Added check for getpwnam returning null.
authorJeremy Allison <jra@samba.org>
Tue, 7 Apr 1998 17:41:56 +0000 (17:41 +0000)
committerJeremy Allison <jra@samba.org>
Tue, 7 Apr 1998 17:41:56 +0000 (17:41 +0000)
Jeremy.

source/utils/smbpasswd.c

index f914e4d4fa8540a962428ab332fefe67af2f8391..f977346fc05fc384e9469f725ac71d33379f5317 100644 (file)
@@ -373,9 +373,13 @@ int main(int argc, char **argv)
         usage(prog_name, True);
     }
 
-    if(*user_name)
-      pwd = getpwnam(user_name);
-    else {
+    if(*user_name) {
+      if((pwd = getpwnam(user_name)) == NULL) {
+        fprintf(stderr, "%s: User \"%s\" was not found in system password file.\n", 
+                    prog_name, user_name);
+        exit(1);
+      }
+    } else {
       if((pwd = getpwuid(real_uid)) != NULL)
         pstrcpy( user_name, pwd->pw_name);
     }