xref: /freebsd/usr.sbin/periodic/etc/security/100.chksetuid (revision aa48259f337100e79933d660fec8856371f761ed)
181ea85a8SBrad Davis#!/bin/sh -
281ea85a8SBrad Davis#
381ea85a8SBrad Davis# Copyright (c) 2001  The FreeBSD Project
481ea85a8SBrad Davis# All rights reserved.
581ea85a8SBrad Davis#
681ea85a8SBrad Davis# Redistribution and use in source and binary forms, with or without
781ea85a8SBrad Davis# modification, are permitted provided that the following conditions
881ea85a8SBrad Davis# are met:
981ea85a8SBrad Davis# 1. Redistributions of source code must retain the above copyright
1081ea85a8SBrad Davis#    notice, this list of conditions and the following disclaimer.
1181ea85a8SBrad Davis# 2. Redistributions in binary form must reproduce the above copyright
1281ea85a8SBrad Davis#    notice, this list of conditions and the following disclaimer in the
1381ea85a8SBrad Davis#    documentation and/or other materials provided with the distribution.
1481ea85a8SBrad Davis#
1581ea85a8SBrad Davis# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1681ea85a8SBrad Davis# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1781ea85a8SBrad Davis# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1881ea85a8SBrad Davis# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1981ea85a8SBrad Davis# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2081ea85a8SBrad Davis# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2181ea85a8SBrad Davis# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2281ea85a8SBrad Davis# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2381ea85a8SBrad Davis# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2481ea85a8SBrad Davis# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2581ea85a8SBrad Davis# SUCH DAMAGE.
2681ea85a8SBrad Davis#
2781ea85a8SBrad Davis#
2881ea85a8SBrad Davis
2981ea85a8SBrad Davis# If there is a global system configuration file, suck it in.
3081ea85a8SBrad Davis#
3181ea85a8SBrad Davisif [ -r /etc/defaults/periodic.conf ]
3281ea85a8SBrad Davisthen
3381ea85a8SBrad Davis    . /etc/defaults/periodic.conf
3481ea85a8SBrad Davis    source_periodic_confs
3581ea85a8SBrad Davisfi
3681ea85a8SBrad Davis
3781ea85a8SBrad Davis. /etc/periodic/security/security.functions
3881ea85a8SBrad Davis
3981ea85a8SBrad Davisrc=0
4081ea85a8SBrad Davis
4181ea85a8SBrad Davisif check_yesno_period security_status_chksetuid_enable
4281ea85a8SBrad Davisthen
4381ea85a8SBrad Davis	echo ""
4481ea85a8SBrad Davis	echo 'Checking setuid files and devices:'
4581ea85a8SBrad Davis	IFS=$'\n'	# Don't split mount points with spaces or tabs
4681ea85a8SBrad Davis	MP=`mount -t ufs,zfs | awk '
4781ea85a8SBrad Davis		$0 !~ /no(suid|exec)/ {
4881ea85a8SBrad Davis			sub(/^.* on \//, "/");
4981ea85a8SBrad Davis			sub(/ \(.*\)/, "");
5081ea85a8SBrad Davis			print $0
5181ea85a8SBrad Davis		}'`
5281ea85a8SBrad Davis	find -sx $MP /dev/null \( ! -fstype local \) -prune -o -type f \
5381ea85a8SBrad Davis	    \( -perm -u+x -or -perm -g+x -or -perm -o+x \) \
54*d2b4753fSMichael Osipov	    \( -perm -u+s -or -perm -g+s \) -exec ls -lid -D "%FT%T" \{\} \+ |
5581ea85a8SBrad Davis	check_diff setuid - "${host} setuid diffs:"
5681ea85a8SBrad Davis	rc=$?
5781ea85a8SBrad Davisfi
5881ea85a8SBrad Davis
5981ea85a8SBrad Davisexit $rc
60