diff options
author | Edward Tomasz Napierala <trasz@FreeBSD.org> | 2015-11-29 11:30:17 +0000 |
---|---|---|
committer | Edward Tomasz Napierala <trasz@FreeBSD.org> | 2015-11-29 11:30:17 +0000 |
commit | 478f7a726bdf7270f9e5a770eec1c6926eb725ce (patch) | |
tree | 1dfcc81991c6905b22e03cc466283d0a5532132f /usr.bin/rctl | |
parent | d3214e8d6dc187fbf627f15cdd5749825f82eb6f (diff) | |
download | src-478f7a726bdf7270f9e5a770eec1c6926eb725ce.tar.gz src-478f7a726bdf7270f9e5a770eec1c6926eb725ce.zip |
User and group identifiers the rctl(8) utility receives from the kernel
are always in numeric form; don't try to resolve them by names. This
speeds up rule listing with large rulesets by about 50%.
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Notes
Notes:
svn path=/head/; revision=291445
Diffstat (limited to 'usr.bin/rctl')
-rw-r--r-- | usr.bin/rctl/rctl.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.bin/rctl/rctl.c b/usr.bin/rctl/rctl.c index 915303612971..50fd1c658619 100644 --- a/usr.bin/rctl/rctl.c +++ b/usr.bin/rctl/rctl.c @@ -193,7 +193,7 @@ humanize_ids(char *rule) struct passwd *pwd; struct group *grp; const char *subject, *textid, *rest; - char *humanized; + char *end, *humanized; subject = strsep(&rule, ":"); textid = strsep(&rule, ":"); @@ -206,12 +206,16 @@ humanize_ids(char *rule) /* Replace numerical user and group ids with names. */ if (strcasecmp(subject, "user") == 0) { - id = parse_user(textid); + id = strtod(textid, &end); + if ((size_t)(end - textid) != strlen(textid)) + errx(1, "malformed uid '%s'", textid); pwd = getpwuid(id); if (pwd != NULL) textid = pwd->pw_name; } else if (strcasecmp(subject, "group") == 0) { - id = parse_group(textid); + id = strtod(textid, &end); + if ((size_t)(end - textid) != strlen(textid)) + errx(1, "malformed gid '%s'", textid); grp = getgrgid(id); if (grp != NULL) textid = grp->gr_name; |