X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/blobdiff_plain/bc6ad793e5b918984a7ebc16cfe966dc2ae946a5..b22cf8b89f6b5917fe320d703763a1a32346a94e:/incremental/afs_create.pl diff --git a/incremental/afs_create.pl b/incremental/afs_create.pl index 0929fc3b..d453a5f1 100644 --- a/incremental/afs_create.pl +++ b/incremental/afs_create.pl @@ -1,4 +1,4 @@ -#!/afs/athena/contrib/perl/perl +#!/usr/athena/bin/perl # Usage: afs_create locker type cell path quota user group require "/moira/bin/afs_utils.pl"; @@ -6,19 +6,6 @@ require "/moira/bin/afs_utils.pl"; $protodir="/moira/dotfiles"; $quota=1; -%vtypes_ATHENA_MIT_EDU = - ("ACTIVITY", "activity", - "APROJ", "aproj", - "AREF", "aref", - "CONTRIB", "contrib", - "COURSE", "course", - "HOMEDIR", "user", - "PROJECT", "project", - "REF", "ref", - "SW", "sw", - "SYSTEM", "system", - ); - %proc = ("ATHENA.MIT.EDU", 'athena_proc' ); @@ -32,23 +19,27 @@ die "Usage: $0 locker type cell path user group\n" if (@ARGV != 6); $vtype = eval "\$vtypes_$c{$type}"; die "Cannot create $type volumes in $cell\n" unless $vtype; $vname = $vtype . "." . $locker; - -# Find free space -($asrv,$apart) = &afs_find($cell,$type,$quota); -die "Unable to find space to create $vname in $cell\n" unless ($asrv&&$apart); - -# Create volume -system("$vos create $asrv $apart $vname -cell $cell >/dev/null") && - &fatal("Unable to create $vname in $cell"); +$vname =~ s/[^-A-Za-z0-9_.]//g; # strip out illegal characters + +# Find free space/Create volume +$tries = 0; $code = 1; +while ($tries<3 && $code) { + ($asrv,$apart) = &afs_find($cell,$type,$quota,@except); + die "Unable to find space to create $vname in $cell\n" unless ($asrv&&$apart); + $code = system("$vos create $asrv $apart $vname -cell $cell >/dev/null"); + push(@except, $asrv); + $tries++; +} +&fatal("Unable to create $vname in $cell") if ($code); # Too many create errors push(@clean, "$vos remove $asrv $apart $vname -cell $cell >/dev/null"); # Create mountpoint and set quota $path =~ s:^/afs/([^.]):/afs/.\1:; -system("$fs checkb >/dev/null; $fs mkm $path $vname"); +system("$fs checkv >/dev/null; $fs mkm $path $vname"); &fatal("Unable to create $path") if ($?); push(@clean, "$fs rmm $path"); -# Obtain user/group information +# Obtain user/group information (uid >= 0, gid <= 0) $uid = $gid = 0; open(PTS, "$pts ex $user -cell $cell|"); chop($_ = ); @@ -59,7 +50,6 @@ open(PTS, "$pts ex system:$group -cell $cell|"); chop($_ = ); close(PTS); ($gid,$gid,$gid,$gid) = split(/[:,] /, $_) unless ($?); -$gid = 0-$gid; # Dispatch to the cell-specific creation routines eval "&$proc{$cell}"; @@ -76,8 +66,10 @@ chop($_ = ); close(FS); &fatal("Can't get information about $p") if ($?); @tmp = (split(/ /,$_)); -system("$vos release $tmp[$#tmp] -cell $cell >/dev/null") && - &fatal("Can't release $tmp[$#tmp] in cell $cell"); +if ($tmp[$#tmp] !~ /user\../) { + system("$vos release $tmp[$#tmp] -cell $cell >/dev/null") && + &fatal("Can't release $tmp[$#tmp] in cell $cell"); +} &afs_quota_adj($cell,$asrv,$apart,$quota); exit(0); @@ -106,25 +98,29 @@ sub athena_proc # CONTRIB all system:anyuser rl # COURSE all all system:facdev all system:authuser rl # HOMEDIR all + # LEASE all + # ORG all all system:cwisfac all # PROJECT all all # REF all system:anyuser rl # SW all system:swmaint all system:authuser rl # SYSTEM system:administrators all system:anyuser rl + # UROP all all system:facdev all system:authuser rl # # Notes: # 1. All directories also have "system:expunge ld". @acl=("system:expunge ld"); - push(@acl,"system:facdev all") if ($type =~ /^(COURSE)/); + push(@acl,"system:facdev all") if ($type =~ /^(COURSE|UROP)/); push(@acl,"system:swmaint all") if ($type =~ /^(SW)/); + push(@acl,"system:cwisfac all") if ($type =~ /^(ORG)/); push(@acl,"system:administrators all") if ($type =~ /^(SYSTEM)/); push(@acl,"$user all") - if ($uid != 0 && $type =~ /^(ACTIVITY|APROJ|AREF|CONTRIB|COURSE|HOMEDIR|PROJECT|REF|SW)/); + if ($uid != 0 && $type =~ /^(ACTIVITY|APROJ|AREF|CONTRIB|COURSE|HOMEDIR|LEASE|ORG|PROJECT|REF|SW|UROP)/); push(@acl,"system:$group all") - if ($gid != 0 && $type =~ /^(ACTIVITY|APROJ|COURSE|PROJECT)/); - push(@acl,"system:$group rl") if ($gid != -1 && $type =~ /^(AREF)/); + if ($gid != 0 && $type =~ /^(ACTIVITY|APROJ|COURSE|ORG|PROJECT|UROP)/); + push(@acl,"system:$group rl") if ($gid != 0 && $type =~ /^(AREF)/); push(@acl,"system:authuser rl") - if ($type =~ /^(COURSE|SW)/); + if ($type =~ /^(COURSE|SW|UROP)/); push(@acl,"system:anyuser rl") if ($type =~ /^(ACTIVITY|APROJ|CONTRIB|REF|SYSTEM)/); @@ -133,6 +129,23 @@ sub athena_proc warn "$locker: Unable to create OldFiles mountpoint\n" if ($?); } + if ($type =~ /ACTIVITY|APROJ|PROJECT/) { + chown($gid,0,$path) || + die "Unable to set volume ownership\n"; + } elsif ($type =~ /HOMEDIR|UROP/) { + chown($uid,0,$path) || + die "Unable to set volume ownership\n"; + } + + if ($type eq "ORG") { + mkdir("$path/www",0755) || die "Unable to create subdirectories\n"; + system("$fs sa $path @acl system:anyuser rl -clear") && + die "Unable to set acl on www directory\n"; + + system("$fs sa $path @acl system:anyuser l -clear") && + die "Unable to set acl on top-level directory\n"; + } + if ($type eq "HOMEDIR") { die "Unable to get uid for user\n" unless ($uid); @@ -159,9 +172,8 @@ sub athena_proc close(IN); chown($uid,0,"$path/$i"); } - chown($uid,0,$path) && - system("$fs sa $path @acl system:anyuser l -clear") && - die "Unable to set acl on top-level directory\n"; + system("$fs sa $path @acl system:anyuser l -clear") && + die "Unable to set acl on top-level directory\n"; return; }