summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-10-23 11:37:10 -0400
committerJune McEnroe <june@causal.agency>2020-10-23 11:37:10 -0400
commit363ab9f834a955b4b664e99f176293c30d6ef75b (patch)
treebbdfed0eac97bc95b92bb54dcb0089b884c981c5
parentRemove default defines of RUNDIR, ETCDIR (diff)
downloadcatsit-363ab9f834a955b4b664e99f176293c30d6ef75b.tar.gz
catsit-363ab9f834a955b4b664e99f176293c30d6ef75b.zip
Only look up group if one is named
-rw-r--r--daemon.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/daemon.c b/daemon.c
index 686b7fd..490e13f 100644
--- a/daemon.c
+++ b/daemon.c
@@ -242,16 +242,17 @@ int main(int argc, char *argv[]) {
 	struct passwd *user = (userName ? getpwnam(userName) : getpwuid(getuid()));
 	if (errno) err(EX_OSFILE, "getpwnam");
 	if (!user) errx(EX_USAGE, "no such user %s", userName);
-
-	errno = 0;
-	struct group *group = (
-		groupName ? getgrnam(groupName) : getgrgid(user->pw_gid)
-	);
-	if (errno) err(EX_OSFILE, "getgrnam");
-	if (!group) errx(EX_USAGE, "no such group %s", groupName);
-
 	serviceUID = user->pw_uid;
-	serviceGID = group->gr_gid;
+
+	if (groupName) {
+		errno = 0;
+		struct group *group = getgrnam(groupName);
+		if (errno) err(EX_OSFILE, "getgrnam");
+		if (!group) errx(EX_USAGE, "no such group %s", groupName);
+		serviceGID = group->gr_gid;
+	} else {
+		serviceGID = user->pw_gid;
+	}
 
 	int len = asprintf(&serviceEnviron[USER], "USER=%s", user->pw_name);
 	if (len < 0) err(EX_OSERR, "asprintf");
colspan='3' class='logmsg'> 2019-07-27Shell script style passJune McEnroe 2019-07-27Add c11.pdfJune McEnroe 2019-07-27Move pdf script to MakefileJune McEnroe 2019-07-27Update macOS neovim to 0.3.8June McEnroe Which somehow still doesn't include my man fix. 2019-07-27Rewrite port makefiles consistentlyJune McEnroe 2019-07-27Rewrite Makefile once more with more organizationJune McEnroe 2019-07-27Reference png.h in bin.7June McEnroe 2019-07-27Revert "Use scheme to style HTMLs"June McEnroe This reverts commit 46237a457ff3c9a813a56f2a442c115bf8610cbc. I don't know why but I don't like it. 2019-07-27Remove scheme text linkJune McEnroe No standard base64 encoder so no way to maintain it. 2019-07-26Update Dark.terminalJune McEnroe Why are the blobs so much bigger now? 2019-07-26Lighten dark whiteJune McEnroe 2019-07-25Add png.3 man pageJune McEnroe 2019-07-25Use scheme to style HTMLsJune McEnroe 2019-07-25Don't match comments in strings in makeJune McEnroe 2019-07-25Generate index.html with links from bin.7June McEnroe 2019-07-24Warn when date has changedJune McEnroe 2019-07-24Add whenJune McEnroe When? Now. 2019-07-24Remove histedit from bitJune McEnroe