version 1.6, 2011/10/30 16:01:20
|
version 1.7, 2011/12/09 03:01:44
|
Line 256 if ($lonusersdir) {
|
Line 256 if ($lonusersdir) {
|
my ($dir,$output); |
my ($dir,$output); |
if (opendir($dir,$lonusersdir)) { |
if (opendir($dir,$lonusersdir)) { |
my @contents = (grep(!/^\.{1,2}$/,readdir($dir))); |
my @contents = (grep(!/^\.{1,2}$/,readdir($dir))); |
|
closedir($dir); |
foreach my $item (@contents) { |
foreach my $item (@contents) { |
if (-d "$lonusersdir/$item") { |
if (-d "$lonusersdir/$item") { |
if ($item =~ /^$match_domain$/) { |
if ($item =~ /^$match_domain$/) { |
Line 303 if ($lonusersdir) {
|
Line 304 if ($lonusersdir) {
|
} |
} |
} |
} |
} |
} |
closedir($dir); |
|
} else { |
} else { |
$output = &mt('Could not open [_1].',"'$lonusersdir'")."\n"; |
$output = &mt('Could not open [_1].',"'$lonusersdir'")."\n"; |
print $output; |
print $output; |
Line 318 if ($londocroot ne '') {
|
Line 318 if ($londocroot ne '') {
|
my ($dir,$domdir); |
my ($dir,$domdir); |
if (opendir($dir,"$londocroot/res")) { |
if (opendir($dir,"$londocroot/res")) { |
my @contents = (grep(!/^\.{1,2}$/,readdir($dir))); |
my @contents = (grep(!/^\.{1,2}$/,readdir($dir))); |
|
closedir($dir); |
foreach my $dom (@contents) { |
foreach my $dom (@contents) { |
if ((grep(/^\Q$dom\E/,@machinedoms)) && (-d "$londocroot/res/$dom")) { |
if ((grep(/^\Q$dom\E/,@machinedoms)) && (-d "$londocroot/res/$dom")) { |
if (opendir($domdir,"$londocroot/res/$dom")) { |
if (opendir($domdir,"$londocroot/res/$dom")) { |
my @unames = (grep(!/^\.{1,2}$/,readdir($domdir))); |
my @unames = (grep(!/^\.{1,2}$/,readdir($domdir))); |
|
closedir($domdir); |
foreach my $uname (@unames) { |
foreach my $uname (@unames) { |
if ($uname =~ /^$match_username$/) { |
if ($uname =~ /^$match_username$/) { |
push(@{$pubusers{$uname}},$dom); |
push(@{$pubusers{$uname}},$dom); |
Line 341 if ($action eq 'undo') {
|
Line 343 if ($action eq 'undo') {
|
my ($dir,$domdir); |
my ($dir,$domdir); |
if (opendir($dir,"$londocroot/priv")) { |
if (opendir($dir,"$londocroot/priv")) { |
my @contents = (grep(!/^\.{1,2}/,readdir($dir))); |
my @contents = (grep(!/^\.{1,2}/,readdir($dir))); |
|
closedir($dir); |
foreach my $dom (@contents) { |
foreach my $dom (@contents) { |
next if (!-d "$londocroot/priv/$dom"); |
next if (!-d "$londocroot/priv/$dom"); |
if (opendir($domdir,"$londocroot/priv/$dom")) { |
if (opendir($domdir,"$londocroot/priv/$dom")) { |
my @unames = (grep(!/^\.{1,2}$/,readdir($domdir))); |
my @unames = (grep(!/^\.{1,2}$/,readdir($domdir))); |
|
closedir($domdir); |
foreach my $uname (@unames) { |
foreach my $uname (@unames) { |
if ($uname =~ /^$match_username$/) { |
if ($uname =~ /^$match_username$/) { |
push(@{$privspaces{$uname}},$dom); |
push(@{$privspaces{$uname}},$dom); |
Line 357 if ($action eq 'undo') {
|
Line 361 if ($action eq 'undo') {
|
} |
} |
foreach my $uname (keys(%privspaces)) { |
foreach my $uname (keys(%privspaces)) { |
if (ref($privspaces{$uname}) eq 'ARRAY') { |
if (ref($privspaces{$uname}) eq 'ARRAY') { |
|
my $output; |
if (@{$privspaces{$uname}} > 1) { |
if (@{$privspaces{$uname}} > 1) { |
my $displaydoms = join(', ',@{$privspaces{$uname}}); |
my $displaydoms = join(', ',@{$privspaces{$uname}}); |
print &mt('Same username used for authors in multiple domains.')."\n". |
print &mt('Same username used for authors in multiple domains.')."\n". |
Line 367 if ($action eq 'undo') {
|
Line 372 if ($action eq 'undo') {
|
my $choice=<STDIN>; |
my $choice=<STDIN>; |
chomp($choice); |
chomp($choice); |
if (grep(/^\Q$choice\E$/,@{$privspaces{$uname}})) { |
if (grep(/^\Q$choice\E$/,@{$privspaces{$uname}})) { |
my $output = &move_priv_to_home($londocroot,$uid,$gid,$uname,$choice); |
$output = &move_priv_to_home($londocroot,$uid,$gid,$uname,$choice); |
print $output; |
|
print $logfh $output; |
|
} else { |
} else { |
print &mt('Invalid choice of domain:')." $choice\n"; |
print &mt('Invalid choice of domain:')." $choice\n"; |
my $output = &mt('Skipping this user: [_1].',"'$uname'")."\n"; |
$output = &mt('Skipping this user: [_1].',"'$uname'")."\n"; |
print $output; |
print $output; |
print $logfh $output; |
print $logfh $output; |
next; |
next; |
} |
} |
} elsif (@{$privspaces{$uname}} == 1) { |
} elsif (@{$privspaces{$uname}} == 1) { |
my $output = &move_priv_to_home($londocroot,$uid,$gid,$uname,$privspaces{$uname}[0]); |
$output = &move_priv_to_home($londocroot,$uid,$gid,$uname,$privspaces{$uname}[0]); |
print $output; |
|
print $logfh $output; |
|
} else { |
} else { |
print &mt('Username [_1] found in [_2] was not within a domain', |
print &mt('Username [_1] found in [_2] was not within a domain', |
"'$uname'","'$londocroot/priv'")."\n"; |
"'$uname'","'$londocroot/priv'")."\n"; |
my $output = &mt('Skipping this user: [_1].',"'$uname'")."\n"; |
$output = &mt('Skipping this user: [_1].',"'$uname'")."\n"; |
print $output; |
} |
print $logfh $output; |
print $output; |
|
print $logfh $output; |
|
} |
|
} |
|
if (-d "$londocroot/priv") { |
|
my $output; |
|
if (opendir(my $dir,"$londocroot/priv")) { |
|
my @doms = grep(!/^\.{1,2}/,readdir($dir)); |
|
closedir($dir); |
|
foreach my $dom (@doms) { |
|
if (opendir(my $domdir,"$londocroot/priv/$dom")) { |
|
my @contents = grep(!/^\.{1,2}/,readdir($domdir)); |
|
closedir($domdir); |
|
if (@contents == 0) { |
|
if (rmdir("$londocroot/priv/$dom")) { |
|
$output = &mt('Removed empty directory: [_1]', |
|
"'$londocroot/priv/$dom'")."\n"; |
|
} else { |
|
$output = &mt('Failed to remove directory: [_1]', |
|
"'$londocroot/priv/$dom'")."\n"; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
my $warning = &mt('WARNING: Access to Construction Spaces in their old locations (i.e., in [_1]) via LON-CAPA with URLs of the form [_2] will not work until the directory at [_3] is moved or deleted.',"'/home/<user>/'","'/priv/<user>/'","'$londocroot/priv/'")."\n"; |
|
if (opendir(my $dir,"$londocroot/priv")) { |
|
my @contents = (grep(!/^\.{1,2}/,readdir($dir))); |
|
closedir($dir); |
|
if (@contents == 0) { |
|
if (rmdir("$londocroot/priv")) { |
|
$output .= &mt('Removed empty directory: [_1]', |
|
"'$londocroot/priv'")."\n"; |
|
} else { |
|
$output .= &mt('Failed to remove directory: [_1]', |
|
"'$londocroot/priv'")."\n". |
|
$warning."\n"; |
|
} |
|
} else { |
|
$output .= $warning."\n". |
|
&mt('The attempt to remove the directory failed, because it is not empty.')."\n"; |
} |
} |
|
} else { |
|
$output .= $warning."\n". |
|
&mt('The attempt to open the directory to see its contents failed, hence no attempt was made to remove it.')."\n"; |
} |
} |
|
print $output; |
|
print $logfh $output; |
} |
} |
&stop_logging($logfh); |
&stop_logging($logfh); |
print "\n".&mt('Done')."\n"; |
print "\n".&mt('Done')."\n"; |
Line 401 my ($dbh,$dbflag);
|
Line 447 my ($dbh,$dbflag);
|
|
|
# Iterate over directories in /home |
# Iterate over directories in /home |
if (opendir(my $dir,"/home")) { |
if (opendir(my $dir,"/home")) { |
my @possibles = grep(!/^\.{1,2}$/,readdir($dir)); |
my @possibles = grep(!/^\.{1,2}$/,readdir($dir)); |
|
closedir($dir); |
foreach my $item (sort(@possibles)) { |
foreach my $item (sort(@possibles)) { |
next if ($item eq 'www'); |
next if ($item eq 'www'); |
if ((-d "/home/$item") && ($item ne '')) { |
if ((-d "/home/$item") && ($item ne '')) { |
Line 526 if (opendir(my $dir,"/home")) {
|
Line 573 if (opendir(my $dir,"/home")) {
|
if (opendir(my $homedir,"/home/$author")) { |
if (opendir(my $homedir,"/home/$author")) { |
my @contents = |
my @contents = |
grep(!/^\.{1,2}$/,readdir($homedir)); |
grep(!/^\.{1,2}$/,readdir($homedir)); |
|
closedir($homedir); |
if (@contents == 0) { |
if (@contents == 0) { |
if (rmdir("/home/$author/")) { |
if (rmdir("/home/$author/")) { |
$output .= &mt('Removed empty directory: [_1]', |
$output .= &mt('Removed empty directory: [_1]', |
Line 651 if (opendir(my $dir,"/home")) {
|
Line 699 if (opendir(my $dir,"/home")) {
|
if (-e $dompath) { |
if (-e $dompath) { |
if (move($source_path,$newpath)) { |
if (move($source_path,$newpath)) { |
chown($uid,$gid,$newpath); |
chown($uid,$gid,$newpath); |
chmod($newpath,0750); |
chmod(0750,$newpath); |
$output = &mt('Moved [_1] to [_2].', |
$output = &mt('Moved [_1] to [_2].', |
"'$source_path'","'$newpath'")."\n"; |
"'$source_path'","'$newpath'")."\n"; |
} else { |
} else { |
Line 787 sub move_priv_to_home {
|
Line 835 sub move_priv_to_home {
|
if (!-e $target_path) { |
if (!-e $target_path) { |
move($source_path,$target_path); |
move($source_path,$target_path); |
chown($uid,$gid,$target_path); |
chown($uid,$gid,$target_path); |
chmod($target_path,2770); |
chmod(0750,$target_path); |
$output = &mt('Moved [_1] to [_2].',"'$source_path'","'$target_path'")."\n"; |
if (-e $target_path && !-e $source_path) { |
|
$output = &mt('Moved [_1] to [_2].',"'$source_path'","'$target_path'")."\n"; |
|
} else { |
|
$output = &mt('Failed to move [_1] to [_2].',"'$source_path'","'$target_path'")."\n"; |
|
} |
} else { |
} else { |
$output = &mt('Directory [_1] already exists -- not moving [_2].', |
$output = &mt('Directory [_1] already exists -- not moving [_2].', |
"'$target_path'","'$source_path'")."\n"; |
"'$target_path'","'$source_path'")."\n"; |
Line 842 sub check_for_restore_files {
|
Line 894 sub check_for_restore_files {
|
my ($londaemons,$author,$domain) = @_; |
my ($londaemons,$author,$domain) = @_; |
if (opendir(my $homedir,"/home/$author")) { |
if (opendir(my $homedir,"/home/$author")) { |
my @contents = grep(!/^\.{1,2}$/,readdir($homedir)); |
my @contents = grep(!/^\.{1,2}$/,readdir($homedir)); |
|
closedir($homedir); |
if (@contents > 0) { |
if (@contents > 0) { |
if (grep(/^restore_\d+\.sh$/,@contents)) { |
if (grep(/^restore_\d+\.sh$/,@contents)) { |
if (!-e "$londaemons/logs/moved_construction_spaces") { |
if (!-e "$londaemons/logs/moved_construction_spaces") { |