source: trunk/server/doc/cluedump/admof.in.num @ 2053

Last change on this file since 2053 was 37, checked in by jbarnold, 18 years ago
Touched up documentation; moved cluedump info to its own dir
File size: 3.2 KB
Line 
10000 #!/usr/bin/perl
20001 use strict;
30002 
40003 # admof
50004 # Copyright (C) 2006  Jeff Arnold <jbarnold@mit.edu>
60005 #
70006 # This program is free software; you can redistribute it and/or
80007 # modify it under the terms of the GNU General Public License
90008 # as published by the Free Software Foundation; either version 2
100009 # of the License, or (at your option) any later version.
110010 #
120011 # This program is distributed in the hope that it will be useful,
130012 # but WITHOUT ANY WARRANTY; without even the implied warranty of
140013 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
150014 # GNU General Public License for more details.
160015 #
170016 # You should have received a copy of the GNU General Public License
180017 # along with this program; if not, write to the Free Software
190018 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
200019 #
210020 # See /COPYRIGHT in this repository for more information.
220021 
230022 $ENV{PATH} = '';
240023 
250024 my $targetuser;
260025 unless(($targetuser) = ($ARGV[0] =~ /^([\w._-]+)$/)) {
270026   error("Invalid locker name: <$ARGV[0]>.");
280027 }
290028 my $curuser;
300029 unless(($curuser) = ($ARGV[1] =~ /^([\w._-]+)\@ATHENA\.MIT\.EDU$/)) {
310030   error("An internal error has occurred.\nContact scripts\@mit.edu for assistance.");
320031 }
330032 
340033 my $fs = `@fs_path@ 2>/dev/null la /mit/$targetuser/`;
350034 my @fs = split(/\n/, $fs);
360035 
370036 #Access list for . is
380037 #Normal rights:
390038 #  system:scripts-root rlidwka
400039 #  system:anyuser rl
410040 
420041 unless($fs[0] =~ /^Access list for \/mit\/$targetuser\/ is$/ &&
430042        $fs[1] =~ /^Normal rights:$/) {
440043   error("Cannot find locker <$targetuser>.");
450044 }
460045 
470046 if($ARGV[2] && !getpwnam($targetuser)) {
480047   error("Locker <$targetuser> does not have a scripts.mit.edu account.");
490048 }
500049 
510050 for(my $i = 2; $i < @fs; $i++) {
520051   my ($id) = ($fs[$i] =~ /^  ([\w:_-]+) rlidwka$/);
530052   if($id eq "") { next; }
540053   my $group;
550054   if($id eq $curuser) { success(); }
560055   elsif(($group) = ($id =~ /^(system:.+)/)) {
570056     my $mems = `@pts_path@ 2>/dev/null membership $group`;
580057     my @mems = split(/\n/, $mems);
590058 
600059 #Members of system:scripts-root (id: -56104) are:
610060 #  hartmans
620061 #  jbarnold
630062 #  presbrey
640063 #  tabbott
650064 #  hartmans.root
660065 
670066     next if($mems[0] !~ /^Members of $group \(id: \S+\) are:$/);
680067 
690068     if($mems =~ /\s+$curuser\s+/) {
700069    success();
710070     }
720071   }
730072 }
740073 
750074 print <<END;
760075 
770076 ERROR:
780077 It appears as though you are not an administrator of locker <$targetuser>.
790078 In order to be able to su to <$targetuser>, you must have full AFS access
800079 to the root directory of locker <$targetuser>.  Try running the command
810080 fs sa /mit/$targetuser $curuser all
820081 on Athena in order to explicitly grant yourself full AFS access.
830082 Contact scripts\@mit.edu if you are unable to solve the problem.
840083 
850084 END
860085 
870086 exit(1);
880087 
890088 sub error {
900089   print STDERR "\nERROR:\n$_[0]\n\n";
910090   exit(1);
920091 }
930092 
940093 sub success {
950094   print STDERR "\n== SUCCESS ==\nYou are now logged in as user <$targetuser>.\n";
960095   print STDERR "To return to being <$curuser>, type \"exit\".\n\n";
970096   exit(33);
980097 }
Note: See TracBrowser for help on using the repository browser.