smeserver-audittools/root/sbin/e-smith/audittools/groups-users

134 lines
3.1 KiB
Plaintext
Raw Permalink Normal View History

#!/bin/bash
#------------------------------------------------------------------------
# The purpose of this tool is to verify correct GID and UID of essential
# groups and users of SME and to display all users, groups, ibays set in
# the collaboration panel of server-manager.
#------------------------------------------------------------------------
##admin
a=`id admin`
a1=`id admin -u`
a2=`id admin -g`
a4=`awk -F: '$1=="admin" { print $1,$3 }' /etc/group`
##Test conditions
if [ $a1 = "101" ] && [ $a2 = "101" ]
then
a3="....Good!!!"
else
a3="....Error!!!"
fi
if [[ -n "$a4" ]]; then
a5="....Good!!!"
else
a5="....Error!!!"
fi
##www
b=`id www`
b1=`id www -u`
b2=`id www -g`
b4=`awk -F: '$1=="www" { print $1,$3 }' /etc/group`
##Test conditions
if [ $b1 = "102" ] && [ $b2 = "102" ]
then
b3="....Good!!!"
else
b3="....Error!!!"
fi
if [[ -n "$b4" ]]; then
b5="....Good!!!"
else
b5="....Error!!!"
fi
##apache
c=`id apache`
c1=`id apache -u`
c2=`id apache -g`
c4=`awk -F: '$1=="apache" { print $1,$3 }' /etc/group`
##Test conditions
if [ $c1 = "102" ] && [ $c2 = "102" ]
then
c3="....Good!!!"
else
c3="....Error!!!"
fi
if [[ -n "$c4" ]]; then
c5="....Good!!!"
else
c5="....Error!!!"
fi
##public
d=`id public`
d1=`id public -u`
d2=`id public -g`
d4=`awk -F: '$1=="public" { print $1,$3 }' /etc/group`
##Test conditions
if [ $d1 = "103" ] && [ $d2 = "103" ]
then
d3="....Good!!!"
else
d3="....Error!!!"
fi
if [[ -n "$d4" ]]; then
d5="....Good!!!"
else
d5="....Error!!!"
fi
##smelog
e=`id smelog`
e1=`id smelog -u`
e2=`id smelog -g`
e4=`awk -F: '$1=="smelog" { print $1,$3 }' /etc/group`
##Test conditions
if [ $e1 = "1002" ] && [ $e2 = "1002" ]
then
e3="....Good!!!"
else
e3="....Error!!!"
fi
if [[ -n "$e4" ]]; then
e5="....Good!!!"
else
e5="....Error!!!"
fi
##display uid/gid
echo "* The user/group 'admin' needs a UID/GID of 101 : " $a3
echo $a
echo "* The group 'admin' needs to be written in /etc/group : " $a4 $a5
echo ""
echo "* The user/group 'www' needs a UID/GID of 102 : " $b3
echo $b
echo "* The group 'www' needs to be written in /etc/group : " $b4 $b5
echo ""
echo "* The user/group 'apache' needs a UID/GID of 102 : " $c3
echo $c
echo "* The group 'apache' needs to be written in /etc/group : " $c4 $c5
echo ""
echo "* The user/group 'public' needs a UID/GID of 103 : " $d3
echo $d
echo "* The group 'public' needs to be written in /etc/group : " $d4 $d5
echo ""
echo "* The user/group 'smelog' needs a UID/GID of 1002 : " $e3
echo $e
echo "* The group 'smelog' needs to be written in /etc/group : " $e4 $e5
echo
##display all users of server-manager
echo "* All users created in the server-manager with their UID/GID"
cat /etc/passwd | grep 'users' |sort| sed "s/:/ /g"| sed "s/x/ /g"
echo ""
##display all groups of server-manager
echo "* All groups created in the server-manager with their GID"
awk -F: '$3== '500' || $3 >= '5000' && $3 < '65534' { print $1,$3,$4 }' /etc/group | sort
echo ""
##display all ibays created
echo "* All ibays created in the server-manager with their UID/GID"
cat /etc/passwd | grep 'ibays' |sort | sed "s/:/ /g"| sed "s/x/ /g"| sed "s|/bin/false| |g"