summaryrefslogtreecommitdiff
path: root/src/util
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/util
parentfa551077410019fb34460dc730950e93b62b2963 (diff)
downloadsssd-2cbb879c517f2c756a2eb3962527979bac01ddab.tar.gz
sssd-2cbb879c517f2c756a2eb3962527979bac01ddab.tar.bz2
sssd-2cbb879c517f2c756a2eb3962527979bac01ddab.zip
NSS: Add original homedir to home directory template options
https://fedorahosted.org/sssd/ticket/1805
Diffstat (limited to 'src/util')
-rw-r--r--src/util/sss_nss.c14
-rw-r--r--src/util/sss_nss.h2
2 files changed, 14 insertions, 2 deletions
diff --git a/src/util/sss_nss.c b/src/util/sss_nss.c
index ceccda38..ac36a9ba 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 55e2b7f6..0520035f 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