]> git.cameronkatri.com Git - pw-darwin.git/blobdiff - libc/gen/pw_scan.c
integrate from head@185615
[pw-darwin.git] / libc / gen / pw_scan.c
index 3d49aa88be8f38e938259df48c62f2f588627810..9242dd054244ebe89b7cede690de1dcedf24d7b3 100644 (file)
  * 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.
@@ -124,6 +120,13 @@ __pw_scan(char *bp, struct passwd *pw, int flags)
                goto fmt;
        if (p[0])
                pw->pw_fields |= _PWF_GID;
+       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)
@@ -173,7 +176,7 @@ __pw_scan(char *bp, struct passwd *pw, int flags)
                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)
@@ -183,6 +186,8 @@ __pw_scan(char *bp, struct passwd *pw, int flags)
                        if (!strcmp(p, sh))
                                break;
                }
+               endusershell();
+       }
        if (p[0])
                pw->pw_fields |= _PWF_SHELL;