File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22#
33# Locks the root account and erases it's current password.
44#
5- # Version: v1.0.3
5+ # Version: v1.0.4
66# License: MIT License
7- # Copyright (c) 2020-2021 Hunter T.
7+ # Copyright (c) 2020-2022 Hunter T. (StrangeRanger)
88#
99# #######################################################################################
1010# ### [ Variables ]
1111
1212
13- config_file_bak=" /etc/shadow.bak"
14- config_file=" /etc/shadow"
1513green=$' \033 [0;32m'
16- cyan=$' \033 [0;36m'
1714red=$' \033 [1;31m'
1815nc=$' \033 [0m'
1916
@@ -27,7 +24,7 @@ nc=$'\033[0m'
2724if [[ $EUID != 0 ]]; then
2825 echo " ${red} Please run this script as or with root privilege$nc " >&2
2926 echo -e " \nExiting..."
30- exit 1
27+ exit 2
3128fi
3229
3330
3835
3936read -rp " We will now disable the root account. Press [Enter] to continue."
4037
41- # # Backup 'shadow' if 'shadow.bak' doesn't already exist.
42- if [[ ! -f $config_file_bak ]]; then
43- echo " Backing up original 'shadow'..."
44- cp " $config_file " " $config_file_bak " || {
45- echo " ${red} Failed to back up shadow" >&2
46- echo " ${cyan} Please create a backup of the original 'shadow' before continuing$nc "
47- exit 1
48- }
49- fi
50-
5138echo " Disabling root account..."
52- passwd -dl root && echo -e " \n${green} The root account has been locked$nc " \
53- || echo -e " \n${red} Failed to lock the root account$nc "
39+ passwd -dl root || {
40+ echo -e " \n${red} Failed to lock the root account$nc "
41+ exit 1
42+ }
43+
44+ echo -e " \n${green} The root account has been locked$nc "
5445
5546
5647# ### End of [ Main ]
You can’t perform that action at this time.
0 commit comments