diff options
author | Brian Feldman <green@FreeBSD.org> | 1999-09-03 18:18:46 +0000 |
---|---|---|
committer | Brian Feldman <green@FreeBSD.org> | 1999-09-03 18:18:46 +0000 |
commit | 1efcedf596030f6be528bbe65999fa821bb2c04c (patch) | |
tree | f1dd33e7b78efd36b1a060607429054b530f1aae /sbin/ipfw | |
parent | 77b3485b11cbb20746eb4d9e9d4275cd68b0bbb7 (diff) | |
download | src-1efcedf596030f6be528bbe65999fa821bb2c04c.tar.gz src-1efcedf596030f6be528bbe65999fa821bb2c04c.zip |
Notes
Diffstat (limited to 'sbin/ipfw')
-rw-r--r-- | sbin/ipfw/ipfw.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/sbin/ipfw/ipfw.c b/sbin/ipfw/ipfw.c index d297119f7bf8..5a160dcd5951 100644 --- a/sbin/ipfw/ipfw.c +++ b/sbin/ipfw/ipfw.c @@ -1273,27 +1273,43 @@ add(ac,av) while (ac) { if (!strncmp(*av,"uid",strlen(*av))) { struct passwd *pwd; + char *end; + uid_t uid; rule.fw_flg |= IP_FW_F_UID; ac--; av++; if (!ac) show_usage("``uid'' requires argument"); - rule.fw_uid = (pwd = getpwnam(*av)) ? pwd->pw_uid - : strtoul(*av, NULL, 0); + uid = strtoul(*av, &end, 0); + if (*end == '\0') + pwd = getpwuid(uid); + else + pwd = getpwnam(*av); + if (pwd == NULL) + show_usage("uid \"%s\" is nonexistant", *av); + rule.fw_uid = pwd->pw_uid; ac--; av++; continue; } if (!strncmp(*av,"gid",strlen(*av))) { struct group *grp; + char *end; + gid_t gid; rule.fw_flg |= IP_FW_F_GID; ac--; av++; if (!ac) show_usage("``gid'' requires argument"); - rule.fw_gid = (grp = getgrnam(*av)) ? (gid_t)grp->gr_gid - : strtoul(*av, NULL, 0); + gid = strtoul(*av, &end, 0); + if (*end == '\0') + grp = getgrgid(gid); + else + grp = getgrnam(*av); + if (grp == NULL) + show_usage("gid \"%s\" is nonexistant", *av); + rule.fw_gid = grp->gr_gid; ac--; av++; continue; } |