Cpanel / SuPHP Part 2 – Fix Ownership Issues

In addition to the correct chmod of files and folders (see part 1), you must ensure that all public_html files and folders have the correct (user and group) ownership.  The following Perl code will eliminate nobody/root ownership.  Place the Perl script into your /home directory and execute it.

#!/usr/bin/perl -w

my @dirs = grep -d,<*>;

foreach my $user (@dirs) {
`chown -R $user:$user $user/public_html/*`;
}

4 Responses to Cpanel / SuPHP Part 2 – Fix Ownership Issues

  1. Tom Egan says:

    Gi Randy

    Tried the above in a .cgi format and received the following error. Can you look at what may be wrong? Thanks Tom

    chown: `cpbackuptmp:cpbackuptmp’: invalid user
    chown: `cpeasyapache:cpeasyapache’: invalid user
    chown: cannot access `lnadmin/public_html/*’: No such file or directory
    chown: `MySQL-install:MySQL-install’: invalid user
    chown: `no:no’: invalid user
    chown: `virtfs:virtfs’: invalid user

  2. Randy says:

    Looks fine… it’s a crude script so it throws those warnings when it skips certain folders in /home. It should have still worked though!

  3. B Ybooha says:

    Place the Perl script into your /home directory and execute it.

    How do you do this?
    Do you save it as a text file? cgi….? Access it from a browser? Via SSH?
    I just don’t know….. Please let me know!

    Thanks for all this by the way It’s solved a mystery…Almost:-)

  4. Mike says:

    I have created a user.cgi file from the code at the top but it says internal error. I have suPHP running and the permission for this file is 755. I placed it in the public_html directory and tried to execute. Any thoughts? Thanks for all the help!