File:
[LON-CAPA] /
loncom /
build /
verifymodown.pl
Revision
1.2:
download - view:
text,
annotated -
select for diffs
Thu Dec 6 23:14:33 2001 UTC (22 years, 9 months ago) by
harris41
Branches:
MAIN
CVS tags:
version_1_1_X,
version_1_1_3,
version_1_1_2,
version_1_1_1,
version_1_1_0,
version_1_0_99_3,
version_1_0_99_2,
version_1_0_99_1,
version_1_0_99,
version_1_0_3,
version_1_0_2,
version_1_0_1,
version_1_0_0,
version_0_99_5,
version_0_99_4,
version_0_99_3,
version_0_99_2,
version_0_99_1,
version_0_99_0,
version_0_6_2,
version_0_6,
version_0_5_1,
version_0_5,
version_0_4,
stable_2002_spring,
stable_2002_july,
stable_2002_april,
conference_2003,
STABLE,
HEAD
GPL-ing and seems to fully work for looking at status of file system -Scott
#!/usr/bin/perl
# The LearningOnline Network with CAPA
#
# verifymodown.pl - script to enforce file mode and ownership
#
# YEAR=2001
# 11/17,12/6 Scott Harrison
#
# $Id: verifymodown.pl,v 1.2 2001/12/06 23:14:33 harris41 Exp $
###
my $filename=shift @ARGV;
my $arguments=shift @ARGV;
#print "Filename: $filename\n";
#print "Arguments: $arguments\n";
my ($user)=($arguments=~/\-o (\S+)/);
my ($group)=($arguments=~/\-g (\S+)/);
my ($mode)=($arguments=~/\-m (\S+)/);
my $nofix;
$nofix=1 if $arguments=~/\-N/;
my $currentmode=(stat($filename))[2];
my $currentuser=getpwuid((stat($filename))[4]);
my $currentgroup=getgrgid((stat($filename))[5]);
my $cflag='';
unless (-l $filename) {
$currentmode=sprintf("%.4o",($currentmode&07777));
$cflag.="[MODE IS $currentmode SHOULD BE $mode]" if $mode ne $currentmode;
}
$cflag.="[USER IS $currentuser SHOULD BE $user]" if $user ne $currentuser;
$cflag.="[GROUP IS $currentgroup SHOULD BE $group]"
if $group ne $currentgroup;
if ($nofix) {
print $cflag; exit;
}
if ($cflag) {
`chmod $mode $filename`;
`chown $user:$group $filename`;
}
print <<END if $cflag;
**** WARNING (how did this happen?!) ****
Fixing $filename ownership/permissions mismatch. $cflag\n";
END
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>