sysusers: do not implicitly create group by 'm' if 'u' with the same name exists
The commit e2c2060f7b makes 'm' lines
disturb 'u' lines.
This fixes the disturbance.
This commit is contained in:
+26
-31
@@ -1259,40 +1259,11 @@ static int add_implicit(void) {
|
||||
int r;
|
||||
|
||||
/* Implicitly create additional users and groups, if they were listed in "m" lines */
|
||||
|
||||
ORDERED_HASHMAP_FOREACH_KEY(l, g, members, iterator) {
|
||||
Item *i;
|
||||
char **m;
|
||||
|
||||
i = ordered_hashmap_get(groups, g);
|
||||
if (!i) {
|
||||
_cleanup_(item_freep) Item *j = NULL;
|
||||
|
||||
r = ordered_hashmap_ensure_allocated(&groups, &string_hash_ops);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
j = new0(Item, 1);
|
||||
if (!j)
|
||||
return log_oom();
|
||||
|
||||
j->type = ADD_GROUP;
|
||||
j->name = strdup(g);
|
||||
if (!j->name)
|
||||
return log_oom();
|
||||
|
||||
r = ordered_hashmap_put(groups, j->name, j);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
log_debug("Adding implicit group '%s' due to m line", j->name);
|
||||
j = NULL;
|
||||
}
|
||||
|
||||
STRV_FOREACH(m, l) {
|
||||
|
||||
i = ordered_hashmap_get(users, *m);
|
||||
if (!i) {
|
||||
STRV_FOREACH(m, l)
|
||||
if (!ordered_hashmap_get(users, *m)) {
|
||||
_cleanup_(item_freep) Item *j = NULL;
|
||||
|
||||
r = ordered_hashmap_ensure_allocated(&users, &string_hash_ops);
|
||||
@@ -1315,6 +1286,30 @@ static int add_implicit(void) {
|
||||
log_debug("Adding implicit user '%s' due to m line", j->name);
|
||||
j = NULL;
|
||||
}
|
||||
|
||||
if (!(ordered_hashmap_get(users, g) ||
|
||||
ordered_hashmap_get(groups, g))) {
|
||||
_cleanup_(item_freep) Item *j = NULL;
|
||||
|
||||
r = ordered_hashmap_ensure_allocated(&groups, &string_hash_ops);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
j = new0(Item, 1);
|
||||
if (!j)
|
||||
return log_oom();
|
||||
|
||||
j->type = ADD_GROUP;
|
||||
j->name = strdup(g);
|
||||
if (!j->name)
|
||||
return log_oom();
|
||||
|
||||
r = ordered_hashmap_put(groups, j->name, j);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
log_debug("Adding implicit group '%s' due to m line", j->name);
|
||||
j = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user