diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2009-05-25 19:26:08 +0200 |
---|---|---|
committer | Simo Sorce <ssorce@redhat.com> | 2009-05-26 09:12:47 -0400 |
commit | 4fcb0a5f5dfef2c391367699243c36259da90375 (patch) | |
tree | 0f09704a401c5f8a2e2fe0a1c41aedfd03a84253 /server/tools | |
parent | 419d4579bcb84a3b10d8b5048df2087a3f55544f (diff) | |
download | sssd-4fcb0a5f5dfef2c391367699243c36259da90375.tar.gz sssd-4fcb0a5f5dfef2c391367699243c36259da90375.tar.bz2 sssd-4fcb0a5f5dfef2c391367699243c36259da90375.zip |
Move useradd defaults to confdb
Previously, sss_useradd defaults were hardcoded with no way to
change user's default shell or base for home directory. This patch moves
them into config/user_defaults
Diffstat (limited to 'server/tools')
-rw-r--r-- | server/tools/sss_useradd.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/server/tools/sss_useradd.c b/server/tools/sss_useradd.c index f573877f..a01cd7f8 100644 --- a/server/tools/sss_useradd.c +++ b/server/tools/sss_useradd.c @@ -73,6 +73,14 @@ #define USERADD_USERNAME "%s " #endif +/* Default settings for user attributes */ +#define CONFDB_DFL_SECTION "config/user_defaults" + +#define DFL_SHELL_ATTR "defaultShell" +#define DFL_BASEDIR_ATTR "baseDirectory" + +#define DFL_SHELL_VAL "/bin/bash" +#define DFL_BASEDIR_VAL "/home" struct user_add_ctx { struct sysdb_req *sysreq; @@ -304,7 +312,8 @@ int main(int argc, const char **argv) const char *pc_group = NULL; const char *pc_gecos = NULL; const char *pc_home = NULL; - const char *pc_shell = NULL; + char *pc_shell = NULL; + char *basedir = NULL; int pc_debug = 0; struct poptOption long_options[] = { POPT_AUTOHELP @@ -401,7 +410,14 @@ int main(int argc, const char **argv) if (pc_home) { user_ctx->home = talloc_strdup(user_ctx, pc_home); } else { - user_ctx->home = talloc_asprintf(user_ctx, "/home/%s", user_ctx->username); + ret = confdb_get_string(user_ctx->ctx->confdb, user_ctx, + CONFDB_DFL_SECTION, DFL_BASEDIR_ATTR, + DFL_BASEDIR_VAL, &basedir); + if (ret != EOK) { + ret = EXIT_FAILURE; + goto fini; + } + user_ctx->home = talloc_asprintf(user_ctx, "%s/%s", basedir, user_ctx->username); } if (!user_ctx->home) { ret = EXIT_FAILURE; @@ -409,7 +425,13 @@ int main(int argc, const char **argv) } if (!pc_shell) { - pc_shell = "/bin/bash"; + ret = confdb_get_string(user_ctx->ctx->confdb, user_ctx, + CONFDB_DFL_SECTION, DFL_SHELL_ATTR, + DFL_SHELL_VAL, &pc_shell); + if (ret != EOK) { + ret = EXIT_FAILURE; + goto fini; + } } user_ctx->shell = talloc_strdup(user_ctx, pc_shell); if (!user_ctx->shell) { |