summaryrefslogtreecommitdiff
path: root/src/providers
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2010-10-28 14:10:43 +0200
committerStephen Gallagher <sgallagh@redhat.com>2010-11-04 15:04:20 -0400
commit0bbe2065770968c70fd305da4f6eda1a360a3f1b (patch)
tree0e71759eac0c3153fe4195ec5fd23d380d79f036 /src/providers
parent1e29e68388c2e9c5da9cb0afe997bc1b4e6933be (diff)
downloadsssd-0bbe2065770968c70fd305da4f6eda1a360a3f1b.tar.gz
sssd-0bbe2065770968c70fd305da4f6eda1a360a3f1b.tar.bz2
sssd-0bbe2065770968c70fd305da4f6eda1a360a3f1b.zip
Add krb5_get_simple_upn()
Diffstat (limited to 'src/providers')
-rw-r--r--src/providers/krb5/krb5_auth.c9
-rw-r--r--src/providers/krb5/krb5_common.c25
-rw-r--r--src/providers/krb5/krb5_common.h2
3 files changed, 30 insertions, 6 deletions
diff --git a/src/providers/krb5/krb5_auth.c b/src/providers/krb5/krb5_auth.c
index 626df2ff..08a97ef1 100644
--- a/src/providers/krb5/krb5_auth.c
+++ b/src/providers/krb5/krb5_auth.c
@@ -716,14 +716,11 @@ struct tevent_req *krb5_auth_send(TALLOC_CTX *mem_ctx,
case 1:
kr->upn = ldb_msg_find_attr_as_string(res->msgs[0], SYSDB_UPN, NULL);
if (kr->upn == NULL) {
- /* NOTE: this is a hack, works only in some environments */
- kr->upn = talloc_asprintf(kr, "%s@%s", pd->user, realm);
- if (kr->upn == NULL) {
- DEBUG(1, ("failed to build simple upn.\n"));
- ret = ENOMEM;
+ ret = krb5_get_simple_upn(state, krb5_ctx, pd->user, &kr->upn);
+ if (ret != EOK) {
+ DEBUG(1, ("krb5_get_simple_upn failed.\n"));
goto done;
}
- DEBUG(9, ("Using simple UPN [%s].\n", kr->upn));
}
kr->homedir = ldb_msg_find_attr_as_string(res->msgs[0], SYSDB_HOMEDIR,
diff --git a/src/providers/krb5/krb5_common.c b/src/providers/krb5/krb5_common.c
index 81ad4e9d..4d577257 100644
--- a/src/providers/krb5/krb5_common.c
+++ b/src/providers/krb5/krb5_common.c
@@ -653,3 +653,28 @@ errno_t krb5_install_sigterm_handler(struct tevent_context *ev,
return EOK;
}
+
+errno_t krb5_get_simple_upn(TALLOC_CTX *mem_ctx, struct krb5_ctx *krb5_ctx,
+ const char *username, const char **_upn)
+{
+ const char *realm;
+ char *upn;
+
+ realm = dp_opt_get_cstring(krb5_ctx->opts, KRB5_REALM);
+ if (realm == NULL) {
+ DEBUG(1, ("Missing Kerberos realm.\n"));
+ return ENOENT;
+ }
+
+ /* NOTE: this is a hack, works only in some environments */
+ upn = talloc_asprintf(mem_ctx, "%s@%s", username, realm);
+ if (upn == NULL) {
+ DEBUG(1, ("talloc_asprintf failed.\n"));
+ return ENOMEM;
+ }
+
+ DEBUG(9, ("Using simple UPN [%s].\n", upn));
+
+ *_upn = upn;
+ return EOK;
+}
diff --git a/src/providers/krb5/krb5_common.h b/src/providers/krb5/krb5_common.h
index a8ebcf5c..139ce400 100644
--- a/src/providers/krb5/krb5_common.h
+++ b/src/providers/krb5/krb5_common.h
@@ -145,4 +145,6 @@ errno_t write_krb5info_file(const char *realm, const char *kdc,
errno_t remove_krb5_info_files(TALLOC_CTX *mem_ctx, const char *realm);
+errno_t krb5_get_simple_upn(TALLOC_CTX *mem_ctx, struct krb5_ctx *krb5_ctx,
+ const char *username, const char **_upn);
#endif /* __KRB5_COMMON_H__ */