diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2011-12-12 16:35:53 +0100 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2011-12-16 14:46:16 -0500 |
commit | df5adbad4f5e938a000aee6527628ad63a0bd4c3 (patch) | |
tree | 4c09cdb26ce5d0f934a3a1b57bb7b6a4a01f5b21 /src | |
parent | 247a7056af42fc50bbc896cddb66a60154ca12e9 (diff) | |
download | sssd-df5adbad4f5e938a000aee6527628ad63a0bd4c3.tar.gz sssd-df5adbad4f5e938a000aee6527628ad63a0bd4c3.tar.bz2 sssd-df5adbad4f5e938a000aee6527628ad63a0bd4c3.zip |
Canonicalize username in PAM provider
Diffstat (limited to 'src')
-rw-r--r-- | src/responder/pam/pamsrv_cmd.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/responder/pam/pamsrv_cmd.c b/src/responder/pam/pamsrv_cmd.c index 5f77697f..7ae54ac2 100644 --- a/src/responder/pam/pamsrv_cmd.c +++ b/src/responder/pam/pamsrv_cmd.c @@ -93,6 +93,26 @@ static int extract_uint32_t(uint32_t *var, size_t size, uint8_t *body, return EOK; } +static int pd_set_primary_name(const struct ldb_message *msg,struct pam_data *pd) +{ + const char *name; + + name = ldb_msg_find_attr_as_string(msg, SYSDB_NAME, NULL); + if (!name) { + DEBUG(SSSDBG_CRIT_FAILURE, ("A user with no name?\n")); + return EIO; + } + + if (strcmp(pd->user, name)) { + DEBUG(SSSDBG_TRACE_FUNC, ("User's primary name is %s\n", name)); + talloc_free(pd->user); + pd->user = talloc_strdup(pd, name); + if (!pd->user) return ENOMEM; + } + + return EOK; +} + static int pam_parse_in_data_v2(struct sss_names_ctx *snctx, struct pam_data *pd, uint8_t *body, size_t blen) @@ -890,6 +910,13 @@ static int pam_check_user_search(struct pam_auth_req *preq) DEBUG(6, ("Returning info for user [%s@%s]\n", name, dom->name)); + /* We might have searched by alias. Pass on the primary name */ + ret = pd_set_primary_name(preq->res->msgs[0], preq->pd); + if (ret != EOK) { + DEBUG(SSSDBG_CRIT_FAILURE, ("Could not canonicalize username\n")); + return ret; + } + return EOK; } |