The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

403 Forbidden with chown script

Discussion in 'General Discussion' started by wobblyboy, Oct 28, 2005.

  1. wobblyboy

    wobblyboy Member

    Joined:
    Sep 27, 2004
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Hey,

    I'm using the modified chownpublichtmls script below to update files in every account in /home. When I run the script, every account gets locked out and receives a 403 Forbidden error.

    Is there any way to avoid the 403 error when I update the files? Is it really neccessary to lock people out when chowning or copying files?

    BTW, I don't know if it matters but I'm running PHP as cgi with phpsuexec.

    Thanks!


    Code:
    #!/usr/bin/perl
    
    BEGIN {
        push(@INC,"/scripts");
    }
    
    require '/scripts/safetybits.pl';
    
    while(@PW=getpwent()) {
            if (-d "$PW[7]/public_html" && -e "/var/cpanel/users/$PW[0]")  {
    		print "Copying and Chowning $PW[0]....";
    		
    		$account = $PW[0];
    		
    		if ($account ne "imsdirec"){
    		system("cp -rf /root/cpanel3-skel/public_html/admin /home/$PW[0]/public_html");
    		system("cp -rf /root/cpanel3-skel/public_html/cncat /home/$PW[0]/public_html");
    		system("cp -rf /root/cpanel3-skel/public_html/shared_files /home/$PW[0]/public_html");
    		#system("cp -rf /root/cpanel3-skel/public_html/.htaccess /home/$PW[0]/public_html");
    		system("cp -rf /root/cpanel3-skel/public_html/download.php /home/$PW[0]/public_html");
    		system("cp -rf /root/cpanel3-skel/public_html/index.php /home/$PW[0]/public_html");
    		print "Copy done...";
    		}
    		
                    safe_recchown($PW[2],$PW[3],"$PW[7]/public_html");
    		print "chown Done\n";
            }
    
    }
    
    
    exec '/scripts/enablefileprotect';
     
  2. dropby23

    dropby23 Well-Known Member

    Joined:
    Jan 16, 2005
    Messages:
    155
    Likes Received:
    0
    Trophy Points:
    16
    re chown the public html directory's like user:nobody

    chown user:nobody /home/user/public_html

    chown -R user:user /home/user/public_html/
     
    #2 dropby23, Oct 29, 2005
    Last edited: Oct 29, 2005
Loading...

Share This Page