summaryrefslogtreecommitdiffstats
path: root/src/providers
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2013-12-02 13:03:33 +0100
committerJakub Hrozek <jhrozek@redhat.com>2014-06-03 12:57:14 +0200
commitf9b90ac1cb9ea76f369459470097996cbbc7b343 (patch)
tree2313f42a0c25033a8307bf9b72b204a6f8cac5d7 /src/providers
parent4deef23b3a0e7da0c1ef4f45f792736c056c3123 (diff)
downloadsssd-f9b90ac1cb9ea76f369459470097996cbbc7b343.tar.gz
sssd-f9b90ac1cb9ea76f369459470097996cbbc7b343.tar.xz
sssd-f9b90ac1cb9ea76f369459470097996cbbc7b343.zip
NSS: Refactor expand_homedir_template
Function expand_homedir_template had lot of parameters. After adding new expand option, all function call should be rewritten, (usually argument NULL will be added) This patch wraps all necessary arguments to structure. Reviewed-by: Pavel Reichl <preichl@redhat.com>
Diffstat (limited to 'src/providers')
-rw-r--r--src/providers/ipa/ipa_s2n_exop.c17
-rw-r--r--src/providers/ipa/ipa_subdomains_id.c23
2 files changed, 24 insertions, 16 deletions
diff --git a/src/providers/ipa/ipa_s2n_exop.c b/src/providers/ipa/ipa_s2n_exop.c
index ac240be71..6bb3384b1 100644
--- a/src/providers/ipa/ipa_s2n_exop.c
+++ b/src/providers/ipa/ipa_s2n_exop.c
@@ -647,6 +647,7 @@ static void ipa_s2n_get_user_done(struct tevent_req *subreq)
struct resp_attrs *simple_attrs = NULL;
time_t now;
uint64_t timeout = 10*60*60; /* FIXME: find a better timeout ! */
+ struct sss_nss_homedir_ctx homedir_ctx;
const char *homedir = NULL;
struct sysdb_attrs *user_attrs = NULL;
struct sysdb_attrs *group_attrs = NULL;
@@ -737,13 +738,15 @@ static void ipa_s2n_get_user_done(struct tevent_req *subreq)
switch (attrs->response_type) {
case RESP_USER:
if (state->dom->subdomain_homedir) {
- homedir = expand_homedir_template(state,
- state->dom->subdomain_homedir,
- attrs->a.user.pw_name,
- attrs->a.user.pw_uid,
- NULL,
- state->dom->name,
- state->dom->flat_name);
+ ZERO_STRUCT(homedir_ctx);
+ homedir_ctx.username = attrs->a.user.pw_name;
+ homedir_ctx.uid = attrs->a.user.pw_uid;
+ homedir_ctx.domain = state->dom->name;
+ homedir_ctx.flatname = state->dom->flat_name;
+
+ homedir = expand_homedir_template(state,
+ state->dom->subdomain_homedir,
+ &homedir_ctx);
if (homedir == NULL) {
ret = ENOMEM;
goto done;
diff --git a/src/providers/ipa/ipa_subdomains_id.c b/src/providers/ipa/ipa_subdomains_id.c
index 2d5c3b3ee..96891b348 100644
--- a/src/providers/ipa/ipa_subdomains_id.c
+++ b/src/providers/ipa/ipa_subdomains_id.c
@@ -366,10 +366,10 @@ get_subdomain_homedir_of_user(TALLOC_CTX *mem_ctx, struct sss_domain_info *dom,
const char **_homedir)
{
errno_t ret;
- char *name;
- char *lc_name;
+ const char *name;
const char *homedir;
TALLOC_CTX *tmp_ctx;
+ struct sss_nss_homedir_ctx homedir_ctx;
tmp_ctx = talloc_new(mem_ctx);
if (tmp_ctx == NULL) {
@@ -377,22 +377,27 @@ get_subdomain_homedir_of_user(TALLOC_CTX *mem_ctx, struct sss_domain_info *dom,
goto done;
}
- ret = sss_parse_name(tmp_ctx, dom->names, fqname, NULL, &name);
+ ZERO_STRUCT(homedir_ctx);
+
+ homedir_ctx.uid = uid;
+ homedir_ctx.domain = dom->name;
+ homedir_ctx.flatname = dom->flat_name;
+ ret = sss_parse_name_const(tmp_ctx, dom->names, fqname,
+ NULL, &name);
if (ret != EOK) {
goto done;
}
/* To be compatible with the old winbind based user lookups and IPA
* clients the user name in the home directory path will be lower-case. */
- lc_name = sss_tc_utf8_str_tolower(tmp_ctx, name);
- if (lc_name == NULL) {
- ret =ENOMEM;
+ homedir_ctx.username = sss_tc_utf8_str_tolower(tmp_ctx, name);
+ if (homedir_ctx.username == NULL) {
+ ret = ENOMEM;
goto done;
}
- homedir = expand_homedir_template(tmp_ctx, dom->subdomain_homedir, lc_name,
- uid, NULL, dom->name, dom->flat_name);
-
+ homedir = expand_homedir_template(tmp_ctx, dom->subdomain_homedir,
+ &homedir_ctx);
if (homedir == NULL) {
DEBUG(SSSDBG_OP_FAILURE, "expand_homedir_template failed\n");
ret = ENOMEM;