From owner-freebsd-bugs@FreeBSD.ORG Sun Nov 8 23:30:03 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 252B11065672 for ; Sun, 8 Nov 2009 23:30:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 053F28FC16 for ; Sun, 8 Nov 2009 23:30:03 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id nA8NU1VL040949 for ; Sun, 8 Nov 2009 23:30:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id nA8NU1Lt040946; Sun, 8 Nov 2009 23:30:01 GMT (envelope-from gnats) Resent-Date: Sun, 8 Nov 2009 23:30:01 GMT Resent-Message-Id: <200911082330.nA8NU1Lt040946@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, Dan Lukes Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AE88D106566B for ; Sun, 8 Nov 2009 23:29:23 +0000 (UTC) (envelope-from dan@obluda.cz) Received: from master7.ms.mff.cuni.cz (master7.ms.mff.cuni.cz [195.113.20.22]) by mx1.freebsd.org (Postfix) with ESMTP id 498BD8FC08 for ; Sun, 8 Nov 2009 23:29:22 +0000 (UTC) Received: (from root@localhost) by master7.ms.mff.cuni.cz (8.14.3/8.14.3) id nA8NTLaB021533 for FreeBSD-gnats-submit@freebsd.org; Mon, 9 Nov 2009 00:29:21 +0100 (CET) (envelope-from dan@obluda.cz) Message-Id: <200911082329.nA8NTLaB021533@master7.ms.mff.cuni.cz> Date: Mon, 9 Nov 2009 00:29:21 +0100 (CET) From: Dan Lukes To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/140397: newsyslog doesn't handle stopped daemons correctly X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Dan Lukes List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Nov 2009 23:30:03 -0000 >Number: 140397 >Category: bin >Synopsis: newsyslog doesn't handle stopped daemons correctly >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Nov 08 23:30:01 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Dan Lukes >Release: FreeBSD 7.2-RELEASE-p3 i386 >Organization: Obludarium >Environment: analyzed on: System: FreeBSD 7.2-RELEASE-p3 usr.sbin/newsyslog/newsyslog.c,v 1.107.2.1.4.1 2009/04/15 03:14:26 but apply to: HEAD usr.sbin/newsyslog/newsyslog.c,v 1.108 2008/01/30 22:11:59 as well >Description: The current code says: /* * Warn if the PID file is empty, but do not consider * it an error. Most likely it means the process has * has terminated, so it should be safe to rotate any * log files that the process would have been using. */ True, but the same apply when PID file doesn't exist at all. The code should handle missing PID file the same way as empty PID file. The missing PID file is handled like error for now. >How-To-Repeat: Stop a daemon that remove the PID file on exit. Try to use newsyslog to rotate it's log file while daemon not running. >Fix: --- usr.sbin/newsyslog/newsyslog.c.orig 2009-04-15 05:14:26.000000000 +0200 +++ usr.sbin/newsyslog/newsyslog.c 2009-11-07 00:45:09.000000000 +0100 @@ -1779,7 +1779,17 @@ f = fopen(ent->pid_file, "r"); if (f == NULL) { - warn("can't open pid file: %s", ent->pid_file); + if (errno == ENOENT) { + /* + * Warn if the PID file doesn't exist, but do not consider + * it an error. Most likely it means the process has + * has terminated, so it should be safe to rotate any + * log files that the process would have been using. + */ + swork->sw_pidok = 1; + warnx("pid file doesn't exist: %s", ent->pid_file); + } else + warn("can't open pid file: %s", ent->pid_file); return; } >Release-Note: >Audit-Trail: >Unformatted: