summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorWilbern Cobb <wcobb@cvs.openbsd.org>2002-06-26 23:36:15 +0000
committerWilbern Cobb <wcobb@cvs.openbsd.org>2002-06-26 23:36:15 +0000
commitd7763465fa51acddc377e336bcf842ed4bd300c0 (patch)
tree63637c884cb66779f1a0c60c2c3122b1bba2c57a /usr.bin
parent353fad8ad2a449a12c93135b188934c61a0db784 (diff)
Don't follow symbolic links for (ie. user-owned) log files by default;
closes pr #1913. ok millert@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/newsyslog/newsyslog.85
-rw-r--r--usr.bin/newsyslog/newsyslog.c22
2 files changed, 24 insertions, 3 deletions
diff --git a/usr.bin/newsyslog/newsyslog.8 b/usr.bin/newsyslog/newsyslog.8
index 2443310701d..426e01cf5fe 100644
--- a/usr.bin/newsyslog/newsyslog.8
+++ b/usr.bin/newsyslog/newsyslog.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: newsyslog.8,v 1.21 2001/08/02 18:37:35 mpech Exp $
+.\" $OpenBSD: newsyslog.8,v 1.22 2002/06/26 23:36:14 wcobb Exp $
.\"
.\" Copyright (c) 1997, Jason Downs. All rights reserved.
.\"
@@ -194,6 +194,9 @@ The
.Sq M
flag marks this entry as a monitored
log file.
+The
+.Sq F
+flag specifies that symbolic links should be followed.
.It monitor notification (optional)
Specify the account that should receive notification messages if this is
a monitored log file.
diff --git a/usr.bin/newsyslog/newsyslog.c b/usr.bin/newsyslog/newsyslog.c
index e6bec0c2f2a..594a38a8b3c 100644
--- a/usr.bin/newsyslog/newsyslog.c
+++ b/usr.bin/newsyslog/newsyslog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: newsyslog.c,v 1.44 2002/06/12 06:07:16 mpech Exp $ */
+/* $OpenBSD: newsyslog.c,v 1.45 2002/06/26 23:36:14 wcobb Exp $ */
/*
* Copyright (c) 1999 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -88,7 +88,7 @@ provided "as is" without express or implied warranty.
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: newsyslog.c,v 1.44 2002/06/12 06:07:16 mpech Exp $";
+static char rcsid[] = "$OpenBSD: newsyslog.c,v 1.45 2002/06/26 23:36:14 wcobb Exp $";
#endif /* not lint */
#ifndef CONF
@@ -132,6 +132,7 @@ static char rcsid[] = "$OpenBSD: newsyslog.c,v 1.44 2002/06/12 06:07:16 mpech Ex
#define CE_BINARY 0x04 /* Logfile is in binary, don't add */
/* status messages */
#define CE_MONITOR 0x08 /* Monitory for changes */
+#define CE_FOLLOW 0x10 /* Follow symbolic links */
#define NONE -1
struct conf_entry {
@@ -267,6 +268,19 @@ do_entry(ent)
{
int modtime, size;
+ struct stat sta;
+
+ if (!(ent->flags & CE_FOLLOW)) {
+ if (lstat(ent->log, &sta) != 0)
+ return;
+ if ((sta.st_mode & S_IFLNK) != S_IFREG) {
+ if (verbose) {
+ printf("--> %s is not a regular file, skip\n",
+ ent->log);
+ return;
+ }
+ }
+ }
if (verbose)
printf("%s <%d%s>: ", ent->log, ent->numlogs,
@@ -533,6 +547,10 @@ parse_file(nentries)
case 'm':
working->flags |= CE_MONITOR;
break;
+ case 'F':
+ case 'f':
+ working->flags |= CE_FOLLOW;
+ break;
default:
errx(1, "Illegal flag in config file: %c", *q);
break;