security.d/chk_setid

Mon, 18 Feb 2013 19:47:24 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 18 Feb 2013 19:47:24 +0100
changeset 16
37f217a8bcce
parent 14
59e07bba67cc
child 17
65656789da08
permissions
-rw-r--r--

Fixed check mailq on ssmtp systems

5
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
1 #!/bin/bash
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
2 #
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
3 #############################################################################
14
59e07bba67cc Fixed spelling error, updated address
Michiel Broek <mbse@mbse.eu>
parents: 11
diff changeset
4 # Copyright (C) 2005-2012
5
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
5 #
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
6 # Michiel Broek <mbse@mbse.eu>
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
7 # the Netherlands
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
8 #
14
59e07bba67cc Fixed spelling error, updated address
Michiel Broek <mbse@mbse.eu>
parents: 11
diff changeset
9 # This file is part of SlackSecCheckScripts.
5
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
10 #
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
11 # This package is free software; you can redistribute it and/or modify it
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
12 # under the terms of the GNU General Public License as published by the
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
13 # Free Software Foundation; either version 2, or (at your option) any
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
14 # later version.
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
15 #
14
59e07bba67cc Fixed spelling error, updated address
Michiel Broek <mbse@mbse.eu>
parents: 11
diff changeset
16 # SlackSecCheckScripts is distributed in the hope that it will be useful, but
5
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
17 # WITHOUT ANY WARRANTY; without even the implied warranty of
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
19 # General Public License for more details.
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
20 #
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
21 # You should have received a copy of the GNU General Public License
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
22 # along with MBSE BBS; see the file COPYING. If not, write to the Free
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
23 # Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
24 #############################################################################
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
25
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
26 PATH=/sbin:/usr/sbin:/bin:/usr/bin
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
27
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
28 umask 077
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
29 TZ=UTC; export TZ
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
30 LANG=C; export LANG
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
31
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
32 SECUREDIR=`mktemp -d /tmp/_securedir.XXXXXX` || exit 1
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
33
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
34 trap "/bin/rm -rf $SECUREDIR ; exit 0" EXIT INT QUIT PIPE
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
35
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
36 if ! cd "$SECUREDIR"; then
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
37 echo "Can not cd to $SECUREDIR".
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
38 exit 1
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
39 fi
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
40
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
41 backup_dir=/var/cache/sscs
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
42 mkdir -p "$backup_dir"
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
43
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
44 CURR=${backup_dir}/setid.current
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
45 BACK=${backup_dir}/setid.backup
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
46 TMP1=$SECUREDIR/tmp1
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
47 TMP2=$SECUREDIR/tmp2
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
48 TMP3=$SECUREDIR/tmp3
11
a1f9231336f2 Include tmpfs filesystems
Michiel Broek <mbroek@mbse.eu>
parents: 5
diff changeset
49 FSS=$( egrep "^\/dev\/| tmpfs" /etc/mtab | awk '{ print $2 }' )
5
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
50
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
51
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
52 if [ ! -f $CURR ]; then
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
53 # No database, install new database
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
54 find $FSS \( -mount \( -perm -u+s -a ! -type d \) -o \( -perm -g+s -a ! -type d \) \) -print0 | \
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
55 xargs -0 /bin/ls -ld --full-time | sort -k9 > $CURR
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
56 exit
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
57 fi
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
58
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
59 # Database is present, create temp database
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
60 #
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
61 find $FSS \( -mount \( -perm -u+s -a ! -type d \) -o \( -perm -g+s -a ! -type d \) \) -print0 | \
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
62 xargs -0 /bin/ls -ld --full-time | sort -k9 > $TMP1
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
63 changed=0
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
64
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
65 diff $TMP1 $CURR > $TMP2
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
66 if [ -s $TMP2 ]; then
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
67 egrep '>' $TMP2 > $TMP3
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
68 if [ -s $TMP3 ]; then
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
69 printf "\nOld or updated setuid or setgid files:\n"
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
70 cat $TMP3 | tr '>' ' '
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
71 fi
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
72 egrep '<' $TMP2 > $TMP3
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
73 if [ -s $TMP3 ]; then
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
74 printf "\nNew or updated setuid or setgid files:\n"
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
75 cat $TMP3 | tr '<' ' '
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
76 fi
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
77 changed=1
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
78 fi
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
79
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
80
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
81 # If changes were seen, update the database
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
82 #
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
83 if [ "$changed" == "1" ]; then
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
84 cat $CURR > $BACK
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
85 cat $TMP1 > $CURR
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
86 fi
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
87

mercurial