summaryrefslogtreecommitdiffstats
path: root/server/db
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2009-03-10 10:53:16 -0400
committerSimo Sorce <ssorce@redhat.com>2009-03-10 14:52:59 -0400
commit704cc1c73e17d32fadcf6b57cc6f9246515efb49 (patch)
tree81ea7ceaceb4d66e16254c656ea2f82962ac3fe3 /server/db
parent603e64676bae6640588291289bd9cbc100ee35c6 (diff)
downloadsssd-704cc1c73e17d32fadcf6b57cc6f9246515efb49.tar.gz
sssd-704cc1c73e17d32fadcf6b57cc6f9246515efb49.tar.xz
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/db')
-rw-r--r--server/db/sysdb.h4
-rw-r--r--server/db/sysdb_ops.c20
2 files changed, 15 insertions, 9 deletions
diff --git a/server/db/sysdb.h b/server/db/sysdb.h
index 50aabac22..9e2cb39d2 100644
--- a/server/db/sysdb.h
+++ b/server/db/sysdb.h
@@ -90,7 +90,7 @@
#define SYSDB_CHECK_FILTER "(&(|("SYSDB_UC")("SYSDB_GC"))("SYSDB_NAME"=%s))"
#define SYSDB_PW_ATTRS {SYSDB_NAME, SYSDB_UIDNUM, \
- SYSDB_GIDNUM, SYSDB_FULLNAME, \
+ SYSDB_GIDNUM, SYSDB_GECOS, \
SYSDB_HOMEDIR, SYSDB_SHELL, \
SYSDB_LAST_UPDATE, \
"objectClass", \
@@ -274,7 +274,7 @@ int sysdb_set_user_attr(struct sysdb_req *sysreq,
int sysdb_add_user(struct sysdb_req *sysreq,
struct sss_domain_info *domain,
const char *name,
- uid_t uid, gid_t gid, const char *gecos,
+ uid_t uid, gid_t gid, const char *fullname,
const char *homedir, const char *shell,
sysdb_callback_t fn, void *pvt);
diff --git a/server/db/sysdb_ops.c b/server/db/sysdb_ops.c
index 0d20d7b32..54713dfed 100644
--- a/server/db/sysdb_ops.c
+++ b/server/db/sysdb_ops.c
@@ -864,7 +864,7 @@ struct user_add_ctx {
const char *name;
uid_t uid;
gid_t gid;
- const char *gecos;
+ const char *fullname;
const char *homedir;
const char *shell;
@@ -879,7 +879,7 @@ static int user_add_call(struct user_add_ctx *user_ctx);
int sysdb_add_user(struct sysdb_req *sysreq,
struct sss_domain_info *domain,
const char *name,
- uid_t uid, gid_t gid, const char *gecos,
+ uid_t uid, gid_t gid, const char *fullname,
const char *homedir, const char *shell,
sysdb_callback_t fn, void *pvt)
{
@@ -910,7 +910,7 @@ int sysdb_add_user(struct sysdb_req *sysreq,
user_ctx->name = name;
user_ctx->uid = uid;
user_ctx->gid = gid;
- user_ctx->gecos = gecos;
+ user_ctx->fullname = fullname;
user_ctx->homedir = homedir;
user_ctx->shell = shell;
@@ -1016,8 +1016,14 @@ static int user_add_call(struct user_add_ctx *user_ctx)
return EINVAL;
}
- if (user_ctx->gecos && *user_ctx->gecos) {
- ret = add_string(msg, flags, SYSDB_FULLNAME, user_ctx->gecos);
+ /* We set gecos to be the same as fullname on user creation,
+ * But we will not enforce coherency after that, it's up to
+ * admins to decide if they want to keep it in sync if they change
+ * one of the 2 */
+ if (user_ctx->fullname && *user_ctx->fullname) {
+ ret = add_string(msg, flags, SYSDB_FULLNAME, user_ctx->fullname);
+ if (ret != LDB_SUCCESS) return ENOMEM;
+ ret = add_string(msg, flags, SYSDB_GECOS, user_ctx->fullname);
if (ret != LDB_SUCCESS) return ENOMEM;
}
@@ -1473,9 +1479,9 @@ static int legacy_user_callback(struct ldb_request *req,
}
if (user_ctx->gecos && *user_ctx->gecos) {
- ret = add_string(msg, flags, SYSDB_FULLNAME, user_ctx->gecos);
+ ret = add_string(msg, flags, SYSDB_GECOS, user_ctx->gecos);
} else {
- ret = ldb_msg_add_empty(msg, SYSDB_FULLNAME,
+ ret = ldb_msg_add_empty(msg, SYSDB_GECOS,
LDB_FLAG_MOD_DELETE, NULL);
}
if (ret != LDB_SUCCESS) {