return r;
while ((r = fgetpwent_sane(original, &pw)) > 0) {
-
i = ordered_hashmap_get(users, pw->pw_name);
if (i && i->todo_user)
return log_error_errno(SYNTHETIC_ERRNO(EEXIST),
*tmpfile = TAKE_PTR(gshadow);
*tmpfile_path = TAKE_PTR(gshadow_tmp);
}
- return 0;
-#else
- return 0;
#endif
+ return 0;
}
static int write_files(void) {
_cleanup_fclose_ FILE *passwd = NULL, *group = NULL, *shadow = NULL, *gshadow = NULL;
_cleanup_(unlink_and_freep) char *passwd_tmp = NULL, *group_tmp = NULL, *shadow_tmp = NULL, *gshadow_tmp = NULL;
- const char *passwd_path = NULL, *group_path = NULL, *shadow_path = NULL, *gshadow_path = NULL;
+ const char *passwd_path, *shadow_path, *group_path, *gshadow_path;
int r;
passwd_path = prefix_roota(arg_root, "/etc/passwd");
}
static int uid_is_ok(uid_t uid, const char *name, bool check_with_gid) {
- struct passwd *p;
- struct group *g;
- const char *n;
- Item *i;
/* Let's see if we already have assigned the UID a second time */
if (ordered_hashmap_get(todo_uids, UID_TO_PTR(uid)))
/* Try to avoid using uids that are already used by a group
* that doesn't have the same name as our new user. */
if (check_with_gid) {
+ Item *i;
+
i = ordered_hashmap_get(todo_gids, GID_TO_PTR(uid));
if (i && !streq(i->name, name))
return 0;
return 0;
if (check_with_gid) {
+ const char *n;
+
n = hashmap_get(database_by_gid, GID_TO_PTR(uid));
if (n && !streq(n, name))
return 0;
/* Let's also check via NSS, to avoid UID clashes over LDAP and such, just in case */
if (!arg_root) {
+ struct passwd *p;
+ struct group *g;
+
errno = 0;
p = getpwuid(uid);
if (p)
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);
+ log_info("Creating user %s (%s) with uid " UID_FMT " and gid " GID_FMT ".",
+ i->name, strna(i->description), i->uid, i->gid);
return 0;
}