Repository navigation
chpasswd: apply args before generating salt - #1797
Conversation
|
Note it's in Draft because it was not yet tested. |
Salt was generated before the chroot/prefix were applied, ignoring *proper* '/etc/login.defs' and using host's config instead. Fixes: 3732cf7 (2022-04-03; "chpasswd: fix function problem with -R parameter") Note that the commit message of a patch that introduced this issue: ``` Generating salt value depends on /dev/urandom. But after the function process_root_flag changed the root directory, It does not exist. ``` was wrong because a fall back was implemented before that in c82ed0c
fc27ac0 to
78f4f86
Compare
1. Prepare minimal chrootsudo mkdir -p /tmp/test-chroot/etc /tmp/test-chroot/root 2. Check what the HOST uses (for contrast)grep -E '^ENCRYPT_METHOD' /etc/login.defs 3. Run the PR binary with -Recho "root:newpassword" | sudo ./src/chpasswd -R /tmp/test-chroot 4. Inspect the resultsudo cat /tmp/test-chroot/etc/shadow ===================================================== root@ibm-p8-kvm-03-guest-02:/home/ilak/shadow# # Clean slate Use SINGLE quotes so ! isn't history-expandedecho 'root:x:0:0:root:/root:/bin/bash' | sudo tee /tmp/test-chroot/etc/passwd Sanity check: files must exist and have contentsudo cat /tmp/test-chroot/etc/shadow Run the PR binary (note ./src/)echo 'root:newpassword' | sudo ./src/chpasswd -R /tmp/test-chroot Inspectsudo cat /tmp/test-chroot/etc/shadow From above results: Host /etc/login.defs: ENCRYPT_METHOD YESCRYPT The hash starts with ================================================ root@ibm-p8-kvm-03-guest-02:/home/ilak/shadow# # Reset chroot shadow System binary (no fix)echo 'root:newpassword' | sudo /usr/sbin/chpasswd -R /tmp/test-chroot Inspectsudo cat /tmp/test-chroot/etc/shadow ./src/chpasswd (PR #1797) $6$8ZntiKE9... |
alejandro-colomar
left a comment
There was a problem hiding this comment.
Thanks!
Reviewed-by: Alejandro Colomar <alx@kernel.org>
c16df8e
into
shadow-maint:master
Salt was generated before the chroot/prefix were applied, ignoring proper '/etc/login.defs' and using host's config instead.