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 @@ -975,12 +975,13 @@ cb_access_method_params (enum gconf_callback_command cmd, if (assert_string_arg (locus, cmd, vp)) break; meth->parmv[i] = xstrdup (vp->v.string); } + gl_list_iterator_free (&itr); meth->parmv[i] = NULL; } return 0; } static struct gconf_keyword access_method_kw[] = { @@ -1221,12 +1222,88 @@ cb_spool (enum gconf_callback_command cmd, gconf_error (locus, 0, _("invalid use of block statement")); } return 0; } +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"), gconf_type_bool, &daemon_mode }, { "foreground", NULL, N_("Start in foreground even in daemon mode"), gconf_type_bool, &foreground }, @@ -1234,12 +1311,17 @@ static struct gconf_keyword wydawca_kw[] = { gconf_type_bool, &single_process }, { "wakeup-interval", N_("time"), N_("Set wake-up interval"), gconf_type_string, &wakeup_interval, 0, cb_interval }, { "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"), gconf_type_string, &lockdir }, { "lock-expire-time", N_("interval"), N_("Define lock expiration interval"), gconf_type_string, &lock_expire_time, 0, cb_interval }, |