tree-wide: go via user_record_gid() accessor for UserRecord's .gid field
Sometimes we went for the field directly, where we really should go via the accessor. Fix it.
This commit is contained in:
+1
-1
@@ -2664,7 +2664,7 @@ static int acquire_group_list(char ***ret) {
|
||||
if (r < 0 && r != -ESRCH)
|
||||
return log_debug_errno(r, "Failed to check if matching user exists for group '%s': %m", gr->group_name);
|
||||
|
||||
if (r >= 0 && ur->gid == gr->gid)
|
||||
if (r >= 0 && user_record_gid(ur) == gr->gid)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1062,7 +1062,7 @@ static int copy_skel(UserRecord *h, int root_fd, const char *skel) {
|
||||
assert(h);
|
||||
assert(root_fd >= 0);
|
||||
|
||||
r = copy_tree_at(AT_FDCWD, skel, root_fd, ".", h->uid, h->gid, COPY_MERGE|COPY_REPLACE, NULL, NULL);
|
||||
r = copy_tree_at(AT_FDCWD, skel, root_fd, ".", h->uid, user_record_gid(h), COPY_MERGE|COPY_REPLACE, NULL, NULL);
|
||||
if (r == -ENOENT) {
|
||||
log_info("Skeleton directory %s missing, ignoring.", skel);
|
||||
return 0;
|
||||
|
||||
@@ -93,7 +93,7 @@ static int convert_user(
|
||||
|
||||
assert(u);
|
||||
assert(g);
|
||||
assert(u->gid == g->gid);
|
||||
assert(user_record_gid(u) == g->gid);
|
||||
|
||||
r = check_etc_passwd_collisions(directory, u->user_name, UID_INVALID);
|
||||
if (r < 0)
|
||||
@@ -250,7 +250,7 @@ int bind_user_prepare(
|
||||
if (u->uid >= uid_shift && u->uid < uid_shift + uid_range)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "UID of user '%s' to map is already in container UID range, refusing.", u->user_name);
|
||||
|
||||
r = groupdb_by_gid(u->gid, /* match= */ NULL, USERDB_DONT_SYNTHESIZE_INTRINSIC|USERDB_DONT_SYNTHESIZE_FOREIGN, &g);
|
||||
r = groupdb_by_gid(user_record_gid(u), /* match= */ NULL, USERDB_DONT_SYNTHESIZE_INTRINSIC|USERDB_DONT_SYNTHESIZE_FOREIGN, &g);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to resolve group of user '%s': %m", u->user_name);
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ int nss_passwd_to_user_record(
|
||||
&hr->json,
|
||||
SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(hr->user_name)),
|
||||
SD_JSON_BUILD_PAIR("uid", SD_JSON_BUILD_UNSIGNED(hr->uid)),
|
||||
SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(hr->gid)),
|
||||
SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(user_record_gid(hr))),
|
||||
SD_JSON_BUILD_PAIR_CONDITION(!!hr->real_name, "realName", SD_JSON_BUILD_STRING(hr->real_name)),
|
||||
SD_JSON_BUILD_PAIR_CONDITION(!!hr->home_directory, "homeDirectory", SD_JSON_BUILD_STRING(hr->home_directory)),
|
||||
SD_JSON_BUILD_PAIR_CONDITION(!!hr->shell, "shell", SD_JSON_BUILD_STRING(hr->shell)),
|
||||
|
||||
@@ -216,18 +216,18 @@ void user_record_show(UserRecord *hr, bool show_full_group_info) {
|
||||
}
|
||||
if (uid_is_valid(hr->uid))
|
||||
printf(" UID: " UID_FMT "\n", hr->uid);
|
||||
if (gid_is_valid(hr->gid)) {
|
||||
if (gid_is_valid(user_record_gid(hr))) {
|
||||
if (show_full_group_info) {
|
||||
_cleanup_(group_record_unrefp) GroupRecord *gr = NULL;
|
||||
|
||||
r = groupdb_by_gid(hr->gid, /* match= */ NULL, /* flags= */ 0, &gr);
|
||||
r = groupdb_by_gid(user_record_gid(hr), /* match= */ NULL, /* flags= */ 0, &gr);
|
||||
if (r < 0) {
|
||||
errno = -r;
|
||||
printf(" GID: " GID_FMT " (unresolvable: %m)\n", hr->gid);
|
||||
printf(" GID: " GID_FMT " (unresolvable: %m)\n", user_record_gid(hr));
|
||||
} else
|
||||
printf(" GID: " GID_FMT " (%s)\n", hr->gid, gr->group_name);
|
||||
printf(" GID: " GID_FMT " (%s)\n", user_record_gid(hr), gr->group_name);
|
||||
} else
|
||||
printf(" GID: " GID_FMT "\n", hr->gid);
|
||||
printf(" GID: " GID_FMT "\n", user_record_gid(hr));
|
||||
} else if (uid_is_valid(hr->uid)) /* Show UID as GID if not separately configured */
|
||||
printf(" GID: " GID_FMT "\n", (gid_t) hr->uid);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user