summaryrefslogtreecommitdiff
path: root/src/responder/nss
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2012-05-09 11:07:31 -0400
committerStephen Gallagher <sgallagh@redhat.com>2012-05-09 19:23:09 -0400
commitf6dbb235373b122ae15643ef5dbbe821ee1307d9 (patch)
tree4372f8a2e91c05a7437a278273d4f392ed29737f /src/responder/nss
parent163a17f00c42f2405d8fb0a2af3bc9d8b7309260 (diff)
downloadsssd-f6dbb235373b122ae15643ef5dbbe821ee1307d9.tar.gz
sssd-f6dbb235373b122ae15643ef5dbbe821ee1307d9.tar.bz2
sssd-f6dbb235373b122ae15643ef5dbbe821ee1307d9.zip
NSS: Add fallback_homedir option
This option is similar to override_homedir, except that it will take effect only for users that do not have an explicit home directory specified in LDAP. https://fedorahosted.org/sssd/ticket/1250
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,