summaryrefslogtreecommitdiffstats
path: root/src/config.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-01-04 16:25:31 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-01-04 16:25:31 +0100
commit9b2140040471136e99e13806d0d4f88ccd8863fa (patch)
tree8b3081a4e3f6233e9d2627a1bbf7b22a9e59c0a5 /src/config.c
parent6aa3b1b12ae4b753d384472f3935d5e66584a518 (diff)
downloadfastd-9b2140040471136e99e13806d0d4f88ccd8863fa.tar
fastd-9b2140040471136e99e13806d0d4f88ccd8863fa.zip
Set supplementary groups
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c
index 2d387f3..b857d60 100644
--- a/src/config.c
+++ b/src/config.c
@@ -848,6 +848,20 @@ static void configure_user(fastd_context_t *ctx, fastd_config_t *conf) {
conf->gid = grpr->gr_gid;
}
+
+ if (conf->user) {
+ int ngroups = 0;
+ if (getgrouplist(conf->user, conf->gid, NULL, &ngroups) < 0) {
+ /* the user has supplementary groups */
+
+ conf->groups = calloc(ngroups, sizeof(gid_t));
+ if (getgrouplist(conf->user, conf->gid, conf->groups, &ngroups) < 0)
+ exit_errno(ctx, "getgrouplist");
+
+ conf->n_groups = ngroups;
+ }
+ }
+
}
void fastd_configure(fastd_context_t *ctx, fastd_config_t *conf, int argc, char *const argv[]) {
@@ -1036,6 +1050,7 @@ void fastd_config_release(fastd_context_t *ctx, fastd_config_t *conf) {
free(conf->user);
free(conf->group);
+ free(conf->groups);
free(conf->ifname);
free(conf->secret);
free(conf->on_up);