[Pkg-shadow-devel] [Git][debian/adduser][debian/latest] 4 commits: adapt test to #109934 (EXISTING_HAS_PASSWORD)

Marc Haber (@zugschlus) gitlab at salsa.debian.org
Wed Dec 31 22:23:33 GMT 2025



Marc Haber pushed to branch debian/latest at Debian / adduser


Commits:
81e16856 by Marc Haber at 2025-12-31T22:47:15+01:00
adapt test to #109934 (EXISTING_HAS_PASSWORD)

Git-Dch: ignore

- - - - -
268c6987 by Marc Haber at 2025-12-31T22:58:24+01:00
implement EXISTING_HAS_PASSWORD

Git-Dch: ignore

- - - - -
b7e299b5 by Marc Haber at 2025-12-31T23:05:57+01:00
improve documentation in existing_*_status

Git-Dch: ignore

- - - - -
bf4f9bbc by Marc Haber at 2025-12-31T23:06:03+01:00
make adduser error out if --system and account has a password

Closes: #1099734

- - - - -


3 changed files:

- AdduserCommon.pm
- adduser
- debian/tests/f/adduser_system.t


Changes:

=====================================
AdduserCommon.pm
=====================================
@@ -614,6 +614,9 @@ sub existing_user_status {
         $ret |= EXISTING_HAS_PASSWORD if
             (defined $pw && $pw ne '' && $pw ne '!' && $pw !~ /^\*/);
         $ret |= EXISTING_LOCKED if (substr($pw,0,1) eq "!");  # TODO: also check expiry?
+    } elsif ($new_uid && getpwuid($new_uid)) {
+        # user with the uid exists
+        $ret |= EXISTING_ID_MISMATCH;
     } 
     log_trace( "existing_user_status returning %d", $ret );
     return $ret;


=====================================
adduser
=====================================
@@ -584,6 +584,10 @@ if ($action eq "addsysuser") {
         log_fatal( mtx("The user `%s' already exists with a different UID. Exiting."), $new_name );
         exit( RET_WRONG_OBJECT_PROPERTIES );
     }
+    if ($ret & EXISTING_HAS_PASSWORD) {
+        log_fatal( mtx("The user `%s' already exists and has a password. Exiting."), $new_name );
+        exit( RET_WRONG_OBJECT_PROPERTIES );
+    }
     if ($ret & EXISTING_FOUND) {
         log_info( mtx("The system user `%s' already exists. Exiting.\n"), $new_name );
         exit( RET_OK );


=====================================
debian/tests/f/adduser_system.t
=====================================
@@ -206,8 +206,7 @@ assert_user_is_system('aust');
 
 system('echo "aust:!foobar" | chpasswd --encrypted');
 # with #1099734 fixed, this should fail
-#assert_command_result_silent(RET_WRONG_OBJECT_PROPERTIES,
-assert_command_success(
+assert_command_result_silent(RET_WRONG_OBJECT_PROPERTIES,
     '/usr/sbin/adduser',
     '--stdoutmsglevel=error', '--stderrmsglevel=error',
     '--system',



View it on GitLab: https://salsa.debian.org/debian/adduser/-/compare/5969119bc2d2eaeb56c1de801d379f3784629ad8...bf4f9bbc3d37d074c9dd16e6d64456417b079546

-- 
View it on GitLab: https://salsa.debian.org/debian/adduser/-/compare/5969119bc2d2eaeb56c1de801d379f3784629ad8...bf4f9bbc3d37d074c9dd16e6d64456417b079546
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-shadow-devel/attachments/20251231/d4ffce83/attachment-0001.htm>


More information about the Pkg-shadow-devel mailing list