/
pscript1.1
53 lines (41 loc) · 1.46 KB
/
pscript1.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# Written by Vlaze
# PassScript 1.1, revised November 2015
# This script lets you change your root password and asking for it in sudo commands
VERSION="1.1"
# Changelog 1.1: Restricted kill related processes (pidof, pkill, kill) to root user (25/11/2015)
# Asks if root password wants to be set manually or not
echo "" # (optional) move to a new line
read -p "Do you want to set a custom root password? [Y/n]" -n 1 -r
# Sets possible answers. Exception handling intended to be added in future version
if [[ $REPLY =~ ^[Yy]$ ]]
then
# Lets the user set his/her/its own root password.
# I strongly recommend you not to let your pets/aliens use your computer as root!
echo ""
echo ""
sudo passwd root
fi
if [[ $REPLY =~ ^[Nn]$ ]]
then
# Sets up root password like "username:password"
echo ""
echo ""
echo "Changing your root password to "root"..."
echo "root:root" | chpasswd
sleep 1
echo ""
echo "Password succesfully changed!"
fi
# Asks for root password in sudo commands
sleep 1
echo "" # (optional) move to a new line
# Turns kill related commands sudo
echo "Turning kill, pkill and pidof commands to sudo..."
sudo chmod o-x /bin/kill
sudo chmod o-x /usr/bin/pkill
sudo chmod o-x /bin/pidof
# Edits /etc/sudoers.txt so as to always ask for the recently created root password when using a sudo command
echo ""
sed -i '12iDefaults rootpw' /etc/sudoers
echo "Root password being asked for sudo commands from now on!"