Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Aug 2001 03:40:02 -0700 (PDT)
From:      dirk.meyer@dinoex.sub.org (Dirk Meyer)
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/29363: [PATCH] newsyslog can support time as extension
Message-ID:  <200108011040.f71Ae2x24949@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/29363; it has been noted by GNATS.

From: dirk.meyer@dinoex.sub.org (Dirk Meyer)
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/29363: [PATCH] newsyslog can support time as
	extension
Date: Wed, 01 Aug 2001 12:33:27 +0200

 The stable patch had an stale line (conflicts).
 here the correct version.
 
 Index: newsyslog.8
 ===================================================================
 RCS file: /home/ncvs/src/usr.sbin/newsyslog/newsyslog.8,v
 retrieving revision 1.32
 diff -u -r1.32 newsyslog.8
 --- newsyslog.8	2001/07/30 15:17:17	1.32
 +++ newsyslog.8	2001/08/01 10:28:56
 @@ -28,6 +28,7 @@
  .Op Fl Fnrv
  .Op Fl f Ar config_file
  .Op Fl a Ar directory
 +.Op Fl T Ar timeformat
  .Op Ar
  .Sh DESCRIPTION
  .Nm Newsyslog
 @@ -354,6 +355,14 @@
  to trim the logs, even if the trim conditions have not been met.  This
  option is useful for diagnosing system problems by providing you with
  fresh logs that contain only the problems.
 +.It Fl T
 +Time based extension
 +.Nm
 +to rename all logs that get trimmed into with an extension based on the
 +argument given by this option. This option can be any strfime(3) string.
 + This function is intended for permantely storing of logfiles.  If the
 +patten results to an already existing file, operations breaks without
 +cleanup, leaving stale logs in place, that might be ovewritten.
  .El
  .Pp
  If additional command line arguments are given,
 Index: newsyslog.c
 ===================================================================
 RCS file: /home/ncvs/src/usr.sbin/newsyslog/newsyslog.c,v
 retrieving revision 1.37
 diff -u -r1.37 newsyslog.c
 --- newsyslog.c	2001/07/31 16:25:55	1.37
 +++ newsyslog.c	2001/08/01 10:28:59
 @@ -90,7 +90,9 @@
  int needroot = 1;		/* Root privs are necessary */
  int noaction = 0;		/* Don't do anything, just show it */
  int force = 0;			/* Force the trim no matter what */
 -char *archdirname;		/* Directory path to old logfiles archive */
 +int timename = 0;		/* Use time of rotation as suffix */
 +const char *archdirname;	/* Directory path to old logfiles archive */
 +const char *timearg;		/* Pattern to expand into extension */
  const char *conf = _PATH_CONF;	/* Configuration file to use */
  time_t timenow;
  
 @@ -227,7 +229,7 @@
  	if ((p = strchr(hostname, '.'))) {
  		*p = '\0';
  	}
 -	while ((c = getopt(argc, argv, "nrvFf:a:t:")) != -1)
 +	while ((c = getopt(argc, argv, "nrvFf:a:t:T:")) != -1)
  		switch (c) {
  		case 'n':
  			noaction++;
 @@ -248,6 +250,10 @@
  		case 'F':
  			force++;
  			break;
 +		case 'T':
 +			timename++;
 +			timearg = optarg;
 +			break;
  		default:
  			usage();
  		}
 @@ -516,6 +522,7 @@
  	int notified, need_notification, fd, _numdays;
  	struct stat st;
  	pid_t pid;
 +	time_t now;
  
  #ifdef _IBMR2
  	/*
 @@ -633,6 +640,16 @@
  		if (noaction)
  			printf("mv %s to %s\n", log, file1);
  		else {
 +			/* change file1 to hold the new name */
 +			if (timename) {
 +				now = time( NULL );
 +				(void) strftime(file2, sizeof(file2), timearg, localtime( &now ) );
 +				if (archtodir)
 +					(void) snprintf(file1, sizeof(file1), "%s/%s.%s", dirpart, namepart, file2);
 +				else
 +					(void) snprintf(file1, sizeof(file1), "%s.%s", log, file2);
 +			}
 +
  			if (archtodir)
  				movefile(log, file1, perm, owner_uid,
  				    group_gid);
 @@ -683,26 +700,17 @@
  			    "log %s not compressed because daemon not notified",
  			    log);
  		else if (noaction)
 -			printf("Compress %s.0\n", log);
 +			printf("Compress %s\n", file1);
  		else {
  			if (notified) {
  				if (verbose)
  					printf("small pause to allow daemon to close log\n");
  				sleep(10);
 -			}
 -			if (archtodir) {
 -				(void) snprintf(file1, sizeof(file1), "%s/%s",
 -				    dirpart, namepart);
 -				if (flags & CE_COMPACT)
 -					compress_log(file1);
 -				else if (flags & CE_BZCOMPACT)
 -					bzcompress_log(file1);
 -			} else {
 -				if (flags & CE_COMPACT)
 -					compress_log(log);
 -				else if (flags & CE_BZCOMPACT)
 -					bzcompress_log(log);
  			}
 +			if (flags & CE_COMPACT)
 +				compress_log(file1);
 +			else if (flags & CE_BZCOMPACT)
 +				bzcompress_log(file1);
  		}
  	}
  }
 @@ -729,7 +737,7 @@
  	pid_t pid;
  	char tmp[MAXPATHLEN];
  
 -	(void) snprintf(tmp, sizeof(tmp), "%s.0", log);
 +	(void) snprintf(tmp, sizeof(tmp), "%s", log);
  	pid = fork();
  	if (pid < 0)
  		err(1, "gzip fork");

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200108011040.f71Ae2x24949>