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:
parent
de24b6fde3
commit
5aa25ec606
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=70781
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user