diff options
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c index b1f339f..b6e2533 100644 --- a/src/config.c +++ b/src/config.c @@ -978,6 +978,7 @@ cb_access_method_params (enum gconf_callback_command cmd, meth->parmv[i] = xstrdup (vp->v.string); } + gl_list_iterator_free (&itr); meth->parmv[i] = NULL; } return 0; @@ -1224,6 +1225,82 @@ cb_spool (enum gconf_callback_command cmd, } +static int +cb_user (enum gconf_callback_command cmd, + gconf_locus_t *locus, + void *varptr, + gconf_value_t *value, + void *cb_data) +{ + int rc; + struct passwd *pw; + + if (assert_string_arg (locus, cmd, value)) + return 1; + + pw = getpwnam (value->v.string); + if (!pw) + { + gconf_error (locus, 0, _("no such user: %s"), value->v.string); + return 1; + } + + wydawca_uid = pw->pw_uid; + wydawca_gid = pw->pw_gid; + return 0; +} + +static int +cb_supp_groups (enum gconf_callback_command cmd, + gconf_locus_t *locus, + void *varptr, + gconf_value_t *value, + void *cb_data) +{ + if (cmd != gconf_callback_set_value) + { + gconf_error (locus, 0, _("Unexpected block statement")); + return 1; + } + if (!value || value->type != GCONF_TYPE_LIST) + { + gconf_error (locus, 0, _("expected list value")); + return 1; + } + + wydawca_supp_groupc = gl_list_size (value->v.list); + if (wydawca_supp_groupc == 0) + wydawca_supp_groups = NULL; + else + { + int i; + gl_list_iterator_t itr; + const void *p; + + wydawca_supp_groups = xcalloc (wydawca_supp_groupc, + sizeof (wydawca_supp_groups[0])); + itr = gl_list_iterator (value->v.list); + for (i = 0; gl_list_iterator_next (&itr, &p, NULL); i++) + { + const gconf_value_t *vp = p; + struct group *grp; + + if (assert_string_arg (locus, cmd, vp)) + break; + grp = getgrnam (vp->v.string); + if (!grp) + { + gconf_error (locus, 0, _("no such group: %s"), value->v.string); + break; + } + wydawca_supp_groups[i] = grp->gr_gid; + } + gl_list_iterator_free (&itr); + } + return 0; +} + + static struct gconf_keyword wydawca_kw[] = { { "daemon", NULL, N_("Enable daemon mode"), @@ -1237,6 +1314,11 @@ static struct gconf_keyword wydawca_kw[] = { { "pidfile", N_("file"), N_("Set pid file name"), gconf_type_string, &pidfile }, + { "user", N_("name"), N_("Run with UID and GID of this user"), + gconf_type_string, NULL, 0, cb_user }, + { "group", NULL, N_("Retain these supplementary groups"), + gconf_type_string|GCONF_LIST, NULL, 0, cb_supp_groups }, + { "locking", NULL, N_("Enable or disable locking"), gconf_type_bool, &enable_locking }, { "lockdir", N_("dir"), N_("Set directory for lock files"), |