pts: Prevent creating negative user ids
authorAndrew Deason <adeason@sinenomine.net>
Fri, 15 Oct 2010 21:37:55 +0000 (16:37 -0500)
committerJeffrey Altman <jaltman@openafs.org>
Fri, 15 Oct 2010 23:25:42 +0000 (16:25 -0700)
User ids cannot be negative (those are groups). So, error out if a
negative id is specified for createuser.

FIXES 128343

Change-Id: I6e81a419c797944bfed569aac529b9694702823d
Reviewed-on: http://gerrit.openafs.org/2993
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Phillip Moore <w.phillip.moore@gmail.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>

src/ptserver/pts.c

index 3a74c5e..17a9944 100644 (file)
@@ -340,6 +340,12 @@ CreateUser(struct cmd_syndesc *as, void *arock)
                printf("0 isn't a valid user id; aborting\n");
                return EINVAL;
            }
+           if (id < 0) {
+               code = PRBADARG;
+               afs_com_err(whoami, code, "because user id %d was not positive",
+                       id);
+               return code;
+           }
            idi = idi->next;
        } else
            id = 0;