5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Check :include: aliases (in files configured in sendmail.cf) and .forward
24 # files to make sure the files and their parent directory paths all have
25 # proper permissions. And check the master alias file(s) too.
27 # See http://www.sendmail.org/vendor/sun/migration.html#Security for details.
29 # Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
34 # Check the group- and world-writable bits on the given file.
37 case "`ls -Lldn $1`" in
39 echo $2: $1 is group and world writable
42 echo $2: $1 is world writable
45 echo $2: $1 is group writable
50 # Break down the given file name into its components, and call analyze with
51 # each of them. E.g., an argument of /usr/local/aliases/foo.list would call
52 # analyze in turn with arguments:
53 # * /usr/local/aliases/foo.list
54 # * /usr/local/aliases
61 n = split($0, parts, "/");
62 for (i = n; i >= 2; i--){
64 for (j = 2; j <= i; j++){
65 string = sprintf("%s/%s", string, parts[j]);
75 config
=/etc
/mail
/sendmail.cf
78 afl1
=`grep "^OA" $config | sed 's/^OA//' | sed 's/,/ /g' | sed 's/.*://'`
79 afl2
=`grep "^O AliasFile=" $config | sed 's/^O AliasFile=//' | \
80 sed 's/,/ /g' | sed 's/.*://'`
82 # These should be OK themselves, but other packages may have screwed up the
83 # permissions on /etc or /etc/mail . And best to check in case non-standard
84 # alias paths are used.
86 break_down
$afl1 $afl2
88 # Find all valid :include: files used in alias files configured in sendmail.cf
90 for i
in `sed 's/^[#].*$//' $afl1 $afl2 | \
92 sed 's/.*:include://' | \
98 # Check .forward files as well. If the argument "ALL" is given, do it for
99 # everyone. If no argument to the script is given, just do it for the current
100 # user. O/w, do it for all arguments.
102 if [ $# -eq 0 ] ; then
104 elif [ $1 = "ALL" ] ; then
110 for i
in `getent passwd $arg | nawk -F: '{print $6}'`
112 if [ -f $i/.forward
] ; then
113 break_down
$i/.forward
117 $bogus_dirs ||
echo "No unsafe directories found."