summaryrefslogtreecommitdiffstats
path: root/src/sysusers/sysusers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sysusers/sysusers.c')
-rw-r--r--src/sysusers/sysusers.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
index f0ec5085fc..4f78e3d065 100644
--- a/src/sysusers/sysusers.c
+++ b/src/sysusers/sysusers.c
@@ -1043,13 +1043,15 @@ static int add_user(Item *i) {
i->uid = search_uid;
}
- r = ordered_hashmap_ensure_allocated(&todo_uids, NULL);
- if (r < 0)
+ r = ordered_hashmap_ensure_put(&todo_uids, NULL, UID_TO_PTR(i->uid), i);
+ if (r == -EEXIST)
+ return log_error_errno(r, "Requested user %s with uid " UID_FMT " and gid" GID_FMT " to be created is duplicated "
+ "or conflicts with another user.", i->name, i->uid, i->gid);
+ if (r == -ENOMEM)
return log_oom();
-
- r = ordered_hashmap_put(todo_uids, UID_TO_PTR(i->uid), i);
if (r < 0)
- return log_oom();
+ return log_error_errno(r, "Failed to store user %s with uid " UID_FMT " and gid " GID_FMT " to be created: %m",
+ i->name, i->uid, i->gid);
i->todo_user = true;
log_info("Creating user %s (%s) with uid " UID_FMT " and gid " GID_FMT ".", i->name, strna(i->description), i->uid, i->gid);
@@ -1212,13 +1214,13 @@ static int add_group(Item *i) {
i->gid = search_uid;
}
- r = ordered_hashmap_ensure_allocated(&todo_gids, NULL);
- if (r < 0)
+ r = ordered_hashmap_ensure_put(&todo_gids, NULL, GID_TO_PTR(i->gid), i);
+ if (r == -EEXIST)
+ return log_error_errno(r, "Requested group %s with gid "GID_FMT " to be created is duplicated or conflicts with another user.", i->name, i->gid);
+ if (r == -ENOMEM)
return log_oom();
-
- r = ordered_hashmap_put(todo_gids, GID_TO_PTR(i->gid), i);
if (r < 0)
- return log_oom();
+ return log_error_errno(r, "Failed to store group %s with gid " GID_FMT " to be created: %m", i->name, i->gid);
i->todo_group = true;
log_info("Creating group %s with gid " GID_FMT ".", i->name, i->gid);