fix firstlogin failed to create password on sid

This commit is contained in:
Jianfeng Liu
2025-07-22 17:49:51 +08:00
committed by Igor
parent 2f852e68e5
commit 05581e4b6b

View File

@@ -746,9 +746,17 @@ if [[ -f /root/.not_logged_in_yet && -n $(tty) ]]; then
fi
fi
# only allow one login. Once you enter root password, kill others.
loginfrom=$(who am i | awk '{print $2}')
who -la | grep root | grep -v "$loginfrom" | awk '{print $7}' | xargs --no-run-if-empty kill -9
# Get current session identifiers
current_tty=$(tty | sed 's:/dev/::') # e.g., "tty1"
current_pid=$$
# Kill ONLY other active root SHELL sessions (not login processes)
ps -u root -o pid,tty,comm |
awk -v me="$current_tty" -v mypid="$current_pid" '
NR>1 && $2 != "?" && $2 != me && $1 != mypid && $3 ~ /sh$/ {
print $1
}' |
xargs --no-run-if-empty kill -9
# enable motd
chmod +x /etc/update-motd.d/*