diff options
author | rwatson <rwatson@FreeBSD.org> | 2001-01-08 01:28:53 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2001-01-08 01:28:53 +0000 |
commit | b87b91a453a7baf7ed2f1cd7d84fdc079068e2aa (patch) | |
tree | 1ce48101f4a7e2e894d69745424a5095124140c2 /lib/libc/posix1e/acl_support.c | |
parent | 2c49e670ca56be183507dbfd73026272fc0a12ac (diff) | |
download | FreeBSD-src-b87b91a453a7baf7ed2f1cd7d84fdc079068e2aa.zip FreeBSD-src-b87b91a453a7baf7ed2f1cd7d84fdc079068e2aa.tar.gz |
o Make acl_from_text() support uid's and gid's as well as usernames
and groupnames, by adding appropriate support to acl_name_to_id()
in acl_support.c
Submitted by: green
Diffstat (limited to 'lib/libc/posix1e/acl_support.c')
-rw-r--r-- | lib/libc/posix1e/acl_support.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/libc/posix1e/acl_support.c b/lib/libc/posix1e/acl_support.c index f2e83b7..012d106 100644 --- a/lib/libc/posix1e/acl_support.c +++ b/lib/libc/posix1e/acl_support.c @@ -289,22 +289,34 @@ acl_name_to_id(acl_tag_t tag, char *name, uid_t *id) { struct group *g; struct passwd *p; + unsigned long l; + char *endp; switch(tag) { case ACL_USER: p = getpwnam(name); - if (!p) { - errno = EINVAL; - return (-1); + if (p == NULL) { + l = strtoul(name, &endp, 0); + if (*endp != '\0' || l != (unsigned long)(uid_t)l) { + errno = EINVAL; + return (-1); + } + *id = (uid_t)l; + return (0); } *id = p->pw_uid; return (0); case ACL_GROUP: g = getgrnam(name); - if (!g) { - errno = EINVAL; - return (-1); + if (g == NULL) { + l = strtoul(name, &endp, 0); + if (*endp != '\0' || l != (unsigned long)(gid_t)l) { + errno = EINVAL; + return (-1); + } + *id = (gid_t)l; + return (0); } *id = g->gr_gid; return (0); |