commit 25296f6a3caf6c7c0662eb7364450a160545f55d3a6238f62d461ee7f1791487 from: Anton Lindqvist date: Sun Apr 27 18:53:49 2025 UTC gotwebd: inherit all user groups Required if repos_path is not owned by the _gotwebd group. ok stsp@ commit - 22bc463ea35785216436ee0648181579c6d2bb98b91003111174ebaca9d99ca7 commit + 25296f6a3caf6c7c0662eb7364450a160545f55d3a6238f62d461ee7f1791487 blob - 94883bd0cab664a6bc578751524545a3f8432a301e5e0b522f9d2bd8ee9c50d3 blob + f3560870276ad2453c8ccf53f8f65860dd50599e766d6a01b8d0ab7cd32105ce --- gotwebd/gotwebd.c +++ gotwebd/gotwebd.c @@ -357,12 +357,13 @@ main(int argc, char **argv) struct event_base *evb; struct gotwebd *env; struct passwd *pw; - int ch, i; + int ch, i, gotwebd_ngroups; int no_action = 0; int proc_type = GOTWEBD_PROC_PARENT; const char *conffile = GOTWEBD_CONF; const char *gotwebd_username = GOTWEBD_DEFAULT_USER; const char *www_username = GOTWEBD_WWW_USER; + gid_t gotwebd_groups[NGROUPS_MAX]; gid_t www_gid; const char *argv0; @@ -440,6 +441,9 @@ main(int argc, char **argv) pw = getpwnam(gotwebd_username); if (pw == NULL) fatalx("unknown user %s", gotwebd_username); + if (getgrouplist(gotwebd_username, pw->pw_gid, gotwebd_groups, + &gotwebd_ngroups) == -1) + fatalx("too many groups for user %s", gotwebd_username); /* check for root privileges */ if (geteuid()) @@ -469,7 +473,7 @@ main(int argc, char **argv) setproctitle("gotweb"); log_procinit("gotweb"); - if (setgroups(1, &pw->pw_gid) == -1 || + if (setgroups(gotwebd_ngroups, gotwebd_groups) == -1 || setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) == -1 || setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) == -1) fatal("failed to drop privileges");