Diff for /loncom/debugging_tools/move_construction_spaces.pl between versions 1.8 and 1.9

version 1.8, 2012/06/08 13:04:08 version 1.9, 2012/06/08 13:08:13
Line 819  sub move_priv_to_home { Line 819  sub move_priv_to_home {
     if ($uname =~ /^$match_username$/ && $domain =~ /^$match_domain$/) {      if ($uname =~ /^$match_username$/ && $domain =~ /^$match_domain$/) {
         my $source_path="$londocroot/priv/$domain/$uname";          my $source_path="$londocroot/priv/$domain/$uname";
         my $target_path="/home/$uname/public_html";          my $target_path="/home/$uname/public_html";
           my $userpath = &LONCAPA::propath($domain,$uname);
           my ($authtype,$userid,$groupid);
           if (-e "$userpath/passwd") {
               if (open(my $fh, "<$userpath/passwd")) {
                   ($authtype) = split(/:/,<$fh>);
                   close($fh);
               }
           }
         if (!-e "/home/$uname") {          if (!-e "/home/$uname") {
             my (undef,undef,$userid,$groupid) = getpwnam($uname);              (undef,undef,$userid,$groupid) = getpwnam($uname);
             if (mkdir("/home/$uname",0711)) {              if (mkdir("/home/$uname",0711)) {
                 if ($userid ne '' && $groupid ne '') {                  if ($authtype eq 'unix' && $userid ne '' && $groupid ne '') {
                     chown($userid,$groupid,"/home/$uname");                      chown($userid,$groupid,"/home/$uname");
                       if (&www_in_group($uname)) {
                           chmod(0710,"/home/$uname");
                       }
                 }                  }
             } else {              } else {
                 $output = &mt('Failed to create directory [_1] -- not moving [_2].',                  $output = &mt('Failed to create directory [_1] -- not moving [_2].',
Line 835  sub move_priv_to_home { Line 846  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);
                   if ($authtype eq 'unix' && $userid ne '' && $groupid ne '') {
                       if (&www_in_group($uname)) {
                           chown($userid,$groupid,$target_path);
                       }
                   }
                 chmod(02770,$target_path);                  chmod(02770,$target_path);
                 if (-e $target_path && !-e $source_path) {                  if (-e $target_path && !-e $source_path) {
                     $output = &mt('Moved [_1] to [_2].',"'$source_path'","'$target_path'")."\n";                      $output = &mt('Moved [_1] to [_2].',"'$source_path'","'$target_path'")."\n";
Line 850  sub move_priv_to_home { Line 866  sub move_priv_to_home {
     return $output;      return $output;
 }  }
   
   sub www_in_group {
       my ($uname) = @_;
       my $hasuser;
       if (open(PIPE,"/usr/bin/groups www|")) {
           my $memberlist = <PIPE>;
           close(PIPE);
           chomp($memberlist);
           my ($safegroups)=($memberlist=~/:\s*([\s\w]+)$/);
           if ($safegroups =~ /\S/) {
               my @members = split(/\s+/,$safegroups);
               if (grep(/^\Q$uname\E$/,@members)) {
                   $hasuser = 1;
               } else {
                   my @ugrouplist=grep(!/www|$uname/,@members);
                   my $gl=join(',',(@ugrouplist,$uname));
                   if (system('/usr/sbin/usermod','-G',$gl,'www') == 0) {
                       $hasuser = 1;
                   }
               }
           }
       }
       return $hasuser;
   }
   
 sub get_user_selection {  sub get_user_selection {
     my ($defaultrun) = @_;      my ($defaultrun) = @_;
     my $do_action = 0;      my $do_action = 0;

Removed from v.1.8  
changed lines
  Added in v.1.9


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>