diff options
author | Sumit Bose <sbose@redhat.com> | 2012-10-24 09:33:23 +0200 |
---|---|---|
committer | Sumit Bose <sbose@redhat.com> | 2012-10-26 10:32:05 +0200 |
commit | 29c0fdd1838a4b9892146f7019d12811c1d0d59b (patch) | |
tree | bc162c26b9e640c461ceecf9cf4c9c99b2546626 /src/providers/krb5/krb5_utils.c | |
parent | d3dca30d3a6feba062d0299718d1a9fcdc8b9d17 (diff) | |
download | sssd-29c0fdd1838a4b9892146f7019d12811c1d0d59b.tar.gz sssd-29c0fdd1838a4b9892146f7019d12811c1d0d59b.tar.bz2 sssd-29c0fdd1838a4b9892146f7019d12811c1d0d59b.zip |
Add new call find_or_guess_upn()
With the current approach the upn was either a pointer to a const string
in a ldb_message or a string created with the help of talloc. This new
function always makes it a talloc'ed value.
Additionally krb5_get_simple_upn() is enhanced to handle sub-domains as
well.
Diffstat (limited to 'src/providers/krb5/krb5_utils.c')
-rw-r--r-- | src/providers/krb5/krb5_utils.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/providers/krb5/krb5_utils.c b/src/providers/krb5/krb5_utils.c index 7a68b0f4..98376169 100644 --- a/src/providers/krb5/krb5_utils.c +++ b/src/providers/krb5/krb5_utils.c @@ -30,6 +30,33 @@ #include "src/util/find_uid.h" #include "util/util.h" +errno_t find_or_guess_upn(TALLOC_CTX *mem_ctx, struct ldb_message *msg, + struct krb5_ctx *krb5_ctx, + const char *domain_name, const char *user, + const char *user_dom, char **_upn) +{ + const char *upn; + int ret; + + upn = ldb_msg_find_attr_as_string(msg, SYSDB_UPN, NULL); + if (upn == NULL) { + ret = krb5_get_simple_upn(mem_ctx, krb5_ctx, domain_name, user, + user_dom, _upn); + if (ret != EOK) { + DEBUG(SSSDBG_OP_FAILURE, ("krb5_get_simple_upn failed.\n")); + return ret; + } + } else { + *_upn = talloc_strdup(mem_ctx, upn); + if (*_upn == NULL) { + DEBUG(SSSDBG_OP_FAILURE, ("talloc_strdup failed.\n")); + return ENOMEM; + } + } + + return EOK; +} + char *expand_ccname_template(TALLOC_CTX *mem_ctx, struct krb5child_req *kr, const char *template, bool file_mode, bool case_sensitive, bool *private_path) |