* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
{
uid_t id;
int root;
- char *p, *sh;
+ char *ep, *p, *sh;
if (pw_big_ids_warning == -1)
pw_big_ids_warning = getenv("PW_SCAN_BIG_IDS") == NULL ? 1 : 0;
return (0);
}
}
- id = strtoul(p, (char **)NULL, 10);
+ id = strtoul(p, &ep, 10);
if (errno == ERANGE) {
if (flags & _PWSCAN_WARN)
warnx("%s > max uid value (%lu)", p, ULONG_MAX);
return (0);
}
+ if (*ep != '\0') {
+ if (flags & _PWSCAN_WARN)
+ warnx("%s uid is incorrect", p);
+ return (0);
+ }
if (root && id) {
if (flags & _PWSCAN_WARN)
warnx("root uid should be 0");
goto fmt;
if (p[0])
pw->pw_fields |= _PWF_GID;
- id = strtoul(p, (char **)NULL, 10);
+ else {
+ if (pw->pw_name[0] != '+' && pw->pw_name[0] != '-') {
+ if (flags & _PWSCAN_WARN)
+ warnx("no gid for user %s", pw->pw_name);
+ return (0);
+ }
+ }
+ id = strtoul(p, &ep, 10);
if (errno == ERANGE) {
if (flags & _PWSCAN_WARN)
warnx("%s > max gid value (%lu)", p, ULONG_MAX);
return (0);
}
+ if (*ep != '\0') {
+ if (flags & _PWSCAN_WARN)
+ warnx("%s gid is incorrect", p);
+ return (0);
+ }
if (flags & _PWSCAN_WARN && pw_big_ids_warning && id > USHRT_MAX) {
warnx("%s > recommended max gid value (%u)", p, USHRT_MAX);
/* return (0); This should not be fatal! */
goto fmt;
p = pw->pw_shell;
- if (root && *p) /* empty == /bin/sh */
+ if (root && *p) { /* empty == /bin/sh */
for (setusershell();;) {
if (!(sh = getusershell())) {
if (flags & _PWSCAN_WARN)
if (!strcmp(p, sh))
break;
}
+ endusershell();
+ }
if (p[0])
pw->pw_fields |= _PWF_SHELL;