• Bug#1099570: additional test cases needed

    From Marc Haber@21:1/5 to All on Wed Mar 5 10:00:01 2025
    UGFja2FnZTogYWRkdXNlcgpWZXJzaW9uOiAzLjE0NApTZXZlcml0eTogaW1wb3J0YW50CgpIaSwK CnRoaXMgaXMgYSBkaXNjdXNzaW9uIHdpdGggVmluY2VudCBMZWZldnJlIG9uICMxMDk5NDcwOgo+ MS4gRm9yIGEgc3lzdGVtIGFjY291bnQsIHRoZXJlIHdvdWxkIHN0aWxsIGJlIGFuIGlzc3VlIGlm IHRoZSBhY2NvdW504oayCj5oYXMgYSBwYXNzd29yZCAoaWYgcG9zc2libGUpLiBJZiBFWElTVElO R19JRF9NSVNNQVRDSCBpcyBzZXQsIHRoaXPihrIKPndvdWxkIGFsc28geWllbGQgYW4gaXNzdWU7 IEkgdGhpbmsgdGhhdCB0aGlzIGlzIHBvc3NpYmxlIGlmIHRoZSAtLXVpZOKGsgo+YWRkdXNlciBv cHRpb24gaXMgdXNlZCwgd2l0aCBhbiBpZCBkaWZmZXJlbnQgZnJvbSB0aGUgY3VycmVudCBvbmUg Zm9y4oayCj50aGlzIGFjY291bnQuIFlvdSBzaG91bGQgYWRkIGEgdGVzdCBmb3IgdGhpcyBjYXNl LuKGsgo+4oayCj4yLiBGb3IgYSBub24tc3lzdGVtIGFjY291bnQsIHRoZSBwcm9ibGVtYXRpYyB0 ZXN0IHdvdWxkIGFsd2F5cyBiZeKGsgo+ZmFsc2UsIHdoaWxlIGl0IGlzIGFjdHVhbGx5IG1lYW50 IHRvIGJlIHRydWUgKHRoZSBlcnJvciBtZXNzYWdl4oayCj5jb250YWlucyAiYnV0IGlzIG5vdCBh IHN5c3RlbSB1c2VyIikuIFNvIHlvdSBzaG91bGQgYWRkIGEgdGVzdOKGsgo+4oayCj4gIGFkZHVz ZXIgLS1zeXN0ZW0gdXNlcm5hbWXihrIKPuKGsgo+d2hlcmUgdGhlIHVzZXJuYW1lIGFjY291bnQg YWxyZWFkeSBleGlzdHMgYW5kIGlzIG5vdCBhIHN5c3RlbSBhY2NvdW504oayCj4obm90IHN1cmUg d2hldGhlciBvdGhlciBvcHRpb25zLCBzdWNoIGFzIC0tZGlzYWJsZWQtcGFzc3dvcmQsIG1heSBi ZeKGsgo+bmVlZGVkKS4gT25lIHdvdWxkIGV4cGVjdCBhIG5vbi16ZXJvIGV4aXQgc3RhdHVzIGJl Y2F1c2UgLS1zeXN0ZW0gaXPihrIKPnVzZWQgd2hpbGUgdXNlcm5hbWUgZXhpc3RzIGFuZCBpcyBu b3QgYSBzeXN0ZW0gYWNjb3VudC7ihrIK4oayCg==

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Vincent Lefevre@21:1/5 to Marc Haber on Wed Mar 5 13:50:03 2025
    On 2025-03-05 12:04:04 +0100, Marc Haber wrote:
    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.↲

    Clarification: by "system account" and "non-system account" above,
    I meant: the account that already exists. What will follow is a
    "adduser --system username" (possibly with other options).

    Note also that actually, there is no issue with EXISTING_ID_MISMATCH
    for case (1).

    So that would bascially mean:

    (1)
    adduser foo
    adduser --system (must fail, 'already exists as a non-system user')

    adduser foo
    adduser --system foo

    That would actually be case (2). This must fail.

    Explanations of the issue on this case with adduser 3.143:
    One has

    use constant {
    EXISTING_NOT_FOUND => 0,
    EXISTING_FOUND => 1,
    EXISTING_SYSTEM => 2,
    EXISTING_ID_MISMATCH => 4,
    EXISTING_LOCKED => 8,
    };

    (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.

    If the existing "foo" is a non-system account (as tested above), this
    does not fail (while it would be expected to fail) for 2 reasons:
    first, because EXISTING_SYSTEM is unset (since the existing account
    is *not* a system account) while the test incorrectly requires that
    it is set (instead, it should require that it is unset); second,
    because EXISTING_ID_MISMATCH is necessarily set (non-system and
    system accounts necessarily have 2 different ids), thus the "=="
    cannot be satisfied.

    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

    or for a script, I suppose that this should work (the passwd(1)
    man page says that the -s / --stdin option "is used to indicate
    that passwd should read the new password from standard input,
    which can be a pipe"):

    adduser --system foo
    echo mypassword | passwd -s foo
    adduser --system foo

    This one must not fail.

    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).

    The above is for system accounts (this is handled correctly, even in
    adduser 3.143, with the "$ret & EXISTING_ID_MISMATCH" test).

    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

    Regards,

    --
    Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
    100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
    Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marc Haber@21:1/5 to Marc Haber on Wed Mar 5 14:00:01 2025
    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')

    (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).

    With EXISTING_LOCKED test being completely gone for trixie¹, do you
    suggest adding more tests for adduser in trixie?

    Greetings
    Marc

    ¹ we still define the value but neither set nor use it

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marc Haber@21:1/5 to Marc Haber on Fri Mar 7 12:30:01 2025
    On Wed, Mar 05, 2025 at 12:04:04PM +0100, Marc Haber wrote:
    (1)
    adduser foo
    adduser --system (must fail, 'already exists as a non-system user')

    That is the case, we check that.

    (2)
    adduser --uid 100 foo
    adduser --uid 101 foo (must fail, 'cannot fulfill uid requirement,
    already exists with othe uid')

    for non-system users, it fails with "user already exists"

    for system users, it fails with "already exists with a different 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).

    --disabled-password and --comment ""

    Greetings
    Marc

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marc Haber@21:1/5 to Vincent Lefevre on Fri Mar 7 12:40:01 2025
    On Wed, Mar 05, 2025 at 01:21:24PM +0100, Vincent Lefevre wrote:
    adduser foo
    adduser --system foo

    That would actually be case (2). This must fail.

    yes. We test that now.

    (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.

    That code is fixed resp. gone.

    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

    That we don't at the moment. I am not sure whether we will be adding
    this before trixie.

    We can pipe things into chpasswd like in
    debian/tests/f/adduser_system.t:
    system('echo "aust:*" | chpasswd --encrypted')

    adduser --system foo
    echo mypassword | passwd -s foo
    adduser --system foo

    This one must not fail.

    root@salida-sid-buildd-amd64-xzcp:/srv/build# adduser --system passwdtest root@salida-sid-buildd-amd64-xzcp:/srv/build# passwd !$
    passwd passwdtest
    New password:
    Retype new password:
    passwd: password updated successfully root@salida-sid-buildd-amd64-xzcp:/srv/build# adduser --system passwdtest root@salida-sid-buildd-amd64-xzcp:/srv/build# echo $?

    0
    root@salida-sid-buildd-amd64-xzcp:/srv/build#

    It does not.

    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

    We do that now, it says "already exists"

    root@salida-sid-buildd-amd64-xzcp:/srv/build# adduser --disabled-password --comment "" --uid 4006 u4006
    root@salida-sid-buildd-amd64-xzcp:/srv/build# adduser --disabled-password --comment "" --uid 4007 u4006
    fatal: The user `u4006' already exists. root@salida-sid-buildd-amd64-xzcp:/srv/build#

    Greetings
    Marc

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)