- Timestamp:
- Oct 6, 2007, 8:42:50 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/common/oursrc/accountadm/admof.in
r323 r450 38 38 } 39 39 40 my $uid = getpwnam $targetuser; 41 if(defined $uid && $uid <= 1000) { 42 error(); 40 my (undef, undef, $uid, undef, undef, undef, undef, $home, undef, undef) 41 = getpwnam $targetuser; 42 if(defined $uid) { 43 error() if ($uid <= 1000); 44 } else { 45 $home = "/mit/$targetuser"; 43 46 } 44 47 45 my $fs = `@fs_path@ 2>/dev/null la /mit/$targetuser/`; 46 my @fs = split(/\n/, $fs); 48 my $cell; 49 unless(open WHICHCELL, '-|') { 50 close STDERR; 51 exec '@fs_path@', 'whichcell', '-path', $home; 52 die; 53 } 54 55 unless(($cell) = (<WHICHCELL> =~ /^File \Q$home\E lives in cell '(.*)'$/)) { 56 error("Cannot find locker <$targetuser>."); 57 } 58 close WHICHCELL; 59 60 open LISTACL, '-|', '@fs_path@', 'listacl', '-path', $home; 47 61 48 62 #Access list for . is … … 51 65 # system:anyuser rl 52 66 53 unless( $fs[0] =~ /^Access list for \/mit\/$targetuser\/ is$/&&54 $fs[1] =~ /^Normal rights:$/) {67 unless(<LISTACL> eq "Access list for $home is\n" && 68 <LISTACL> eq "Normal rights:\n") { 55 69 error("Cannot find locker <$targetuser>."); 56 70 } 57 71 58 if($ARGV[2] && ! getpwnam($targetuser)) {72 if($ARGV[2] && !defined $uid) { 59 73 error("Locker <$targetuser> does not have a scripts.mit.edu account."); 60 74 } 61 75 62 for(my $i = 2; $i < @fs; $i++) { 63 my ($id) = ($fs[$i] =~ /^ ([\w:_\.-]+) rlidwka$/); 64 if($id eq "") { next; } 65 my $group; 66 if($id eq $curuser) { success(); } 67 elsif(($group) = ($id =~ /^(system:.+)/)) { 68 my $mems = `@pts_path@ 2>/dev/null membership $group`; 69 my @mems = split(/\n/, $mems); 76 while(<LISTACL>) { 77 last unless /^ /; 78 my ($name) = /^ ([\w:_.-]+) \w*a\w*$/ or next; 79 if($name eq $curuser) { success(); } 80 elsif($name =~ /:/) { 81 unless(open MEMBERSHIP, '-|') { 82 close STDERR; 83 exec '@pts_path@', 'membership', '-nameorid', $name, '-cell', $cell; 84 die; 85 } 70 86 71 87 #Members of system:scripts-root (id: -56104) are: … … 76 92 # hartmans.root 77 93 78 next if($mems[0] !~ /^Members of $group \(id: \S+\) are:$/); 79 80 if($mems =~ /\s+\Q$curuser\E\s+/) { 81 success(); 94 next unless(<MEMBERSHIP> =~ /^Members of \Q$name\E \(id: \S+\) are:$/); 95 while(<MEMBERSHIP>) { 96 success() if($_ eq " $curuser\n"); 82 97 } 98 close MEMBERSHIP; 83 99 } 84 100 }
Note: See TracChangeset
for help on using the changeset viewer.