1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-03 09:00:21 +00:00

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
This commit is contained in:
Robert Watson 2001-01-08 01:28:53 +00:00
parent de24b6fde3
commit 5aa25ec606
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=70781
2 changed files with 36 additions and 12 deletions

View File

@ -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);

View File

@ -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);