summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/db/sysdb.h4
-rw-r--r--server/db/sysdb_ops.c20
-rw-r--r--server/responder/nss/nsssrv_cmd.c13
-rw-r--r--server/tools/sss_usermod.c2
4 files changed, 24 insertions, 15 deletions
diff --git a/server/db/sysdb.h b/server/db/sysdb.h
index 50aabac2..9e2cb39d 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 0d20d7b3..54713dfe 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) {
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;
diff --git a/server/tools/sss_usermod.c b/server/tools/sss_usermod.c
index 63779dd1..6f1d4ce6 100644
--- a/server/tools/sss_usermod.c
+++ b/server/tools/sss_usermod.c
@@ -292,7 +292,7 @@ int main(int argc, const char **argv)
if(pc_gecos) {
ret = sysdb_attrs_add_string(user_ctx->attrs,
- SYSDB_FULLNAME,
+ SYSDB_GECOS,
pc_gecos);
VAR_CHECK(ret, EOK, "Could not add attribute to changeset\n");
}