mirror of
https://github.com/systemd/systemd.git
synced 2025-03-28 02:50:16 +03:00
sysusers: support u username -:300
style syntax (#8325)
This PR implements the first part of RFE #8046. I.e. this allows to write: ``` u username -:300 ``` Where the uid is chosen automatically but the gid is fixed.
This commit is contained in:
parent
283def70cf
commit
1825c909ff
@ -194,7 +194,8 @@ u root 0 "Superuser" /root /bin/zsh</pro
|
||||
match the owners of pre-existing files (such as SUID or SGID
|
||||
binaries).
|
||||
The syntax <literal><replaceable>uid</replaceable>:<replaceable>gid</replaceable></literal> is also supported to
|
||||
allow creating user and group pairs with different numeric UID and GID values. The group with the indicated GID must get created explicitly before or it must already exist.
|
||||
allow creating user and group pairs with different numeric UID and GID values. The group with the indicated GID must get created explicitly before or it must already exist. Specifying <literal>-</literal> for the UID in this syntax
|
||||
is also supported.
|
||||
</para>
|
||||
|
||||
<para>For <varname>m</varname> lines, this field should contain
|
||||
|
@ -1599,11 +1599,12 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
|
||||
i->id_set_strict = true;
|
||||
free_and_replace(resolved_id, uid);
|
||||
}
|
||||
r = parse_uid(resolved_id, &i->uid);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to parse UID: '%s': %m", id);
|
||||
|
||||
i->uid_set = true;
|
||||
if (!streq(resolved_id, "-")) {
|
||||
r = parse_uid(resolved_id, &i->uid);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to parse UID: '%s': %m", id);
|
||||
i->uid_set = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
1
test/TEST-21-SYSUSERS/test-8.expected-group
Normal file
1
test/TEST-21-SYSUSERS/test-8.expected-group
Normal file
@ -0,0 +1 @@
|
||||
groupname:x:300:
|
1
test/TEST-21-SYSUSERS/test-8.expected-passwd
Normal file
1
test/TEST-21-SYSUSERS/test-8.expected-passwd
Normal file
@ -0,0 +1 @@
|
||||
username:x:SYSTEM_UID_MAX:300::/:/sbin/nologin
|
2
test/TEST-21-SYSUSERS/test-8.input
Normal file
2
test/TEST-21-SYSUSERS/test-8.input
Normal file
@ -0,0 +1,2 @@
|
||||
g groupname 300
|
||||
u username -:300
|
1
test/TEST-21-SYSUSERS/test-9.expected-group
Normal file
1
test/TEST-21-SYSUSERS/test-9.expected-group
Normal file
@ -0,0 +1 @@
|
||||
user1:x:300:
|
2
test/TEST-21-SYSUSERS/test-9.expected-passwd
Normal file
2
test/TEST-21-SYSUSERS/test-9.expected-passwd
Normal file
@ -0,0 +1,2 @@
|
||||
user1:x:300:300::/:/sbin/nologin
|
||||
user2:x:SYSTEM_UID_MAX:300::/:/sbin/nologin
|
2
test/TEST-21-SYSUSERS/test-9.input
Normal file
2
test/TEST-21-SYSUSERS/test-9.input
Normal file
@ -0,0 +1,2 @@
|
||||
u user1 300
|
||||
u user2 -:300
|
Loading…
x
Reference in New Issue
Block a user