Annotation of loncom/build/verifymodown.pl, revision 1.3

1.1       harris41    1: #!/usr/bin/perl
                      2: 
                      3: # The LearningOnline Network with CAPA
                      4: #
                      5: # verifymodown.pl - script to enforce file mode and ownership
                      6: #
                      7: # YEAR=2001
1.2       harris41    8: # 11/17,12/6 Scott Harrison
1.1       harris41    9: #
1.3     ! albertel   10: # $Id: verifymodown.pl,v 1.2 2001/12/06 23:14:33 harris41 Exp $
1.1       harris41   11: ###
                     12: 
                     13: my $filename=shift @ARGV;
                     14: my $arguments=shift @ARGV;
                     15: 
                     16: #print "Filename: $filename\n";
                     17: #print "Arguments: $arguments\n";
                     18: 
                     19: my ($user)=($arguments=~/\-o (\S+)/);
                     20: my ($group)=($arguments=~/\-g (\S+)/);
                     21: my ($mode)=($arguments=~/\-m (\S+)/);
1.2       harris41   22: my $nofix;
                     23: $nofix=1 if $arguments=~/\-N/;
1.1       harris41   24: 
                     25: my $currentmode=(stat($filename))[2];
                     26: my $currentuser=getpwuid((stat($filename))[4]);
                     27: my $currentgroup=getgrgid((stat($filename))[5]);
                     28: 
                     29: my $cflag='';
                     30: 
                     31: unless (-l $filename) {
                     32:     $currentmode=sprintf("%.4o",($currentmode&07777));
                     33:     $cflag.="[MODE IS $currentmode SHOULD BE $mode]" if $mode ne $currentmode;
                     34: }
                     35: 
1.2       harris41   36: $cflag.="[USER IS $currentuser SHOULD BE $user]" if $user ne $currentuser;
                     37: $cflag.="[GROUP IS $currentgroup SHOULD BE $group]" 
                     38:     if $group ne $currentgroup;
                     39: 
                     40: if ($nofix) {
                     41:     print $cflag; exit;
                     42: }
1.1       harris41   43: 
                     44: if ($cflag) {
1.3     ! albertel   45:     system("chmod $mode $filename");
        !            46:     system("chown $user:$group $filename");
1.1       harris41   47: }
                     48: 
1.3     ! albertel   49: if ($cflag) {
        !            50:     print "\nFixing $filename ownership/permissions mismatch. $cflag\n";
        !            51: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>