diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-03-12 18:45:18 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-03-12 18:45:18 +0000 |
commit | 512457c082c71e8e8ad12bb0dce928cbe4d2845a (patch) | |
tree | c653f90d6d42a626c70b3de6d5efd093a6e5a73b /libexec | |
parent | 6a3b8f48496babb9ab2c357259879a07c5cc6b44 (diff) |
1) user and group name may start with a number (though it is a bad idea).
For the -u/-g flags do passwd/group file lookups first and then try
as a numeric id.
2) Set the gid based on the uid's passwd file entry if there is one, just
like we do with names.
Partially based on a patch from Brian Poole
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/identd/identd.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/libexec/identd/identd.c b/libexec/identd/identd.c index b82f3809c91..a7ad9182772 100644 --- a/libexec/identd/identd.c +++ b/libexec/identd/identd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: identd.c,v 1.24 2002/01/07 17:08:28 mpech Exp $ */ +/* $OpenBSD: identd.c,v 1.25 2002/03/12 18:45:17 millert Exp $ */ /* * This program is in the public domain and may be used freely by anyone @@ -196,13 +196,15 @@ main(argc, argv) bind_address = optarg; break; case 'u': - if (isdigit(optarg[0])) { + pwd = getpwnam(optarg); + if (pwd == NULL && isdigit(optarg[0])) { set_uid = atoi(optarg); - break; + if ((pwd = getpwuid(set_uid)) == NULL) + break; } - pwd = getpwnam(optarg); - if (!pwd) - ERROR1("no such user (%s) for -u option", optarg); + if (pwd == NULL) + ERROR1("no such user (%s) for -u option", + optarg); else { set_uid = pwd->pw_uid; if (setgid == 0) @@ -210,7 +212,8 @@ main(argc, argv) } break; case 'g': - if (isdigit(optarg[0])) { + grp = getgrnam(optarg); + if (grp == NULL && isdigit(optarg[0])) { set_gid = atoi(optarg); break; } |