From owner-svn-src-stable@FreeBSD.ORG Sun Feb 17 19:49:30 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 89475239; Sun, 17 Feb 2013 19:49:30 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 6CCE0674; Sun, 17 Feb 2013 19:49:30 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r1HJnUho051866; Sun, 17 Feb 2013 19:49:30 GMT (envelope-from markj@svn.freebsd.org) Received: (from markj@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r1HJnUXT051864; Sun, 17 Feb 2013 19:49:30 GMT (envelope-from markj@svn.freebsd.org) Message-Id: <201302171949.r1HJnUXT051864@svn.freebsd.org> From: Mark Johnston Date: Sun, 17 Feb 2013 19:49:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r246919 - stable/8/usr.sbin/newsyslog X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Feb 2013 19:49:30 -0000 Author: markj Date: Sun Feb 17 19:49:29 2013 New Revision: 246919 URL: http://svnweb.freebsd.org/changeset/base/246919 Log: MFC r245961 r245962 r245963. MFC r245961: When the 'R' flag is used with a newsyslog.conf entry, some fields of the corresponding struct sigwork_entry were left uninitialized, potentially causing an early return from do_sigwork(). Ensure that these fields are initialized, and handle the 'R' flag properly in do_sigwork(). MFC r245962: Ensure that newsyslog -n prints the correct message for a rotation rule that uses the 'R' flag. MFC r245963: Rename the run_cmd field to sw_runcmd to make it consistent with the other fields in struct sigwork_entry. Approved by: emaste (co-mentor) Modified: stable/8/usr.sbin/newsyslog/newsyslog.c Directory Properties: stable/8/usr.sbin/newsyslog/ (props changed) Modified: stable/8/usr.sbin/newsyslog/newsyslog.c ============================================================================== --- stable/8/usr.sbin/newsyslog/newsyslog.c Sun Feb 17 19:49:18 2013 (r246918) +++ stable/8/usr.sbin/newsyslog/newsyslog.c Sun Feb 17 19:49:29 2013 (r246919) @@ -179,7 +179,7 @@ struct sigwork_entry { int sw_pidok; /* true if pid value is valid */ pid_t sw_pid; /* the process id from the PID file */ const char *sw_pidtype; /* "daemon" or "process group" */ - int run_cmd; /* run command or send PID to signal */ + int sw_runcmd; /* run command or send PID to signal */ char sw_fname[1]; /* file the PID was read from or shell cmd */ }; @@ -1830,7 +1830,7 @@ do_sigwork(struct sigwork_entry *swork) int kres, secs; char *tmp; - if (!(swork->sw_pidok) || swork->sw_pid == 0) + if (swork->sw_runcmd == 0 && (!(swork->sw_pidok) || swork->sw_pid == 0)) return; /* no work to do... */ /* @@ -1864,14 +1864,19 @@ do_sigwork(struct sigwork_entry *swork) } if (noaction) { - printf("\tkill -%d %d \t\t# %s\n", swork->sw_signum, - (int)swork->sw_pid, swork->sw_fname); - if (secs > 0) - printf("\tsleep %d\n", secs); + if (swork->sw_runcmd) + printf("\tsh -c '%s %d'\n", swork->sw_fname, + swork->sw_signum); + else { + printf("\tkill -%d %d \t\t# %s\n", swork->sw_signum, + (int)swork->sw_pid, swork->sw_fname); + if (secs > 0) + printf("\tsleep %d\n", secs); + } return; } - if (swork->run_cmd) { + if (swork->sw_runcmd) { asprintf(&tmp, "%s %d", swork->sw_fname, swork->sw_signum); if (tmp == NULL) { warn("can't allocate memory to run %s", @@ -1946,7 +1951,7 @@ do_zipwork(struct zipwork_entry *zwork) else pgm_name++; - if (zwork->zw_swork != NULL && zwork->zw_swork->run_cmd == 0 && + if (zwork->zw_swork != NULL && zwork->zw_swork->sw_runcmd == 0 && zwork->zw_swork->sw_pidok <= 0) { warnx( "log %s not compressed because daemon(s) not notified", @@ -2038,10 +2043,12 @@ save_sigwork(const struct conf_entry *en tmpsiz = sizeof(struct sigwork_entry) + strlen(ent->pid_cmd_file) + 1; stmp = malloc(tmpsiz); - stmp->run_cmd = 0; + stmp->sw_runcmd = 0; /* If this is a command to run we just set the flag and run command */ if (ent->flags & CE_PID2CMD) { - stmp->run_cmd = 1; + stmp->sw_pid = -1; + stmp->sw_pidok = 0; + stmp->sw_runcmd = 1; } else { set_swpid(stmp, ent); }