blob: d0dab500b5a6ba1fd1e0ab46ff4ed976a0a01ed3 (
plain) (
blame)
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
|
add_group() {
echo -n "# Adding group: $1, gid $2..."
groupadd -g "$2" "$1" 2>/dev/null || perror "Could not add group $1 / gid $2!"
echo " ok."
}
add_user() {
echo -n "# Adding user: $1, uid $2, prim. gid $3, optional: other group $4"
if [ $# -eq 4 ]; then
params=" -u $2 -m -d /home/$1 -s /bin/bash -g $3 -G $4 $1"
else
params=" -u $2 -m -d /home/$1 -s /bin/bash -g $3 $1"
fi
useradd ${params} 2>/dev/null || perror "Could not add user ${1}/${2} / gid $3 $4"
echo " ok."
}
add_user_nohome() {
echo -n "# Adding homeless user: $1, uid $2, to gid $3..."
useradd -u "$2" --no-create-home -d /nonexistent --shell /bin/false -g "$3" "$1" 2>/dev/null \
|| perror "Could not add homeless user ${1}/${2} / gid $3!"
echo " ok."
}
kill_user() {
echo -n "# Terminating user account id $1, leaving user home/files as they were: "
userdel $(getent passwd "$1" | cut -f 1 -d ":") || perror "# could not kill userid ${1}!"
echo " ok."
}
check_users() {
echo "#"
echo "# Checking for users to kill with id>=1000: "
for userid in $(cat /etc/passwd|cut -f 3 -d ":"|sort -n); do
case $userid in
65534) echo "# Ignoring user 65534/sync." ;;
*) [ "$userid" -ge 1000 ] && kill_user "$userid"
esac
done
}
|