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