security.d/chk_homespace

Wed, 14 Jan 2009 21:12:35 +0100

author
Mercurial Repos
date
Wed, 14 Jan 2009 21:12:35 +0100
changeset 5
fe3130d22800
child 14
59e07bba67cc
permissions
-rw-r--r--

Conversion from CVS

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 # $Id$
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
4 #
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
5 #############################################################################
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
6 # Copyright (C) 2005
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
7 #
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
8 # Michiel Broek <mbse@mbse.dds.nl>
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
9 # Beekmansbos 10
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
10 # 1971 BV IJmuiden
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
11 # the Netherlands
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
12 #
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
13 # This file is part of SlackSecCheckSripts.
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
14 #
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
15 # This package is free software; you can redistribute it and/or modify it
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
16 # under the terms of the GNU General Public License as published by the
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
17 # Free Software Foundation; either version 2, or (at your option) any
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
18 # later version.
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
19 #
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
20 # SlackSecCheckSripts is distributed in the hope that it will be useful, but
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
21 # WITHOUT ANY WARRANTY; without even the implied warranty of
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
23 # General Public License for more details.
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
24 #
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
25 # You should have received a copy of the GNU General Public License
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
26 # along with MBSE BBS; see the file COPYING. If not, write to the Free
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
27 # Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
28 #############################################################################
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
29
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
30
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
31 PATH=/sbin:/usr/sbin:/bin:/usr/bin
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
32
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
33 umask 077
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
34 TZ=UTC; export TZ
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
35 MP=/etc/passwd
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
36 LANG=C; export LANG
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
37
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
38 SECUREDIR=`mktemp -d /tmp/_securedir.XXXXXX` || exit 1
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
39
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
40 trap "/bin/rm -rf $SECUREDIR ; exit 0" EXIT INT QUIT PIPE
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
41
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
42 if ! cd "$SECUREDIR"; then
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
43 echo "Can not cd to $SECUREDIR".
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
44 exit 1
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
45 fi
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
46
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
47 MPBYPATH=secure1.$$
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
48 OUTPUT=secure2.$$
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
49
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
50
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
51 # These are used several times.
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
52 #
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
53 awk -F: '{ print $1 " " $3 " " $6 }' $MP > $MPBYPATH
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
54
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
55
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
56 while read name uid homedir; do
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
57 if [ -d ${homedir}/ ] && [ "`expr $uid \>= 1000`" == "1" ]; then
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
58 USAGE=`du -s --block-size=1048576 -h $homedir | cut -f 1`
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
59 SPACE=`df -khTP $homedir | tail -n 1 | awk '{ print $3 }'`
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
60 printf -- "%-16s %6s %6s $homedir\n" $name $USAGE $SPACE
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
61 fi
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
62 done < $MPBYPATH > $OUTPUT
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
63 if [ -s $OUTPUT ] ; then
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
64 printf -- "\n Diskspace used by users.\n\n"
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
65 printf -- "Username used size homedirectory\n"
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
66 printf -- "---------------- ------ ------ -------------\n"
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
67 cat $OUTPUT
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
68 fi
fe3130d22800 Conversion from CVS
Mercurial Repos
parents:
diff changeset
69

mercurial