mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
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:
parent
fb5dfbc2d8
commit
d4f0412de4
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
2
test/TEST-21-SYSUSERS/test-10.expected-group
Normal file
2
test/TEST-21-SYSUSERS/test-10.expected-group
Normal file
@ -0,0 +1,2 @@
|
||||
u1:x:300:u2
|
||||
u2:x:SYSTEM_UID_MAX:
|
2
test/TEST-21-SYSUSERS/test-10.expected-passwd
Normal file
2
test/TEST-21-SYSUSERS/test-10.expected-passwd
Normal file
@ -0,0 +1,2 @@
|
||||
u1:x:300:300::/:/sbin/nologin
|
||||
u2:x:SYSTEM_UID_MAX:SYSTEM_UID_MAX::/:/sbin/nologin
|
5
test/TEST-21-SYSUSERS/test-10.input
Normal file
5
test/TEST-21-SYSUSERS/test-10.input
Normal file
@ -0,0 +1,5 @@
|
||||
# check that 'm' lines do not conflicts 'u' line
|
||||
#
|
||||
#Type Name ID GECOS HOMEDIR
|
||||
u u1 300 - -
|
||||
m u2 u1
|
Loading…
Reference in New Issue
Block a user