~armaan/opendoas

71b759e2542878de5c75a7101f2400cf35ec6299 — Armaan Bhojwani 3 months ago b3ac44f
Change the way insults are enabled

Now they are configured entirely with the configure script.

Will be working on a config file option as well.
3 files changed, 12 insertions(+), 16 deletions(-)

M configure
M doas.c
M insults.c
M configure => configure +4 -5
@@ 28,7 28,7 @@ usage: configure [options]

  --with-timestamp       enable timestamp support

  --with-kiss-insults    enable kiss insults
  --without-insults      disable insults

  --uid-max=NUM          set UID_MAX (default 65535)
  --gid-max=NUM          set GID_MAX (default 65535)


@@ 40,7 40,6 @@ EOF

# defaults
WITHOUT_TIMESTAMP=yes
WITHOUT_KISS_INSULTS=""
UID_MAX=65535
GID_MAX=65535



@@ 63,7 62,7 @@ for x; do
	--with-shadow) WITHOUT_SHADOW=; WITHOUT_PAM=yes ;;
	--without-pam) WITHOUT_PAM=yes ;;
	--without-shadow) WITHOUT_SHADOW=yes ;;
	--with-kiss-insults) WITH_KISS_INSULTS=yes ;;
	--without-insults) WITHOUT_INSULTS=yes ;;
	--with-timestamp) WITHOUT_TIMESTAMP= ;;
	--without-timestamp) WITHOUT_TIMESTAMP=yes ;;
	--uid-max) UID_MAX=$var ;;


@@ 227,8 226,8 @@ int main(void) {

definsults() {
	printf 'SRCS	+= insults.c\n' >>$CONFIG_MK
	[ -n "$WITH_KISS_INSULTS" ] && {
		printf '#define DOAS_INSULTS_KISS\n' >>$CONFIG_H
	[ -z "$WITHOUT_INSULTS" ] && {
		printf '#define DOAS_INSULTS\n' >>$CONFIG_H
	}
	return 0
}

M doas.c => doas.c +4 -0
@@ 239,7 239,11 @@ mygetpwuid_r(uid_t uid, struct passwd *pwd, struct passwd **result)
void
authfail(void)
{

#ifdef DOAS_INSULTS
	printf("%s\n", getinsult());
#endif

	errx(1, "Authentication failed");
}


M insults.c => insults.c +4 -11
@@ 4,9 4,8 @@
#include "config.h"

char *insults[] = {

    /*
     * These insults were stolen from the Sudo project.
     * These insults were stolen from the Sudo project, with some additions.
     * The copyright header on those files states:
     *     ISC license
     *     Copyright (c) 1996-2018Todd C. Miller <Todd.Miller@sudo.ws>


@@ 73,15 72,9 @@ char *insults[] = {
    "This man, he doesn't know when he's beaten! He doesn't know when he's winning, either. He has no... sort of... sensory apparatus...",
    "There's nothing wrong with you that an expensive operation can't prolong.",
    "I'm very sorry, but I'm not allowed to argue unless you've paid.",

#ifdef DOAS_INSULTS_KISS
    /*
     * Insults from the KISS Linux community
     */

    "",

#endif
    "You are being naughty this year.",
    "A new shipment of coal is on it's way.",
    "Santa is not amused",
};

const char *