Index: [Article Count Order] [Thread]

Date:  Thu, 31 Jul 2008 11:59:54 -0600
From:  "Rodrigo Ordonez Licona" <rodrigo (at mark) xnet.com.mx>
Subject:  [coba-e:13666] Re: apache suexec
To:  <coba-e (at mark) bluequartz.org>
Message-Id:  <200807311849.m6VInpS5011718 (at mark) ana.xnet.com.mx>
In-Reply-To:  <094901c8f336$1326c2b0$6601a8c0@OfficeKen>
X-Mail-Count: 13666

Thank for the script ,

But should this option be applied by default to all vsites ?

 

-----Original Message-----
From: Ken Marcus - Precision Web Hosting, Inc.
[mailto:kenmarcus (at mark) precisionweb.net] 
Sent: Jueves, 31 de Julio de 2008 11:52
To: coba-e (at mark) bluequartz.org
Subject: [coba-e:13665] Re: apache suexec


Rodrigo

You might try setting the php_admin_value  open_basedir   for each of your 
sites

E.g.
php_admin_value open_basedir 
/var/lib/php/session:/home/.sites/$preview:/home/sites/$filename:/home/tmp:/
tmp:/usr/bin/pear:/usr/share/pear


The script I use for that  is:

#!/usr/bin/perl
##################################################################
#changes the openbase dir from  /home to their site only.

$tempfile = "/home/sites/home/web/tempfile.txt";
if (-e "$tempfile") { system ("rm $tempfile"); }
#cancel.choicesalmon.com

#/var/lib/php/session:/home/.sites/$preview:/home/tmp:/tmp:/usr/bin/pear:/us
r/share/pear


@locatearray=`ls -1 /home/sites`;
&doit();

sub doit {
 foreach $filename (@locatearray) {
           chomp ($filename);
     if ( ($filename eq "index.html" ) or ($filename eq "home" )  or 
($filename =~ /secure-access/ ) )
          { print "is home or index";}
           else {
          $ls=`ls -la /home/sites/ | grep $filename`;

          print "The ls is $ls";

         ($prev0, $prev1, $prev2, $prev3, $prev4, $prev5) = split(/\//,$ls);
          chomp ($prev3);
          $preview = "$prev2/$prev3";
          print "Preview is $preview\n\n";
          $sitenumber = $prev3;

          $conffile = "/etc/httpd/conf/vhosts/"."$sitenumber".".include";
          print "The conf file is $conffile\n";
          $backupfile = $conffile.".old";
          open (FIL,"$conffile") or die "Can't Open $conffile\n";
          open (FIL2,">$tempfile") or die "Can't Open $tempfile\n";
          while (<FIL>)          {
              $thisline = $_;

              if ( ($thisline =~ /php_admin_value/) and ($_ =~ 
/open_basedir/) )  {
                print FIL2 "#"."$thisline";
              } else {
                print FIL2 "$thisline";
              }
          }
          close (FIL);

         print "Preview is $preview\n\n";


          print FIL2 "php_admin_value open_basedir 
/var/lib/php/session:/home/.sites/$preview:/home/sites/$filename:/home/tmp:/
tmp:/usr/bin/pear:/usr/share/pear\n";
          close (FIL2);
          system ("cp $conffile $backupfile");
          system ("cp $tempfile $conffile ");
          system ("rm $tempfile");

         print "I fixed: $tempfile \n";
         print "I fixed: $filename  \n";
         print "\nIf this looks right, then hit enter to do the next one. 
\n";
         $nothing = <STDIN>;
     }
  }
}

exit;