]> git.ipfire.org Git - thirdparty/shadow.git/commit
chpasswd: Check hash before write when using -e
authorvinz <mmpx09@protonmail.com>
Fri, 11 Jul 2025 16:08:22 +0000 (16:08 +0000)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Sun, 20 Jul 2025 19:57:14 +0000 (21:57 +0200)
commitc44f1e096a19a7d356da5969295393247e61874f
treebffe7845a9a5546744a11f26b5dc1b7aaa06e009
parent2e7db49128fc5ae7dd68b613c03a174e65d70e4a
chpasswd: Check hash before write when using -e

Add is_valid_hash to prevent adding a bad hash in /etc/shadow (and so prevent user to be lock) when using chpasswd -e

    # before
    echo 'vinz:test123' | chpasswd -e
    grep vinz /etc/shadow
    vinz:test123:20280:0:99999:7:::

    # now
    echo 'vinz:test123' | sudo ./chpasswd -e
    chpasswd: (line 1, user vinz) invalid password hash
    chpasswd: error detected, changes ignored
lib/Makefile.am
lib/chkhash.c [new file with mode: 0644]
lib/chkhash.h [new file with mode: 0644]
src/chpasswd.c