Verified Commit acdf1338 authored by Marco Marinello's avatar Marco Marinello
Browse files

Various fixes to password-next-change

parent 0d3e06cd
Pipeline #224 passed with stage
in 23 seconds
#!/bin/bash
#Data ultimo cambio password in giorni dal 1/01/1970
LAST_CHANGE=$(expr $(date --date=$(passwd -S $user|cut -d" " -f3) +%s) / 86400 + 1)
#Durata della password in giorni
SHADOWMAX=$(passwd -S $user|cut -d" " -f5)
#Data del prossimo cambio password forzato in giorni dal 1/01/1970
# This file is part of the FUSS Utility project.
# Copyright (C) 2022 The FUSS Project <info@fuss.bz.it>
# Author: Claudio Cavalli <ccavalli@fuss.bz.it>
# Author: Marco Marinello <contact-nohuman@marinello.bz.it>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
user="$(whoami)"
# Data ultimo cambio password in giorni dal 1/01/1970
LAST_CHANGE=$(expr $(date --date=$(passwd -S "$user"|cut -d" " -f3) +%s) / 86400 + 1)
# Durata della password in giorni
SHADOWMAX=$(passwd -S "$user"|cut -d" " -f5)
# Data del prossimo cambio password forzato in giorni dal 1/01/1970
NEXT_CHANGE=$(expr $LAST_CHANGE + $SHADOWMAX)
#Data di oggi in giorni dal 1/01/1970
# Data di oggi in giorni dal 1/01/1970
TODAY=$(expr $(date +%s) / 86400 )
#Giorni mancanti al prossimo cambio password forzato
# Giorni mancanti al prossimo cambio password forzato
DAYTOCHANGE=$(expr $NEXT_CHANGE - $TODAY)
if [ $DAYTOCHANGE -lt 8 ]
if [ "$DAYTOCHANGE" -lt 10 ]
then
if [ $DAYTOCHANGE == 0 ]; then
if [ "$DAYTOCHANGE" == 0 ]; then
GIO="scade oggi"
elif [ $DAYTOCHANGE == 1 ]; then
elif [ "$DAYTOCHANGE" == 1 ]; then
GIO="scadrà domani"
else
GIO="scadrà tra $DAYTOCHANGE giorni"
fi
zenity --info --width 400 --text "\nCiao $USER \n\nLa tua password $GIO! \n"
zenity --question --title="Password scaduta" --text="\nTi consigliamo di aggiornare al più presto la password! \n\nLa aggiorni ora?" --width=500 --height=100
if [ $? == 0 ]; then
/usr/bin/change-password
fi
zenity --info --width 400 --title "Avviso scadenza password" --text "\nAttenzione!\n\nLa tua password $GIO\n"
if [ $? == 1 ]; then
exit 0
if zenity --question --title="Avviso scadenza password" --text "\nÈ consigliabile aggiornare al più presto password, prima che questa scada!\n\nProcedere ora al cambiamento?" --width=500 --height=100
then
[ -x '/usr/bin/change-password' ] && /usr/bin/change-password
fi
fi
exit 0
\ No newline at end of file
[Desktop Entry]
Type=Application
Name=User password next change
TryExec=/usr/bin/password-next-change
Exec=/usr/bin/password-next-change
StartupNotify=false
NoDisplay=true
X-XFCE-Autostart-Override=true
X-XFCE-Autostart-Override=true
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment