summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2001-01-08 01:28:53 +0000
committerrwatson <rwatson@FreeBSD.org>2001-01-08 01:28:53 +0000
commitb87b91a453a7baf7ed2f1cd7d84fdc079068e2aa (patch)
tree1ce48101f4a7e2e894d69745424a5095124140c2 /lib
parent2c49e670ca56be183507dbfd73026272fc0a12ac (diff)
downloadFreeBSD-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')
-rw-r--r--lib/libc/posix1e/acl_support.c24
-rw-r--r--lib/libposix1e/acl_support.c24
2 files changed, 36 insertions, 12 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);
diff --git a/lib/libposix1e/acl_support.c b/lib/libposix1e/acl_support.c
index f2e83b7..012d106 100644
--- a/lib/libposix1e/acl_support.c
+++ b/lib/libposix1e/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);
OpenPOWER on IntegriCloud