Dois anos e nenhuma resposta? É triste dizer que a única solução que eu encontrei é esse roteiro. Eu testei no Ubuntu 14. Note que não há tratamento de erros se você der uma entrada ruim.
chage_update.sh
:
#!/bin/bash
usage() {
cat <<EOF
Usage: $0 [ YYYY-MM-DD ]
Update chage information for all regular users to the values present in
/etc/login.defs, and set the date of the last password change to YYYY-MM-DD
(defaults to current date). Must be run as root.
EOF
exit;
}
get_val() {
ARR=('grep ^$1 /etc/login.defs')
echo ${ARR[1]}
}
UID_MIN='get_val UID_MIN'
PASS_MAX_DAYS='get_val PASS_MAX_DAYS'
PASS_WARN_AGE='get_val PASS_WARN_AGE'
if [ "$1" = "-h" -o "$1" = "--help" ]; then
usage
elif [ -z "$1" ]; then
DATE='date +%Y-%m-%d'
else
DATE=$1
fi
cat /etc/passwd | while read line; do
ARR=($(echo "$line" | cut -d\: -f1-3 | tr : \ ))
USER=${ARR[0]}
USERID=${ARR[2]}
if [ -z "$USERID" ]; then
continue
elif [ "$USERID" -ge $UID_MIN ]; then
chage -d $DATE -M $PASS_MAX_DAYS -W $PASS_WARN_AGE $USER
fi
done