Browse Source

Since sh's bulitin echo(1) supports /t and /n there is no reason to

use printf(1) here.  This way there is no possibility of format
string problems and we use a shell builtin instead of an external
command.
OPENBSD_2_8
millert 24 years ago
parent
commit
95c109f653
1 changed files with 52 additions and 52 deletions
  1. +52
    -52
      src/etc/security

+ 52
- 52
src/etc/security View File

@ -1,6 +1,6 @@
#!/bin/sh - #!/bin/sh -
# #
# $OpenBSD: security,v 1.40 2000/10/18 16:45:27 hugh Exp $
# $OpenBSD: security,v 1.41 2000/10/20 16:27:16 millert Exp $
# from: @(#)security 8.1 (Berkeley) 6/9/93 # from: @(#)security 8.1 (Berkeley) 6/9/93
# #
@ -17,7 +17,7 @@ LIST=$DIR/_secure5
OUTPUT=$DIR/_secure6 OUTPUT=$DIR/_secure6
if ! mkdir $DIR ; then if ! mkdir $DIR ; then
printf "tmp directory %s already exists, looks like:\n" $DIR
echo "tmp directory ${DIR} already exists, looks like:"
ls -alqF $DIR ls -alqF $DIR
exit 1 exit 1
fi fi
@ -60,20 +60,20 @@ awk -F: '{
printf("Login %s has a negative group ID.\n", $1); printf("Login %s has a negative group ID.\n", $1);
}' < $MP > $OUTPUT }' < $MP > $OUTPUT
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "\nChecking the %s file:\n" "$MP"
echo "\nChecking the ${MP} file:"
cat $OUTPUT cat $OUTPUT
fi fi
awk -F: '{ print $1 }' $MP | sort | uniq -d > $OUTPUT awk -F: '{ print $1 }' $MP | sort | uniq -d > $OUTPUT
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "\n%s has duplicate user names.\n" "$MP"
echo "\n${MP} has duplicate user names."
column $OUTPUT column $OUTPUT
fi fi
awk -F: '{ print $1 " " $3 }' $MP | sort -n +1 | tee $TMP1 | awk -F: '{ print $1 " " $3 }' $MP | sort -n +1 | tee $TMP1 |
uniq -d -f 1 | awk '{ print $2 }' > $TMP2 uniq -d -f 1 | awk '{ print $2 }' > $TMP2
if [ -s $TMP2 ] ; then if [ -s $TMP2 ] ; then
printf "\n%s has duplicate user ID's.\n" "$MP"
echo "\n${MP} has duplicate user ID's."
while read uid; do while read uid; do
grep -w $uid $TMP1 grep -w $uid $TMP1
done < $TMP2 | column done < $TMP2 | column
@ -120,13 +120,13 @@ awk -F: '{
printf("Login %s has a negative group ID.\n", $1); printf("Login %s has a negative group ID.\n", $1);
}' < $GRP > $OUTPUT }' < $GRP > $OUTPUT
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "\nChecking the %s file:\n" "$GRP"
echo "\nChecking the ${GRP} file:"
cat $OUTPUT cat $OUTPUT
fi fi
awk -F: '{ print $1 }' $GRP | sort | uniq -d > $OUTPUT awk -F: '{ print $1 }' $GRP | sort | uniq -d > $OUTPUT
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "\n%s has duplicate group names.\n" "$GRP"
echo "\n${GRP} has duplicate group names."
column $OUTPUT column $OUTPUT
fi fi
@ -173,12 +173,12 @@ end-of-csh
fi fi
done done
if [ $umaskset = "no" -o -s $OUTPUT ] ; then if [ $umaskset = "no" -o -s $OUTPUT ] ; then
printf "\nChecking root csh paths, umask values:\n%s\n" "$list"
echo "\nChecking root csh paths, umask values:\n${list}"
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
cat $OUTPUT cat $OUTPUT
fi fi
if [ $umaskset = "no" ] ; then if [ $umaskset = "no" ] ; then
printf "\nRoot csh startup files do not set the umask.\n"
echo "\nRoot csh startup files do not set the umask."
fi fi
fi fi
@ -227,12 +227,12 @@ end-of-sh
fi fi
done done
if [ $umaskset = "no" -o -s $OUTPUT ] ; then if [ $umaskset = "no" -o -s $OUTPUT ] ; then
printf "\nChecking root sh paths, umask values:\n%s\n" "$list"
echo "\nChecking root sh paths, umask values:\n${list}"
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
cat $OUTPUT cat $OUTPUT
fi fi
if [ $umaskset = "no" ] ; then if [ $umaskset = "no" ] ; then
printf "\nRoot sh startup files do not set the umask.\n"
echo "\nRoot sh startup files do not set the umask."
fi fi
fi fi
@ -279,7 +279,7 @@ end-of-sh
done done
) )
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "\nChecking root ksh paths, umask values:\n%s\n" "$list"
echo "\nChecking root ksh paths, umask values:\n${list}"
cat $OUTPUT cat $OUTPUT
fi fi
@ -287,17 +287,17 @@ fi
if egrep root /etc/ftpusers > /dev/null ; then if egrep root /etc/ftpusers > /dev/null ; then
: :
else else
printf "\nRoot not listed in /etc/ftpusers file.\n"
echo "\nRoot not listed in /etc/ftpusers file."
fi fi
if egrep uucp /etc/ftpusers > /dev/null ; then if egrep uucp /etc/ftpusers > /dev/null ; then
: :
else else
printf "\nUucp not listed in /etc/ftpusers file.\n"
echo "\nUucp not listed in /etc/ftpusers file."
fi fi
# Uudecode should not be in the /etc/mail/aliases file. # Uudecode should not be in the /etc/mail/aliases file.
if egrep 'uudecode|decode' /etc/mail/aliases; then if egrep 'uudecode|decode' /etc/mail/aliases; then
printf "\nThere is an entry for uudecode in the /etc/mail/aliases file.\n"
echo "\nThere is an entry for uudecode in the /etc/mail/aliases file."
fi fi
# Files that should not have + signs. # Files that should not have + signs.
@ -324,12 +324,12 @@ while read uid homedir; do
# Root owned .rhosts/.shosts files are ok. # Root owned .rhosts/.shosts files are ok.
if [ -s ${homedir}/$j -a ! -O ${homedir}/$j ] ; then if [ -s ${homedir}/$j -a ! -O ${homedir}/$j ] ; then
rhost=`ls -ldgT ${homedir}/$j` rhost=`ls -ldgT ${homedir}/$j`
printf "%s: %s\n" "$uid" "$rhost"
echo "${uid}: ${rhost}"
fi fi
done done
done > $OUTPUT done > $OUTPUT
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "\nChecking for special users with .rhosts/.shosts files.\n"
echo "\nChecking for special users with .rhosts/.shosts files."
cat $OUTPUT cat $OUTPUT
fi fi
@ -348,7 +348,7 @@ while read uid homedir; do
done done
done > $OUTPUT done > $OUTPUT
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "\nChecking .rhosts/.shosts files syntax.\n"
echo "\nChecking .rhosts/.shosts files syntax."
cat $OUTPUT cat $OUTPUT
fi fi
@ -358,7 +358,7 @@ awk -F: '/^[^+-]/ { print $1 " " $6 }' /etc/passwd | \
while read uid homedir; do while read uid homedir; do
if [ -d ${homedir}/ ] ; then if [ -d ${homedir}/ ] ; then
file=`ls -ldgT ${homedir}` file=`ls -ldgT ${homedir}`
printf "%s %s\n" "$uid" "$file"
echo "${uid} ${file}"
fi fi
done | done |
awk '$1 != $4 && $4 != "root" \ awk '$1 != $4 && $4 != "root" \
@ -368,7 +368,7 @@ awk '$1 != $4 && $4 != "root" \
$2 ~ /^-.......w/ \ $2 ~ /^-.......w/ \
{ print "user " $1 " home directory is other writeable" }' > $OUTPUT { print "user " $1 " home directory is other writeable" }' > $OUTPUT
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "\nChecking home directories.\n"
echo "\nChecking home directories."
cat $OUTPUT cat $OUTPUT
fi fi
@ -379,7 +379,7 @@ while read uid homedir; do
for f in $list ; do for f in $list ; do
file=${homedir}/${f} file=${homedir}/${f}
if [ -f $file ] ; then if [ -f $file ] ; then
printf "%s %s %s\n" "$uid" "$f" "`ls -ldgT $file`"
echo "${uid} ${f} `ls -ldgT ${file}`"
fi fi
done done
done | done |
@ -405,7 +405,7 @@ while read uid homedir; do
for f in $list ; do for f in $list ; do
file=${homedir}/${f} file=${homedir}/${f}
if [ -f $file ] ; then if [ -f $file ] ; then
printf "%s %s %s\n" "$uid" "$f" "`ls -ldgT $file`"
echo "${uid} ${f} `ls -ldgT ${file}`"
fi fi
done done
done | done |
@ -416,7 +416,7 @@ awk '$1 != $5 && $5 != "root" \
$3 ~ /^-.......w/ \ $3 ~ /^-.......w/ \
{ print "user " $1 " " $2 " file is other writeable" }' >> $OUTPUT { print "user " $1 " " $2 " file is other writeable" }' >> $OUTPUT
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "\nChecking dot files.\n"
echo "\nChecking dot files."
cat $OUTPUT cat $OUTPUT
fi fi
@ -427,7 +427,7 @@ awk '$3 != $9 \
$1 != "-rw-------" \ $1 != "-rw-------" \
{ print "user " $9 " mailbox is " $1 ", group " $4 }' > $OUTPUT { print "user " $9 " mailbox is " $1 ", group " $4 }' > $OUTPUT
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "\nChecking mailbox ownership.\n"
echo "\nChecking mailbox ownership."
cat $OUTPUT cat $OUTPUT
fi fi
@ -449,7 +449,7 @@ if [ -s /etc/exports ] ; then
print "File system " $1 " globally exported, read-write." print "File system " $1 " globally exported, read-write."
}' < /etc/exports > $OUTPUT }' < /etc/exports > $OUTPUT
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "\nChecking for globally exported file systems.\n"
echo "\nChecking for globally exported file systems."
cat $OUTPUT cat $OUTPUT
fi fi
fi fi
@ -464,10 +464,10 @@ pending="\nChecking setuid/setgid files and devices:\n"
# Display any errors that occurred during system file walk. # Display any errors that occurred during system file walk.
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "%sSetuid/device find errors:\n" "$pending"
echo "${pending}Setuid/device find errors:"
pending= pending=
cat $OUTPUT cat $OUTPUT
printf "\n"
echo ""
fi fi
# Display any changes in the setuid/setgid file list. # Display any changes in the setuid/setgid file list.
@ -475,7 +475,7 @@ egrep -v '^[bc]' $LIST > $TMP1
if [ -s $TMP1 ] ; then if [ -s $TMP1 ] ; then
# Check to make sure uudecode isn't setuid. # Check to make sure uudecode isn't setuid.
if grep -w uudecode $TMP1 > /dev/null ; then if grep -w uudecode $TMP1 > /dev/null ; then
printf "%s\nUudecode is setuid.\n" "$pending"
echo "${pending}\nUudecode is setuid."
pending= pending=
fi fi
@ -489,37 +489,37 @@ if [ -s $TMP1 ] ; then
> $TMP2 > $TMP2
join -110 -210 -v2 $CUR $TMP1 > $OUTPUT join -110 -210 -v2 $CUR $TMP1 > $OUTPUT
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "%sSetuid additions:\n" "$pending"
echo "${pending}Setuid additions:"
pending= pending=
tee -a $TMP2 < $OUTPUT tee -a $TMP2 < $OUTPUT
printf "\n"
echo ""
fi fi
join -110 -210 -v1 $CUR $TMP1 > $OUTPUT join -110 -210 -v1 $CUR $TMP1 > $OUTPUT
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "%sSetuid deletions:\n" "$pending"
echo "${pending}Setuid deletions:"
pending= pending=
tee -a $TMP2 < $OUTPUT tee -a $TMP2 < $OUTPUT
printf "\n"
echo ""
fi fi
sort +9 $TMP2 $CUR $TMP1 | \ sort +9 $TMP2 $CUR $TMP1 | \
sed -e 's/[ ][ ]*/ /g' | uniq -u > $OUTPUT sed -e 's/[ ][ ]*/ /g' | uniq -u > $OUTPUT
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "%sSetuid changes:\n" "$pending"
echo "${pending}Setuid changes:"
pending= pending=
column -t $OUTPUT column -t $OUTPUT
printf "\n"
echo ""
fi fi
cp $CUR $BACK cp $CUR $BACK
cp $TMP1 $CUR cp $TMP1 $CUR
fi fi
else else
printf "%sSetuid additions:\n" "$pending"
echo "${pending}Setuid additions:"
pending= pending=
column -t $TMP1 column -t $TMP1
printf "\n"
echo ""
cp $TMP1 $CUR cp $TMP1 $CUR
fi fi
fi fi
@ -537,9 +537,9 @@ awk '$3 != "root" || $4 != "operator" || $1 !~ /.rw-r-----/ \
{ printf("Disk %s is user %s, group %s, permissions %s.\n", \ { printf("Disk %s is user %s, group %s, permissions %s.\n", \
$11, $3, $4, $1); }' < $TMP1 > $OUTPUT $11, $3, $4, $1); }' < $TMP1 > $OUTPUT
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "\nChecking disk ownership and permissions.\n"
echo "\nChecking disk ownership and permissions."
cat $OUTPUT cat $OUTPUT
printf "\n"
echo ""
fi fi
# Display any changes in the device file list. # Display any changes in the device file list.
@ -555,16 +555,16 @@ if [ -s $TMP1 ] ; then
> $TMP2 > $TMP2
join -111 -211 -v2 $CUR $TMP1 > $OUTPUT join -111 -211 -v2 $CUR $TMP1 > $OUTPUT
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "Device additions:\n"
echo "Device additions:"
tee -a $TMP2 < $OUTPUT tee -a $TMP2 < $OUTPUT
printf "\n"
echo ""
fi fi
join -111 -211 -v1 $CUR $TMP1 > $OUTPUT join -111 -211 -v1 $CUR $TMP1 > $OUTPUT
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "Device deletions:\n"
echo "Device deletions:"
tee -a $TMP2 < $OUTPUT tee -a $TMP2 < $OUTPUT
printf "\n"
echo ""
fi fi
# Report any block device change. Ignore character # Report any block device change. Ignore character
@ -575,18 +575,18 @@ if [ -s $TMP1 ] ; then
sed -e 's/[ ][ ]*/ /g' | \ sed -e 's/[ ][ ]*/ /g' | \
uniq -u > $OUTPUT uniq -u > $OUTPUT
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "Block device changes:\n"
echo "Block device changes:"
column -t $OUTPUT column -t $OUTPUT
printf "\n"
echo ""
fi fi
cp $CUR $BACK cp $CUR $BACK
cp $TMP1 $CUR cp $TMP1 $CUR
fi fi
else else
printf "Device additions:\n"
echo "Device additions:"
column -t $TMP1 column -t $TMP1
printf "\n"
echo ""
cp $TMP1 $CUR cp $TMP1 $CUR
fi fi
fi fi
@ -608,9 +608,9 @@ if [ -d /etc/mtree ] ; then
cd /etc/mtree cd /etc/mtree
mtree -e -p / -f /etc/mtree/special > $OUTPUT mtree -e -p / -f /etc/mtree/special > $OUTPUT
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "\nChecking special files and directories.\n"
printf "Output format is:\n\tfilename:\n"
printf "\t\tcriteria (shouldbe, reallyis)\n"
echo "\nChecking special files and directories."
echo "Output format is:\n\tfilename:"
echo "\t\tcriteria (shouldbe, reallyis)"
cat $OUTPUT cat $OUTPUT
fi fi
@ -620,12 +620,12 @@ if [ -d /etc/mtree ] ; then
tree=`sed -n -e '3s/.* //p' -e 3q $file` tree=`sed -n -e '3s/.* //p' -e 3q $file`
mtree -f $file -p $tree > $TMP1 mtree -f $file -p $tree > $TMP1
if [ -s $TMP1 ] ; then if [ -s $TMP1 ] ; then
printf "\nChecking %s:\n" "$tree" >> $OUTPUT
echo "\nChecking ${tree}:" >> $OUTPUT
cat $TMP1 >> $OUTPUT cat $TMP1 >> $OUTPUT
fi fi
done done
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "\nChecking system binaries:\n"
echo "\nChecking system binaries:"
cat $OUTPUT cat $OUTPUT
fi fi
else else
@ -646,7 +646,7 @@ if [ -s /etc/changelist ] ; then
if [ -s $CUR ] ; then if [ -s $CUR ] ; then
diff $CUR $file > $OUTPUT diff $CUR $file > $OUTPUT
if [ -s $OUTPUT ] ; then if [ -s $OUTPUT ] ; then
printf "\n======\n%s diffs (OLD < > NEW)\n======\n" $file
echo "\n======\n${file} diffs (OLD < > NEW)\n======"
cat $OUTPUT cat $OUTPUT
cp -p $CUR $BACK cp -p $CUR $BACK
cp -p $file $CUR cp -p $file $CUR


Loading…
Cancel
Save