Subversion Repositories DevTools

Rev

Rev 3410 | Rev 5253 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3410 Rev 3413
Line 1... Line 1...
1
#!/usr/bin/perl -w
1
#!/usr/bin/perl -w
2
# nbannon 20050523
2
# nbannon 20050523
3
# chmod 777 /devl/dpkg_archive/*
3
# chmod 0775 /devl/dpkg_archive/*
-
 
4
############################
-
 
5
#
-
 
6
#   Ensure that package directories in dpkg_archive are:
-
 
7
#       chmod 0775      - Not world writable
-
 
8
#       chown buildadm  - Owned by buildadm
-
 
9
#
-
 
10
#   Script should be run as root - so that it can fix file attributes
-
 
11
#
4
 
12
 
5
use File::stat;
13
use File::stat;
6
 
14
 
7
$DIR="/export/devl/dpkg_archive";
15
$DIR="/export/devl/dpkg_archive";
8
chdir($DIR) or die "$0: Could not change to \"$DIR\": $!\n";
16
chdir($DIR) or die "$0: Could not change to \"$DIR\": $!\n";
Line 16... Line 24...
16
 
24
 
17
die "$0: Not run as root\n"
25
die "$0: Not run as root\n"
18
        if ( $> );
26
        if ( $> );
19
 
27
 
20
opendir(DPKGARCHIVE, ".") or die "$0: Could not open \"$DIR\": $!\n";
28
opendir(DPKGARCHIVE, ".") or die "$0: Could not open \"$DIR\": $!\n";
21
LOOP: while (defined($pkg=readdir(DPKGARCHIVE))) {
29
while (defined($pkg=readdir(DPKGARCHIVE))) {
22
   next if ( $pkg eq ".." );
30
    next if ( $pkg eq ".." );
23
   next if ( $pkg eq "." );
31
    next if ( $pkg eq "." );
24
   next if ( $pkg eq "dpkg_archive_list.txt" );
32
    next if ( $pkg eq "dpkg_archive_list.txt" );
25
 
33
 
26
    $sb=lstat($pkg);
34
    $sb=lstat($pkg);
27
    $rwx=$sb->mode & 00777;
35
    $rwx=$sb->mode & 00777;
28
    $uid=$sb->uid;
36
    $uid=$sb->uid;
29
 
37
 
30
    # Rather than change everything every day, change it only if it's wrong
38
    # Rather than change everything every day, change it only if it's wrong
31
    if ($rwx != 00775) {
39
    if ($rwx != 00775) {
32
      system("/usr/bin/logger", "-p", "local0.notice", "-t", $0,
40
        system("/usr/bin/logger", "-p", "local0.notice", "-t", $0,
33
        sprintf("%s/%s: was chmod %04o", $DIR, $pkg, $rwx));
41
               sprintf("%s/%s: was chmod %04o", $DIR, $pkg, $rwx));
34
      printf STDERR ("%s: %s/%s: was chmod %04o\n", $0, $DIR, $pkg, $rwx);
42
        printf STDERR ("%s: %s/%s: was chmod %04o\n", $0, $DIR, $pkg, $rwx);
35
      $rwx=($sb->mode & 07000) | 00775;
43
        $rwx=($sb->mode & 07000) | 00775;
36
      unless (chmod($rwx, $pkg) == 1) {
44
        unless (chmod($rwx, $pkg) == 1) {
37
        printf STDERR "%s: Could not chmod %04o %s/%s: %s\n", $0, $rwx, $DIR, $pkg, $!;
45
            printf STDERR "%s: Could not chmod %04o %s/%s: %s\n", $0, $rwx, $DIR, $pkg, $!;
38
      }
46
        }
39
    }
47
    }
40
 
48
 
41
    if ($uid != $buildadm ) {
49
    if ($uid != $buildadm ) {
42
      system("/usr/bin/logger", "-p", "local0.notice", "-t", $0,
50
        system("/usr/bin/logger", "-p", "local0.notice", "-t", $0,
43
        sprintf("%s/%s: was uid %d", $DIR, $pkg, $uid));
51
               sprintf("%s/%s: was uid %d", $DIR, $pkg, $uid));
44
      printf STDERR ("%s: %s/%s: was uid %d\n", $0, $DIR, $pkg, $uid);
52
        printf STDERR ("%s: %s/%s: was uid %d\n", $0, $DIR, $pkg, $uid);
45
      unless (chown($buildadm, $buildgid, $pkg) == 1) {
53
        unless (chown($buildadm, $buildgid, $pkg) == 1) {
46
        printf STDERR "%s: Could not chown buildadm (%d) %s/%s: %s\n", $0,$uid, $DIR, $pkg, $!;
54
            printf STDERR "%s: Could not chown buildadm (%d) %s/%s: %s\n", $0,$uid, $DIR, $pkg, $!;
-
 
55
        }
47
    }
56
    }
48
  }
-
 
49
}
57
}
50
closedir(DPKGARCHIVE);
58
closedir(DPKGARCHIVE);
51
 
59