diff options
author | Simo Sorce <ssorce@redhat.com> | 2009-03-10 10:53:16 -0400 |
---|---|---|
committer | Simo Sorce <ssorce@redhat.com> | 2009-03-10 14:52:59 -0400 |
commit | 704cc1c73e17d32fadcf6b57cc6f9246515efb49 (patch) | |
tree | 81ea7ceaceb4d66e16254c656ea2f82962ac3fe3 /server/responder | |
parent | 603e64676bae6640588291289bd9cbc100ee35c6 (diff) | |
download | sssd-704cc1c73e17d32fadcf6b57cc6f9246515efb49.tar.gz sssd-704cc1c73e17d32fadcf6b57cc6f9246515efb49.tar.bz2 sssd-704cc1c73e17d32fadcf6b57cc6f9246515efb49.zip |
Fix returning user with missing optional attributes.
Gecos, homedir and shell are optional, fix the responder not to refuse to return
the user completely if they are missing, replace an empty homedir with "/".
Also fix fullname vs gecos, and always return gecos for NSS data.
On user creation set gecos to the same value as the user Full Name, to help
populate the gecos field with data that makes sense.
Diffstat (limited to 'server/responder')
-rw-r--r-- | server/responder/nss/nsssrv_cmd.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/server/responder/nss/nsssrv_cmd.c b/server/responder/nss/nsssrv_cmd.c index f55a177b..4117f977 100644 --- a/server/responder/nss/nsssrv_cmd.c +++ b/server/responder/nss/nsssrv_cmd.c @@ -186,7 +186,7 @@ static int fill_pwent(struct sss_packet *packet, struct ldb_message *msg; uint8_t *body; const char *name; - const char *fullname; + const char *gecos; const char *homedir; const char *shell; uint32_t uid; @@ -207,20 +207,23 @@ static int fill_pwent(struct sss_packet *packet, msg = msgs[i]; name = ldb_msg_find_attr_as_string(msg, SYSDB_NAME, NULL); - fullname = ldb_msg_find_attr_as_string(msg, SYSDB_FULLNAME, NULL); + gecos = ldb_msg_find_attr_as_string(msg, SYSDB_GECOS, NULL); homedir = ldb_msg_find_attr_as_string(msg, SYSDB_HOMEDIR, NULL); shell = ldb_msg_find_attr_as_string(msg, SYSDB_SHELL, NULL); uid = ldb_msg_find_attr_as_uint64(msg, SYSDB_UIDNUM, 0); gid = ldb_msg_find_attr_as_uint64(msg, SYSDB_GIDNUM, 0); - if (!name || !fullname || !homedir || !shell || !uid || !gid) { + if (!name || !uid || !gid) { DEBUG(1, ("Incomplete user object for %s[%llu]! Skipping\n", name?name:"<NULL>", (unsigned long long int)uid)); continue; } + if (!gecos) gecos = ""; + if (!homedir) homedir = "/"; + if (!shell) shell = ""; s1 = strlen(name) + 1; - s2 = strlen(fullname) + 1; + s2 = strlen(gecos) + 1; s3 = strlen(homedir) + 1; s4 = strlen(shell) + 1; rsize = 2*sizeof(uint32_t) +s1 + 2 + s2 + s3 +s4; @@ -245,7 +248,7 @@ static int fill_pwent(struct sss_packet *packet, } memcpy(&body[rp], "x", 2); rp += 2; - memcpy(&body[rp], fullname, s2); + memcpy(&body[rp], gecos, s2); rp += s2; memcpy(&body[rp], homedir, s3); rp += s3; |