I'm stumped.

on my www server, I have a number of directories.

This script:
<? echo getcwd; ?>
returns:

/home/myUserName/public_html/myDirectory

Now I have a little script that creates a directory 'mySubDirectory', does some stuff, and drops a file into that directory.

If the subdirectory doesn't exist, I create it:

$dir = "mySubDirectory";
$created=file_exists($dir);
            if (!$created) {
                $blank = umask();
                mkdir ("$dir", 0777);
                chmod ("$dir", 0777);

etc...

This only works, of course , if myDirectory permissions are 777 or something similar.

I'm getting tired of using my FTP program or cpanel to change these permissions, so I thought I'd do a little script to change the cwd permissions before I create the mySubDirectory

I've tried stuff for about an hour; here's a sample:

$holdername= getcwd();
$y=chmod($holdername,0777);

I've tried chdir('..'), chmod on the working directory...lots of stuff.

I'm beat. Time to ask the experts...

    is php running as a different username as the user whose home directory that is in? that could be a problem. since you have cpanel is phpsuexec on or not? try to turn it on if it is off.

      I assume that php is running as root;

      As for
      'phpsuexec on or not? try to turn it on if it is off.'

      need a clue how to do this...??

      I have root privileges on my server, but I kind of stupid about apache. Very stupid, frankly. Overexplaining recommended.

        if php is running as root that is really dangerous. i would bet it runs the same as apache, probably as nobody. in whm if you run the cpanel server, there should be an option to enable phpsuexec. i havent seen the inside of whm as root in a while so im not sure where the option is now.

          As user for php: I'm clueless, but if you know a way to discover, I'll tell you.

          As for suexec, thanks for the direction...it was already enabled, so I guess that wasn't the problem.

          I'm grateful for your prompt reply and ideas.

            Write a Reply...