On Wed, Mar 05, 2025 at 09:46:53AM +0100, Marc Haber wrote:
this is a discussion with Vincent Lefevre on #1099470:
1. For a system account, there would still be an issue if the account↲ >has a password (if possible). If EXISTING_ID_MISMATCH is set, this↲ >would also yield an issue; I think that this is possible if the --uid↲ >adduser option is used, with an id different from the current one for↲ >this account. You should add a test for this case.↲
↲
2. For a non-system account, the problematic test would always be↲ >false, while it is actually meant to be true (the error message↲ >contains "but is not a system user"). So you should add a test↲
↲
adduser --system username↲
↲
where the username account already exists and is not a system account↲ >(not sure whether other options, such as --disabled-password, may be↲ >needed). One would expect a non-zero exit status because --system is↲ >used while username exists and is not a system account.↲
So that would bascially mean:
(1)
adduser foo
adduser --system (must fail, 'already exists as a non-system user')
adduser --uid 100 foo
adduser --uid 101 foo (must fail, 'cannot fulfill uid requirement,
already exists with othe uid')
(we would need to use --disabled-password for all non-system user
creation since adduser cannot non-interactively create an account with a password).
this is a discussion with Vincent Lefevre on #1099470:
1. For a system account, there would still be an issue if the account↲ >has a password (if possible). If EXISTING_ID_MISMATCH is set, this↲
would also yield an issue; I think that this is possible if the --uid↲ >adduser option is used, with an id different from the current one for↲ >this account. You should add a test for this case.↲
↲
2. For a non-system account, the problematic test would always be↲
false, while it is actually meant to be true (the error message↲
contains "but is not a system user"). So you should add a test↲
↲
adduser --system username↲
↲
where the username account already exists and is not a system account↲ >(not sure whether other options, such as --disabled-password, may be↲ >needed). One would expect a non-zero exit status because --system is↲ >used while username exists and is not a system account.↲
(1)
adduser foo
adduser --system (must fail, 'already exists as a non-system user')
(2)
adduser --uid 100 foo
adduser --uid 101 foo (must fail, 'cannot fulfill uid requirement,
already exists with othe uid')
(we would need to use --disabled-password for all non-system user
creation since adduser cannot non-interactively create an account with a password).
adduser foo
adduser --system foo
That would actually be case (2). This must fail.
(these are flags with power-of-two values, thus can be OR'ed) and
the buggy adduser 3.143 has
if ($ret == (EXISTING_FOUND|EXISTING_SYSTEM)) {
# a user with this name already exists; it's a problem when it's not a s
ystem user
log_fatal( mtx("The user `%s' already exists, but is not a system user.
Exiting."), $new_name );
exit( RET_WRONG_OBJECT_PROPERTIES );
}
i.e. it tests whether *only* EXISTING_FOUND and EXISTING_SYSTEM are
set.
You should add a test for case (1), i.e. when the existing system
account has a password:
adduser --system foo
passwd foo
[add a password]
adduser --system foo
adduser --system foo
echo mypassword | passwd -s foo
adduser --system foo
This one must not fail.
You should add a similar test for non-system accounts, since this
involves a different part of the code. Something like:
adduser --disabled-password --uid 2000 foo
adduser --disabled-password --uid 2001 foo
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 481 |
Nodes: | 16 (2 / 14) |
Uptime: | 15:05:51 |
Calls: | 9,540 |
Files: | 13,653 |
Messages: | 6,139,632 |