-
Notifications
You must be signed in to change notification settings - Fork 0
/
ftpusers.sh
executable file
·39 lines (35 loc) · 1.02 KB
/
ftpusers.sh
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
#!/bin/bash
######################################################################
#
# Author: Andrwe Lord Weber
# Mail: andrwe<at>andrwe<dot>org
# Version: 0.0.1
# Description: modifies group & shell of user written to fifo
#
######################################################################
SCRIPT="$(basename $0)"
FIFOFILE="/tmp/${SCRIPT}.fifo"
FTPGROUP="ftpusers"
PREFTPGROUP="preftpusers"
function cleanup ()
{
rm -f ${FIFOFILE}
trap - INT TERM EXIT
}
trap 'cleanup && exit 0' INT TERM EXIT
mkfifo -m 622 ${FIFOFILE} || exit 1
exec 30<> ${FIFOFILE}
( while true
do
while read <&30
do
user="${REPLY}"
groups=( $(groups ${user} 2>/dev/null) )
echo "$(date) ${user}"
[[ -z "${groups[@]}" ]] && continue
if ! grep -xFf <(printf '%s\n' ${groups[@]}) <(printf '%s\n' ${FTPGROUP[@]}) >/dev/null && grep -xFf <(printf '%s\n' ${groups[@]}) <(printf '%s\n' ${PREFTPGROUP[@]}) >/dev/null
then
usermod -g ${FTPGROUP} -s /bin/false ${user}
fi
done
done ) &