summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoritojun <itojun@openbsd.org>2002-06-09 04:18:56 +0000
committeritojun <itojun@openbsd.org>2002-06-09 04:18:56 +0000
commit3f5c80ae3fd6a854a5f528bec2c66896ba6501ef (patch)
tree77928eccc90511e67432f62ff31329f4f20a483c
parentbit of KNF (diff)
downloadwireguard-openbsd-3f5c80ae3fd6a854a5f528bec2c66896ba6501ef.tar.xz
wireguard-openbsd-3f5c80ae3fd6a854a5f528bec2c66896ba6501ef.zip
allow numeric group ID (group ID appear in /etc/passwd, but not in /etc/group)
niels ok
-rw-r--r--bin/systrace/policy.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/bin/systrace/policy.c b/bin/systrace/policy.c
index c2b50df0b02..89e55352847 100644
--- a/bin/systrace/policy.c
+++ b/bin/systrace/policy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: policy.c,v 1.7 2002/06/05 21:09:02 provos Exp $ */
+/* $OpenBSD: policy.c,v 1.8 2002/06/09 04:18:56 itojun Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
@@ -120,6 +120,7 @@ int
systrace_initpolicy(char *file)
{
gid_t groups[NGROUPS_MAX];
+ char gidbuf[10];
int i;
SPLAY_INIT(&policyroot);
@@ -132,10 +133,15 @@ systrace_initpolicy(char *file)
for (i = 0; i < ngroups; i++) {
struct group *gr;
- if ((gr = getgrgid(groups[i])) == NULL)
- err(1, "getgrgid(%d)", groups[i]);
- if ((groupnames[i] = strdup(gr->gr_name)) == NULL)
- err(1, "strdup(%s)", gr->gr_name);
+ if ((gr = getgrgid(groups[i])) != NULL) {
+ if ((groupnames[i] = strdup(gr->gr_name)) == NULL)
+ err(1, "strdup(%s)", gr->gr_name);
+ } else {
+ snprintf(gidbuf, sizeof(gidbuf), "%lu",
+ (u_long)groups[i]);
+ if ((groupnames[i] = strdup(gidbuf)) == NULL)
+ err(1, "strdup(%s)", gidbuf);
+ }
}
if (userpolicy)