summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2007-02-26 02:07:02 +0000
committerkientzle <kientzle@FreeBSD.org>2007-02-26 02:07:02 +0000
commit3de91924d236e02aa3078c572f2cc3b4c0e25a46 (patch)
treed4793a624b4061ae71b705bad60ae9052aad0901 /lib
parent89842b0829560bcf6bede7ab2e0a2f5d32193ac1 (diff)
downloadFreeBSD-src-3de91924d236e02aa3078c572f2cc3b4c0e25a46.zip
FreeBSD-src-3de91924d236e02aa3078c572f2cc3b4c0e25a46.tar.gz
Move _posix1e_acl_name_to_id out of acl_support.c and into
acl_from_text.c. Since acl_from_text.c is the only place it is used, we can now make this internal utility function "static." As a bonus, acl_set_fd() no longer pulls in getpwuid() for no reason. MFC after: 7 days
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/posix1e/acl_from_text.c53
-rw-r--r--lib/libc/posix1e/acl_support.c53
-rw-r--r--lib/libc/posix1e/acl_support.h1
3 files changed, 52 insertions, 55 deletions
diff --git a/lib/libc/posix1e/acl_from_text.c b/lib/libc/posix1e/acl_from_text.c
index 59d9142..c679b17 100644
--- a/lib/libc/posix1e/acl_from_text.c
+++ b/lib/libc/posix1e/acl_from_text.c
@@ -35,12 +35,15 @@ __FBSDID("$FreeBSD$");
#include <sys/acl.h>
#include "un-namespace.h"
#include <sys/errno.h>
+#include <grp.h>
+#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "acl_support.h"
+static int _posix1e_acl_name_to_id(acl_tag_t tag, char *name, uid_t *id);
static acl_tag_t acl_string_to_tag(char *tag, char *qualifier);
static char *string_skip_whitespace(char *string);
static void string_trim_trailing_whitespace(char *string);
@@ -234,5 +237,53 @@ error_label:
return(NULL);
}
+/*
+ * Given a username/groupname from a text form of an ACL, return the uid/gid
+ * XXX NOT THREAD SAFE, RELIES ON GETPWNAM, GETGRNAM
+ * XXX USES *PW* AND *GR* WHICH ARE STATEFUL AND THEREFORE THIS ROUTINE
+ * MAY HAVE SIDE-EFFECTS
+ *
+ * XXX currently doesn't deal correctly with a numeric uid being passed
+ * instead of a username. What is correct behavior here? Check chown.
+ */
+static int
+_posix1e_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 == 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 == 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);
-
+ default:
+ return (EINVAL);
+ }
+}
diff --git a/lib/libc/posix1e/acl_support.c b/lib/libc/posix1e/acl_support.c
index 61e4cf9..b49808f 100644
--- a/lib/libc/posix1e/acl_support.c
+++ b/lib/libc/posix1e/acl_support.c
@@ -287,59 +287,6 @@ _posix1e_acl_id_to_name(acl_tag_t tag, uid_t id, ssize_t buf_len, char *buf)
}
}
-
-/*
- * Given a username/groupname from a text form of an ACL, return the uid/gid
- * XXX NOT THREAD SAFE, RELIES ON GETPWNAM, GETGRNAM
- * XXX USES *PW* AND *GR* WHICH ARE STATEFUL AND THEREFORE THIS ROUTINE
- * MAY HAVE SIDE-EFFECTS
- *
- * XXX currently doesn't deal correctly with a numeric uid being passed
- * instead of a username. What is correct behavior here? Check chown.
- */
-int
-_posix1e_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 == 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 == 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);
-
- default:
- return (EINVAL);
- }
-}
-
-
/*
* Given a right-shifted permission (i.e., direct ACL_PERM_* mask), fill
* in a string describing the permissions.
diff --git a/lib/libc/posix1e/acl_support.h b/lib/libc/posix1e/acl_support.h
index 6cccf0b..a5c93c0 100644
--- a/lib/libc/posix1e/acl_support.h
+++ b/lib/libc/posix1e/acl_support.h
@@ -39,7 +39,6 @@ int _posix1e_acl_sort(acl_t acl);
int _posix1e_acl(acl_t acl, acl_type_t type);
int _posix1e_acl_id_to_name(acl_tag_t tag, uid_t id, ssize_t buf_len,
char *buf);
-int _posix1e_acl_name_to_id(acl_tag_t tag, char *name, uid_t *id);
int _posix1e_acl_perm_to_string(acl_perm_t perm, ssize_t buf_len,
char *buf);
int _posix1e_acl_string_to_perm(char *string, acl_perm_t *perm);
OpenPOWER on IntegriCloud