summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2013-02-07 13:04:24 -0500
committerJakub Hrozek <jhrozek@redhat.com>2013-02-10 19:36:12 +0100
commit2cbb879c517f2c756a2eb3962527979bac01ddab (patch)
tree882adf430f134d30d4c34a8368a47e19f229f3f3 /src
parentfa551077410019fb34460dc730950e93b62b2963 (diff)
downloadsssd-2cbb879c517f2c756a2eb3962527979bac01ddab.tar.gz
sssd-2cbb879c517f2c756a2eb3962527979bac01ddab.tar.xz
sssd-2cbb879c517f2c756a2eb3962527979bac01ddab.zip
NSS: Add original homedir to home directory template options
https://fedorahosted.org/sssd/ticket/1805
Diffstat (limited to 'src')
-rw-r--r--src/man/sssd.conf.5.xml7
-rw-r--r--src/providers/ipa/ipa_s2n_exop.c1
-rw-r--r--src/responder/nss/nsssrv_cmd.c11
-rw-r--r--src/responder/pac/pacsrv_utils.c2
-rw-r--r--src/util/sss_nss.c14
-rw-r--r--src/util/sss_nss.h2
6 files changed, 29 insertions, 8 deletions
diff --git a/src/man/sssd.conf.5.xml b/src/man/sssd.conf.5.xml
index 7f10349e4..373a504d8 100644
--- a/src/man/sssd.conf.5.xml
+++ b/src/man/sssd.conf.5.xml
@@ -468,6 +468,13 @@
<listitem><para>fully qualified user name (user@domain)</para></listitem>
</varlistentry>
<varlistentry>
+ <term>%o</term>
+ <listitem><para>
+ The original home directory retrieved
+ from the identity provider.
+ </para></listitem>
+ </varlistentry>
+ <varlistentry>
<term>%%</term>
<listitem><para>a literal '%'</para>
</listitem>
diff --git a/src/providers/ipa/ipa_s2n_exop.c b/src/providers/ipa/ipa_s2n_exop.c
index 0b4842ccc..be088664e 100644
--- a/src/providers/ipa/ipa_s2n_exop.c
+++ b/src/providers/ipa/ipa_s2n_exop.c
@@ -629,6 +629,7 @@ static void ipa_s2n_get_user_done(struct tevent_req *subreq)
state->dom->subdomain_homedir,
attrs->a.user.pw_name,
attrs->a.user.pw_uid,
+ NULL,
state->dom->name);
if (homedir == NULL) {
ret = ENOMEM;
diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c
index b2dae4a3a..5ac1bacc0 100644
--- a/src/responder/nss/nsssrv_cmd.c
+++ b/src/responder/nss/nsssrv_cmd.c
@@ -176,28 +176,29 @@ static const char *get_homedir_override(TALLOC_CTX *mem_ctx,
{
const char *homedir;
+ homedir = ldb_msg_find_attr_as_string(msg, SYSDB_HOMEDIR, NULL);
+
/* 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);
+ name, uid, homedir, dom->name);
} else if (nctx->override_homedir) {
return expand_homedir_template(mem_ctx, nctx->override_homedir,
- name, uid, dom->name);
+ name, uid, homedir, dom->name);
}
- 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);
+ name, uid, homedir, dom->name);
} else if (nctx->fallback_homedir) {
return expand_homedir_template(mem_ctx, nctx->fallback_homedir,
- name, uid, dom->name);
+ name, uid, homedir, dom->name);
}
}
diff --git a/src/responder/pac/pacsrv_utils.c b/src/responder/pac/pacsrv_utils.c
index 202f7ba32..f5649724a 100644
--- a/src/responder/pac/pacsrv_utils.c
+++ b/src/responder/pac/pacsrv_utils.c
@@ -808,7 +808,7 @@ errno_t get_pwd_from_pac(TALLOC_CTX *mem_ctx,
if (dom->subdomain_homedir) {
pwd->pw_dir = expand_homedir_template(pwd, dom->subdomain_homedir,
- lname, pwd->pw_uid,
+ lname, pwd->pw_uid, NULL,
dom->name);
if (pwd->pw_dir == NULL) {
ret = ENOMEM;
diff --git a/src/util/sss_nss.c b/src/util/sss_nss.c
index ceccda38f..ac36a9ba6 100644
--- a/src/util/sss_nss.c
+++ b/src/util/sss_nss.c
@@ -24,7 +24,7 @@
char *expand_homedir_template(TALLOC_CTX *mem_ctx, const char *template,
const char *username, uint32_t uid,
- const char *domain)
+ const char *original, const char *domain)
{
char *copy;
char *p;
@@ -32,6 +32,7 @@ char *expand_homedir_template(TALLOC_CTX *mem_ctx, const char *template,
char *result = NULL;
char *res = NULL;
TALLOC_CTX *tmp_ctx = NULL;
+ const char *orig = NULL;
if (template == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, ("Missing template.\n"));
@@ -104,6 +105,17 @@ char *expand_homedir_template(TALLOC_CTX *mem_ctx, const char *template,
result = talloc_asprintf_append(result, "%s%s@%s", p,
username, domain);
break;
+ case 'o':
+ if (original == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ ("Original home directory for %s is not available, "
+ "using empty string\n", username));
+ orig = "";
+ } else {
+ orig = original;
+ }
+ result = talloc_asprintf_append(result, "%s%s", p, orig);
+ break;
case '%':
result = talloc_asprintf_append(result, "%s%%", p);
diff --git a/src/util/sss_nss.h b/src/util/sss_nss.h
index 55e2b7f6b..0520035fd 100644
--- a/src/util/sss_nss.h
+++ b/src/util/sss_nss.h
@@ -27,5 +27,5 @@
char *expand_homedir_template(TALLOC_CTX *mem_ctx, const char *template,
const char *username, uint32_t uid,
- const char *domain);
+ const char *original, const char *domain);
#endif