Date: Tue, 13 May 2014 20:55:32 GMT From: David Mackay <davidjx8p@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/189785: [PATCH] amd(8) is missing an option to prevent daemonise Message-ID: <201405132055.s4DKtWnm078940@cgiserv.freebsd.org> Resent-Message-ID: <201405132100.s4DL00ml062575@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 189785 >Category: bin >Synopsis: [PATCH] amd(8) is missing an option to prevent daemonise >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue May 13 21:00:00 UTC 2014 >Closed-Date: >Last-Modified: >Originator: David Mackay >Release: 11.0-CURRENT >Organization: N/A >Environment: FreeBSD bigbertha-fbsd 11.0-CURRENT FreeBSD 11.0-CURRENT #0 574a744(master): Sat May 3 11:43:10 BST 2014 root@bigbertha-fbsd:/usr/obj/usr/src/sys/BIGBERTHA amd64 >Description: amd(8) should provide a command-line option that will tell it not to daemonise. This is necessary for running under e.g. daemontools/runit supervision. >How-To-Repeat: N/A >Fix: See the attached patch. It adds a command-line-option to prevent it daemonising. Patch attached with submission follows: diff --git a/contrib/amd/amd/amd.c b/contrib/amd/amd/amd.c index 3fc25f8..09edda3 100644 --- a/contrib/amd/amd/amd.c +++ b/contrib/amd/amd/amd.c @@ -546,7 +546,7 @@ main(int argc, char *argv[]) } #endif /* HAVE_MAP_NIS */ - if (!amuDebug(D_DAEMON)) + if ((!amuDebug(D_DAEMON)) && (!gopt.nodaemon)) ppid = daemon_mode(); /* diff --git a/contrib/amd/amd/amd.h b/contrib/amd/amd/amd.h index 0e371b7..0f4bf38 100644 --- a/contrib/amd/amd/amd.h +++ b/contrib/amd/amd/amd.h @@ -281,6 +281,7 @@ struct amu_global_options { char *mount_type; /* mount type for map */ char *debug_mtab_file; /* path for the mtab file during debug mode */ u_int flags; /* various CFM_* flags */ + int nodaemon; /* prevents forking into background if 1 */ #define AMU_TYPE_NONE -1 /* for amfs_auto_{timeo,retrans,toplvl} */ #define AMU_TYPE_UDP 0 /* for amfs_auto_{timeo,retrans,toplvl} */ diff --git a/contrib/amd/amd/get_args.c b/contrib/amd/amd/get_args.c index 8f743e6..a479a1b 100644 --- a/contrib/amd/amd/get_args.c +++ b/contrib/amd/amd/get_args.c @@ -131,7 +131,7 @@ show_usage(void) \t[-k kernel_arch] [-l logfile%s\n\ \t[-t timeout.retrans] [-w wait_timeout] [-A arch] [-C cluster_name]\n\ \t[-o op_sys_ver] [-O op_sys_name]\n\ -\t[-F conf_file] [-T conf_tag]", am_get_progname(), +\t[-F conf_file] [-T conf_tag] [-N nodaemon]", am_get_progname(), #ifdef HAVE_SYSLOG # ifdef LOG_DAEMON "|\"syslog[:facility]\"]" @@ -162,7 +162,7 @@ get_args(int argc, char *argv[]) { int opt_ch, i; FILE *fp = stdin; - char getopt_arguments[] = "+nprvSa:c:d:k:l:o:t:w:x:y:C:D:F:T:O:HA:"; + char getopt_arguments[] = "+nprvSNa:c:d:k:l:o:t:w:x:y:C:D:F:T:O:HA:"; char *getopt_args; int print_version = 0; /* 1 means we should print version info */ @@ -294,6 +294,10 @@ get_args(int argc, char *argv[]) exit(1); break; + case 'N': + gopt.nodaemon = 1; + break; + case 'O': gopt.op_sys = optarg; break; >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405132055.s4DKtWnm078940>