From owner-freebsd-current Sun Dec 29 20:25:24 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D7A8337B401 for ; Sun, 29 Dec 2002 20:25:21 -0800 (PST) Received: from bsdone.bsdwins.com (www.bsdwins.com [192.58.184.33]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0965543E4A for ; Sun, 29 Dec 2002 20:25:21 -0800 (PST) (envelope-from jwd@bsdwins.com) Received: from bsdone.bsdwins.com (localhost [127.0.0.1]) by bsdone.bsdwins.com (8.12.5/8.12.5) with ESMTP id gBU4PEW2010174 for ; Sun, 29 Dec 2002 23:25:15 -0500 (EST) (envelope-from jwd@www.bsdwins.com) Received: (from jwd@localhost) by bsdone.bsdwins.com (8.12.5/8.12.5/Submit) id gBU4PEr5010173 for freebsd-current@freebsd.org; Sun, 29 Dec 2002 23:25:14 -0500 (EST) Date: Sun, 29 Dec 2002 23:25:14 -0500 From: John De Boskey To: Current List Subject: cron/crontab openlog() cleanup Message-ID: <20021230042514.GA10022@BSDWins.Com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hi, While debugging a problem recently I had all.log enabled in syslog.conf. One of the things I noted was the messages coming from cron where the ident string was the fully qualified pathname: Dec 29 21:00:00 xxx4 /usr/sbin/cron[7409]: (root) CMD (newsyslog) Dec 29 21:00:00 xxx4 /usr/sbin/cron[7410]: (root) CMD (/usr/libexec/atrun) Any comments on one of the two patch sets below? Either crontab.c and cron.c need a patch, or the common routine they call. cvs server: Diffing . cvs server: Diffing cron Index: cron/cron.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/cron/cron/cron.c,v retrieving revision 1.14 diff -u -r1.14 cron.c --- cron/cron.c 9 Mar 2001 03:14:09 -0000 1.14 +++ cron/cron.c 30 Dec 2002 03:24:23 -0000 @@ -70,7 +70,10 @@ { cron_db database; - ProgramName = argv[0]; + if (ProgramName = strrchr(argv[0],'/') + ++ProgramName; + else + ProgramName = argv[0]; #if defined(BSD) setlinebuf(stdout); cvs server: Diffing crontab Index: crontab/crontab.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/cron/crontab/crontab.c,v retrieving revision 1.19 diff -u -r1.19 crontab.c --- crontab/crontab.c 1 Oct 2002 22:59:11 -0000 1.19 +++ crontab/crontab.c 30 Dec 2002 03:24:23 -0000 @@ -91,7 +91,10 @@ int exitstatus; Pid = getpid(); - ProgramName = argv[0]; + if (ProgramName = strrchr(argv[0],'/') + ++ProgramName; + else + ProgramName = argv[0]; #if defined(POSIX) setlocale(LC_ALL, ""); Or, the single patch to the common openlog interface: Index: lib/misc.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/cron/lib/misc.c,v retrieving revision 1.11 diff -u -r1.11 misc.c --- lib/misc.c 4 Aug 2002 04:32:27 -0000 1.11 +++ lib/misc.c 30 Dec 2002 03:24:23 -0000 @@ -508,14 +508,12 @@ #if defined(SYSLOG) if (!syslog_open) { - /* we don't use LOG_PID since the pid passed to us by - * our client may not be our own. therefore we want to - * print the pid ourselves. - */ + char *Name = strrchr(ProgramName,'/'); + Name = Name ? Name+1 : ProgramName; # ifdef LOG_DAEMON - openlog(ProgramName, LOG_PID, LOG_CRON); + openlog(Name, LOG_PID, LOG_CRON); # else - openlog(ProgramName, LOG_PID); + openlog(Name, LOG_PID); # endif syslog_open = TRUE; /* assume openlog success */ } I removed the comment since it's out-of-date. Maybe I should leave it (to reduce diffs for historical purposes). I tend to prefer this single patch. It's amazing how much this code hasn't changed... I haven't looked at it since '88/'89 when I ported it to a ps/2 Mod80 running ISC Unix... memories... :-) Thanks, John To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message