From: Yu Watanabe Date: Thu, 1 Mar 2018 18:27:34 +0000 (+0900) Subject: sysusers: do not create duplicated groups when create users X-Git-Tag: v238~26^2~2 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fsystemd.git;a=commitdiff_plain;h=b5327d0a65b7515b4c8bcdf94cf71948da5d608e sysusers: do not create duplicated groups when create users The commit e2c2060f7b3b11fa3cca8899d80963b7a05cc4ab introduces the issue #8315. Fixes #8315. --- diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index fab54b50402..80a033054b8 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -1209,12 +1209,25 @@ static int process_item(Item *i) { switch (i->type) { - case ADD_USER: - r = add_group(i); - if (r < 0) - return r; + case ADD_USER: { + Item *j; + + j = ordered_hashmap_get(groups, i->name); + if (j && j->todo_group) { + /* When the group with the same name is already in queue, + * use the information about the group and do not create + * duplicated group entry. */ + i->gid_set = j->gid_set; + i->gid = j->gid; + i->id_set_strict = true; + } else { + r = add_group(i); + if (r < 0) + return r; + } return add_user(i); + } case ADD_GROUP: return add_group(i);