summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/db/sysdb.h2
-rw-r--r--src/man/include/override_homedir.xml4
-rw-r--r--src/responder/nss/nsssrv_cmd.c3
-rw-r--r--src/util/sss_nss.c11
-rw-r--r--src/util/sss_nss.h1
5 files changed, 21 insertions, 0 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 2c5e8316f..03aac1524 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -179,7 +179,9 @@
SYSDB_DEFAULT_ATTRS, \
SYSDB_PRIMARY_GROUP_GIDNUM, \
SYSDB_SID_STR, \
+ SYSDB_UPN, \
NULL}
+
#define SYSDB_GRSRC_ATTRS {SYSDB_NAME, SYSDB_GIDNUM, \
SYSDB_MEMBERUID, \
SYSDB_GHOST, \
diff --git a/src/man/include/override_homedir.xml b/src/man/include/override_homedir.xml
index 552d7eb9d..61de52e00 100644
--- a/src/man/include/override_homedir.xml
+++ b/src/man/include/override_homedir.xml
@@ -24,6 +24,10 @@
<listitem><para>fully qualified user name (user@domain)</para></listitem>
</varlistentry>
<varlistentry>
+ <term>%P</term>
+ <listitem><para>UPN - User Principal Name (name@REALM)</para></listitem>
+ </varlistentry>
+ <varlistentry>
<term>%o</term>
<listitem><para>
The original home directory retrieved
diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c
index ba752c3ff..256c26b17 100644
--- a/src/responder/nss/nsssrv_cmd.c
+++ b/src/responder/nss/nsssrv_cmd.c
@@ -306,6 +306,7 @@ static int fill_pwent(struct sss_packet *packet,
{
struct ldb_message *msg;
uint8_t *body;
+ const char *upn;
const char *tmpstr;
const char *orig_name;
struct sized_string name;
@@ -337,6 +338,7 @@ static int fill_pwent(struct sss_packet *packet,
msg = msgs[i];
+ upn = ldb_msg_find_attr_as_string(msg, SYSDB_UPN, NULL);
orig_name = ldb_msg_find_attr_as_string(msg, SYSDB_NAME, NULL);
uid = ldb_msg_find_attr_as_uint64(msg, SYSDB_UIDNUM, 0);
gid = get_gid_override(msg, dom);
@@ -395,6 +397,7 @@ static int fill_pwent(struct sss_packet *packet,
homedir_ctx.username = name.str;
homedir_ctx.uid = uid;
homedir_ctx.domain = dom->name;
+ homedir_ctx.upn = upn;
tmpstr = get_homedir_override(tmp_ctx, msg, nctx, dom, &homedir_ctx);
if (!tmpstr) {
diff --git a/src/util/sss_nss.c b/src/util/sss_nss.c
index 8cc1416d7..208b57842 100644
--- a/src/util/sss_nss.c
+++ b/src/util/sss_nss.c
@@ -147,6 +147,17 @@ char *expand_homedir_template(TALLOC_CTX *mem_ctx, const char *template,
homedir_ctx->config_homedir_substr);
break;
+ case 'P':
+ if (homedir_ctx->upn == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "Cannot expand user principal name template "
+ "string is empty.\n");
+ goto done;
+ }
+ result = talloc_asprintf_append(result, "%s%s", p,
+ homedir_ctx->upn);
+ break;
+
case '%':
result = talloc_asprintf_append(result, "%s%%", p);
break;
diff --git a/src/util/sss_nss.h b/src/util/sss_nss.h
index 19bf26589..30359fc7c 100644
--- a/src/util/sss_nss.h
+++ b/src/util/sss_nss.h
@@ -32,6 +32,7 @@ struct sss_nss_homedir_ctx {
const char *domain;
const char *flatname;
const char *config_homedir_substr;
+ const char *upn;
};
char *expand_homedir_template(TALLOC_CTX *mem_ctx, const char *template,