From owner-svn-src-all@FreeBSD.ORG Fri May 10 20:55:40 2013 Return-Path: Delivered-To: svn-src-all@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 3D6324DB; Fri, 10 May 2013 20:55:40 +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 1FE6A847; Fri, 10 May 2013 20:55:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4AKteI9046836; Fri, 10 May 2013 20:55:40 GMT (envelope-from markj@svn.freebsd.org) Received: (from markj@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4AKtdCv046835; Fri, 10 May 2013 20:55:40 GMT (envelope-from markj@svn.freebsd.org) Message-Id: <201305102055.r4AKtdCv046835@svn.freebsd.org> From: Mark Johnston Date: Fri, 10 May 2013 20:55:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250478 - stable/9/usr.sbin/newsyslog X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 May 2013 20:55:40 -0000 Author: markj Date: Fri May 10 20:55:39 2013 New Revision: 250478 URL: http://svnweb.freebsd.org/changeset/base/250478 Log: MFC r248776: Fix interval-based rotations when the -t flag is used. In this case, find the most-recently archived logfile and use its mtime to determine whether or not to rotate, as in the non-timestamped case. Previously we would just try to use the mtime of .0, which always results in a rotation since it generally doesn't exist in the -t case. Approved by: emaste Modified: stable/9/usr.sbin/newsyslog/newsyslog.c Directory Properties: stable/9/usr.sbin/newsyslog/ (props changed) Modified: stable/9/usr.sbin/newsyslog/newsyslog.c ============================================================================== --- stable/9/usr.sbin/newsyslog/newsyslog.c Fri May 10 20:02:15 2013 (r250477) +++ stable/9/usr.sbin/newsyslog/newsyslog.c Fri May 10 20:55:39 2013 (r250478) @@ -274,7 +274,7 @@ static void parse_args(int argc, char ** static int parse_doption(const char *doption); static void usage(void); static int log_trim(const char *logname, const struct conf_entry *log_ent); -static int age_old_log(char *file); +static int age_old_log(const char *file); static void savelog(char *from, char *to); static void createdir(const struct conf_entry *ent, char *dirpart); static void createlog(const struct conf_entry *ent); @@ -1445,6 +1445,66 @@ oldlog_entry_compare(const void *a, cons } /* + * Check whether the file corresponding to dp is an archive of the logfile + * logfname, based on the timefnamefmt format string. Return true and fill out + * tm if this is the case; otherwise return false. + */ +static int +validate_old_timelog(const struct dirent *dp, const char *logfname, struct tm *tm) +{ + size_t logfname_len; + char *s; + int c; + + logfname_len = strlen(logfname); + + if (dp->d_type != DT_REG) + return (0); + /* Ignore everything but files with our logfile prefix. */ + if (strncmp(dp->d_name, logfname, logfname_len) != 0) + return (0); + /* Ignore the actual non-rotated logfile. */ + if (dp->d_namlen == logfname_len) + return (0); + + /* + * Make sure we created have found a logfile, so the + * postfix is valid, IE format is: '.