summaryrefslogtreecommitdiffstats
path: root/usr.sbin/newsyslog
diff options
context:
space:
mode:
authorgad <gad@FreeBSD.org>2003-08-19 03:53:03 +0000
committergad <gad@FreeBSD.org>2003-08-19 03:53:03 +0000
commitb21b4520edc240251c53099b6c14b637c9baf097 (patch)
tree9168d58cef0f9b2f1a4e122a95d5e7b1f08392c2 /usr.sbin/newsyslog
parent19b67cf857d897a717de564b1fbd433576000ca6 (diff)
downloadFreeBSD-src-b21b4520edc240251c53099b6c14b637c9baf097.zip
FreeBSD-src-b21b4520edc240251c53099b6c14b637c9baf097.tar.gz
When checking the 'user:group' field in newsyslog.conf, freebsd's source
was mistakenly calling the standard isnumber() function to find out if the given 'user' or 'group' were all numeric. This meant that only the first character of the fields were actually checked, so a username of (say) '3com' would look like a number, and thus get mapped to uid=3 (bin) instead of username=3com. This bug was introduced back in freebsd's v1.1. That initial import almost matches netbsd's v1.9, except that an internal isnumber() routine was removed in favor of the standard library version. The thing is, that internal routine was checking the entire string, and not just the first digit. In OpenBSD, isnumber() was eventually renamed to isnumberstr() to make the distinction more obvious, and I'm going to follow that lead. I believe this also happens to remove the last references to isnumber() in the entire freebsd base system. Obtained from: OpenBSD, by a long circuitous route MFC after: 5 days
Diffstat (limited to 'usr.sbin/newsyslog')
-rw-r--r--usr.sbin/newsyslog/newsyslog.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c
index 7ed501c..2a003f2 100644
--- a/usr.sbin/newsyslog/newsyslog.c
+++ b/usr.sbin/newsyslog/newsyslog.c
@@ -125,6 +125,7 @@ static void parse_file(FILE *cf, const char *cfname, struct conf_entry **work_p,
struct conf_entry **glob_p, struct conf_entry **defconf_p);
static char *sob(char *p);
static char *son(char *p);
+static int isnumberstr(const char *);
static char *missing_field(char *p, char *errline);
static void do_entry(struct conf_entry * ent);
static void expand_globs(struct conf_entry **work_p,
@@ -895,7 +896,7 @@ parse_file(FILE *cf, const char *cfname, struct conf_entry **work_p,
(group = strrchr(q, '.')) != NULL) {
*group++ = '\0';
if (*q) {
- if (!(isnumber(*q))) {
+ if (!(isnumberstr(q))) {
if ((pwd = getpwnam(q)) == NULL)
errx(1,
"error in config file; unknown user:\n%s",
@@ -908,7 +909,7 @@ parse_file(FILE *cf, const char *cfname, struct conf_entry **work_p,
q = group;
if (*q) {
- if (!(isnumber(*q))) {
+ if (!(isnumberstr(q))) {
if ((grp = getgrnam(q)) == NULL)
errx(1,
"error in config file; unknown group:\n%s",
@@ -1536,6 +1537,17 @@ son(char *p)
return (p);
}
+/* Check if string is actually a number */
+static int
+isnumberstr(const char *string)
+{
+ while (*string) {
+ if (!isdigitch(*string++))
+ return (0);
+ }
+ return (1);
+}
+
/*
* Parse a limited subset of ISO 8601. The specific format is as follows:
*
OpenPOWER on IntegriCloud