summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2005-04-16 11:58:55 +0000
committerrwatson <rwatson@FreeBSD.org>2005-04-16 11:58:55 +0000
commitc2d86096e6b74330fd463602e8dfa9628aff0256 (patch)
treec65bf257287e5dade59291b0b6827145eb438227 /lib
parent74350013ae7222aca7f8c583ac11b88ecf04a188 (diff)
downloadFreeBSD-src-c2d86096e6b74330fd463602e8dfa9628aff0256.zip
FreeBSD-src-c2d86096e6b74330fd463602e8dfa9628aff0256.tar.gz
When parsing the second {uid,gid} in an identity phrase for ugidfw,
check the password or group database before attempting to parse as an integer, as is done for the first {uid,gid} in an identity phrase. Obtained from: TrustedBSD Project Sponsored by: SPAWAR, SPARTA
Diffstat (limited to 'lib')
-rw-r--r--lib/libugidfw/ugidfw.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/lib/libugidfw/ugidfw.c b/lib/libugidfw/ugidfw.c
index d89cece..c1f0516 100644
--- a/lib/libugidfw/ugidfw.c
+++ b/lib/libugidfw/ugidfw.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2002, 2004 Networks Associates Technology, Inc.
+ * Copyright (c) 2002-2005 Networks Associates Technology, Inc.
* All rights reserved.
*
* This software was developed for the FreeBSD Project by Network Associates
@@ -341,13 +341,19 @@ bsde_parse_identity(int argc, char *argv[],
len = snprintf(errstr, buflen, "uid short");
return (-1);
}
- value = strtol(argv[current+1], &endp, 10);
- if (*endp != '\0') {
- len = snprintf(errstr, buflen, "invalid uid: '%s'",
- argv[current+1]);
- return (-1);
+ pwd = getpwnam(argv[current+1]);
+ if (pwd != NULL)
+ uid = pwd->pw_uid;
+ else {
+ value = strtol(argv[current+1], &endp, 10);
+ if (*endp != '\0') {
+ len = snprintf(errstr, buflen,
+ "invalid uid: '%s'",
+ argv[current+1]);
+ return (-1);
+ }
+ uid = value;
}
- uid = value;
uid_seen = 1;
current += 2;
} else if (strcmp("gid", argv[current]) == 0) {
@@ -360,13 +366,19 @@ bsde_parse_identity(int argc, char *argv[],
len = snprintf(errstr, buflen, "gid short");
return (-1);
}
- value = strtol(argv[current+1], &endp, 10);
- if (*endp != '\0') {
- len = snprintf(errstr, buflen, "invalid gid: '%s'",
- argv[current+1]);
- return (-1);
+ grp = getgrnam(argv[current+1]);
+ if (grp != NULL)
+ gid = grp->gr_gid;
+ else {
+ value = strtol(argv[current+1], &endp, 10);
+ if (*endp != '\0') {
+ len = snprintf(errstr, buflen,
+ "invalid gid: '%s'",
+ argv[current+1]);
+ return (-1);
+ }
+ gid = value;
}
- gid = value;
gid_seen = 1;
current += 2;
} else {
OpenPOWER on IntegriCloud