summaryrefslogtreecommitdiff
path: root/src/responder/nss
diff options
context:
space:
mode:
Diffstat (limited to 'src/responder/nss')
-rw-r--r--src/responder/nss/nsssrv.c5
-rw-r--r--src/responder/nss/nsssrv.h1
-rw-r--r--src/responder/nss/nsssrv_cmd.c23
3 files changed, 27 insertions, 2 deletions
diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c
index 1a0dcf43..c8ee444a 100644
--- a/src/responder/nss/nsssrv.c
+++ b/src/responder/nss/nsssrv.c
@@ -178,6 +178,11 @@ static int nss_get_config(struct nss_ctx *nctx,
&nctx->override_homedir);
if (ret != EOK) goto done;
+ ret = confdb_get_string(cdb, nctx, CONFDB_NSS_CONF_ENTRY,
+ CONFDB_NSS_FALLBACK_HOMEDIR, NULL,
+ &nctx->fallback_homedir);
+ if (ret != EOK) goto done;
+
ret = confdb_get_string_as_list(cdb, nctx, CONFDB_NSS_CONF_ENTRY,
CONFDB_NSS_ALLOWED_SHELL,
&nctx->allowed_shells);
diff --git a/src/responder/nss/nsssrv.h b/src/responder/nss/nsssrv.h
index 2871c2bf..5b5ae50b 100644
--- a/src/responder/nss/nsssrv.h
+++ b/src/responder/nss/nsssrv.h
@@ -61,6 +61,7 @@ struct nss_ctx {
char *pwfield;
char *override_homedir;
+ char *fallback_homedir;
char **allowed_shells;
char **vetoed_shells;
char **etc_shells;
diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c
index 508db556..d448fa85 100644
--- a/src/responder/nss/nsssrv_cmd.c
+++ b/src/responder/nss/nsssrv_cmd.c
@@ -122,6 +122,11 @@ static const char *get_homedir_override(TALLOC_CTX *mem_ctx,
const char *name,
uint32_t uid)
{
+ const char *homedir;
+
+ /* Check whether we are unconditionally overriding the server
+ * for home directory locations.
+ */
if (dom->override_homedir) {
return expand_homedir_template(mem_ctx, dom->override_homedir,
name, uid, dom->name);
@@ -130,8 +135,22 @@ static const char *get_homedir_override(TALLOC_CTX *mem_ctx,
name, uid, dom->name);
}
- return talloc_strdup(mem_ctx,
- ldb_msg_find_attr_as_string(msg, SYSDB_HOMEDIR, NULL));
+ homedir = ldb_msg_find_attr_as_string(msg, SYSDB_HOMEDIR, NULL);
+ if (!homedir || *homedir == '\0') {
+ /* In the case of a NULL or empty homedir, check to see if
+ * we have a fallback homedir to use.
+ */
+ if (dom->fallback_homedir) {
+ return expand_homedir_template(mem_ctx, dom->fallback_homedir,
+ name, uid, dom->name);
+ } else if (nctx->fallback_homedir) {
+ return expand_homedir_template(mem_ctx, nctx->fallback_homedir,
+ name, uid, dom->name);
+ }
+ }
+
+ /* Return the value we got from the provider */
+ return talloc_strdup(mem_ctx, homedir);
}
static const char *get_shell_override(TALLOC_CTX *mem_ctx,