From owner-freebsd-bugs@FreeBSD.ORG Tue May 13 21:00:00 2014 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9335A628 for ; Tue, 13 May 2014 21:00:00 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7094E2E06 for ; Tue, 13 May 2014 21:00:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s4DL00mH062576 for ; Tue, 13 May 2014 21:00:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s4DL00ml062575; Tue, 13 May 2014 21:00:00 GMT (envelope-from gnats) Resent-Date: Tue, 13 May 2014 21:00:00 GMT Resent-Message-Id: <201405132100.s4DL00ml062575@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, David Mackay Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 35D34501 for ; Tue, 13 May 2014 20:55:33 +0000 (UTC) Received: from cgiserv.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 097782DD8 for ; Tue, 13 May 2014 20:55:33 +0000 (UTC) Received: from cgiserv.freebsd.org ([127.0.1.6]) by cgiserv.freebsd.org (8.14.8/8.14.8) with ESMTP id s4DKtWww078941 for ; Tue, 13 May 2014 20:55:32 GMT (envelope-from nobody@cgiserv.freebsd.org) Received: (from nobody@localhost) by cgiserv.freebsd.org (8.14.8/8.14.8/Submit) id s4DKtWnm078940; Tue, 13 May 2014 20:55:32 GMT (envelope-from nobody) Message-Id: <201405132055.s4DKtWnm078940@cgiserv.freebsd.org> Date: Tue, 13 May 2014 20:55:32 GMT From: David Mackay To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: bin/189785: [PATCH] amd(8) is missing an option to prevent daemonise X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 May 2014 21:00:00 -0000 >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: