summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2012-10-16 18:07:42 -0400
committerSimo Sorce <simo@redhat.com>2013-01-04 14:40:52 -0500
commitc3b18225c79a1fd3c5e92aef97759b04daa5a5d6 (patch)
treefad7103d9d1ebc632140263c5156a543053a5226
parent2d468a06e14672a3012f2cf55720903000061c7d (diff)
downloadsssd-c3b18225c79a1fd3c5e92aef97759b04daa5a5d6.tar.gz
sssd-c3b18225c79a1fd3c5e92aef97759b04daa5a5d6.tar.xz
sssd-c3b18225c79a1fd3c5e92aef97759b04daa5a5d6.zip
Add alias attribute to nss responder structures
Add plumbing to allow to push down an alias attribute to be used by the memory cache.
-rw-r--r--src/confdb/confdb.h2
-rw-r--r--src/responder/nss/nsssrv_cmd.c32
2 files changed, 32 insertions, 2 deletions
diff --git a/src/confdb/confdb.h b/src/confdb/confdb.h
index eb16d01e..7739af8e 100644
--- a/src/confdb/confdb.h
+++ b/src/confdb/confdb.h
@@ -216,6 +216,8 @@ struct sss_domain_info {
const char *override_shell;
const char *default_shell;
+ const char *alias_attr;
+
uint32_t user_timeout;
uint32_t group_timeout;
uint32_t netgroup_timeout;
diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c
index 387408a7..f5e8f783 100644
--- a/src/responder/nss/nsssrv_cmd.c
+++ b/src/responder/nss/nsssrv_cmd.c
@@ -291,6 +291,8 @@ static int fill_pwent(struct sss_packet *packet,
struct sized_string shell;
struct sized_string pwfield;
struct sized_string fullname;
+ struct sized_string alias;
+ struct sized_string *aliasptr;
uint32_t uid;
uint32_t gid;
size_t rsize, rp, blen;
@@ -355,6 +357,18 @@ static int fill_pwent(struct sss_packet *packet,
}
to_sized_string(&name, tmpstr);
+ if (dom->alias_attr) {
+ tmpstr = ldb_msg_find_attr_as_string(msg, dom->alias_attr, NULL);
+ if (!tmpstr) {
+ aliasptr = NULL;
+ } else {
+ to_sized_string(&alias, tmpstr);
+ aliasptr = &alias;
+ }
+ } else {
+ aliasptr = NULL;
+ }
+
tmpstr = ldb_msg_find_attr_as_string(msg, SYSDB_GECOS, NULL);
if (!tmpstr) {
to_sized_string(&gecos, "");
@@ -433,7 +447,7 @@ static int fill_pwent(struct sss_packet *packet,
if (pw_mmap_cache && nctx->pwd_mc_ctx) {
ret = sss_mmap_cache_pw_store(&nctx->pwd_mc_ctx,
- &fullname, NULL, &pwfield,
+ &fullname, aliasptr, &pwfield,
uid, gid,
&gecos, &homedir, &shell);
if (ret != EOK && ret != ENOMEM) {
@@ -2013,6 +2027,8 @@ static int fill_grent(struct sss_packet *packet,
struct sized_string name;
struct sized_string pwfield;
struct sized_string fullname;
+ struct sized_string alias;
+ struct sized_string *aliasptr;
size_t delim;
size_t dom_len;
int i = 0;
@@ -2090,6 +2106,18 @@ static int fill_grent(struct sss_packet *packet,
}
to_sized_string(&name, tmpstr);
+ if (dom->alias_attr) {
+ tmpstr = ldb_msg_find_attr_as_string(msg, dom->alias_attr, NULL);
+ if (!tmpstr) {
+ aliasptr = NULL;
+ } else {
+ to_sized_string(&alias, tmpstr);
+ aliasptr = &alias;
+ }
+ } else {
+ aliasptr = NULL;
+ }
+
/* fill in gid and name and set pointer for number of members */
rsize = STRS_ROFFSET + name.len + pwfield.len; /* name\0x\0 */
if (add_domain) rsize += delim + dom_len;
@@ -2186,7 +2214,7 @@ static int fill_grent(struct sss_packet *packet,
* where body used to be, not where it is */
to_sized_string(&fullname, (const char *)&body[rzero+STRS_ROFFSET]);
ret = sss_mmap_cache_gr_store(&nctx->grp_mc_ctx,
- &fullname, NULL, &pwfield,
+ &fullname, aliasptr, &pwfield,
gid, memnum,
(char *)&body[rzero] + STRS_ROFFSET +
fullname.len + pwfield.len,