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
This commit is contained in:
parent
7a79a9d713
commit
c877fb5131
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=119102
@ -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:
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user