Mkdir runs under wrong user (dhapache)


#1

I’m using a script that uploads files, creating directories if necessary. The script uses mkdir to create directories. When the it creates a new directory, the directory gets dhapache as owner rather than my account. And because of this, the script can not create subdirectories in that directory.

If I create the directories myself, the upload works but the file gets dhapache as the owner, so I can’t delete it (at least, via FTP).

Obviously, the upload script (or mkdir) is running as dhapache rather than as my username, but how do I solve this so that I have ownership over the files and directories?

Thanks,
Kent


#2

I’m guessing this is a PHP script. I’m also guessing that in your Domain, you have PHP not set to run as CGI, which means it runs as the Apache user, and not your own. Try setting your domain to run as CGI.

http://wiki.dreamhost.com/index.php/KB_/Web_Programming/_CGI,PHP&Databases/_PHP

-Scott


#3

Scott,

You are correct that it’s PHP. But according to the control panel, PHP is running as CGI…

Kent


#4

What does phpinfo show?

Put the following lines in a file:

<?php phpinfo(); ?>

Save the file with a .php extension (ex: phpinfo.php), upload the file to a web server, and then view it with a conventional web browser


#5

I’m not exactly sure what I’m looking for in the phpinfo output… Here’s the first section:

[quote]System Linux lei 2.4.29-grsec+w+fhs6b+gr0501+nfs+a32+++p4+sata+c4+gr2b-v6.189 #1 SMP Mon Feb 7 13:23:30 PST 2005 i686 Build Date Mar 31 2006 10:53:42 Configure Command './configure' '--with-mysql=/usr' '--enable-calendar' '--enable-force-cgi-redirect' '--with-config-file-path=/etc/php/cgi' '--enable-trans-sid' '--with-gd' '--with-ttf=/usr' '--with-freetype-dir=/usr' '--enable-exif' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-zlib-dir=/usr' '--enable-ftp' '--with-curl=/usr' '--with-mcrypt=/usr' '--with-pspell=/usr' '--enable-xslt' '--with-dom-xslt=/usr' '--with-dom=/usr' '--with-xslt-sablot=/usr' '--with-openssl=/usr' '--enable-mbstring=all' '--with-gettext' Server API CGI Virtual Directory Support disabled Configuration File (php.ini) Path /etc/php/cgi/php.ini PHP API 20020918 PHP Extension 20020429 Zend Extension 20050606 Debug Build no Zend Memory Manager enabled Thread Safety disabled Registered PHP Streams php, http, ftp, https, ftps, compress.zlib[/quote]


#6

krichards,

Thanks for sending me that. THe information you provided confirms that PHP is running as CGI, and, while I know you did say that was what the panel said, since “weirdness” is evident in the dhapache ownership of a directory, I wanted to check.

As the previous poster indicated, the dhapache ownership suggests that when the dir was created, it was created by a process operated as the dhapache user. This is normally in effect only when PHP is run as an apache module. Have you ever had the domain set up to run PHP as anything other than cgi?

Sopmetime, when experimenting with installing stuff, if you have ever set the domain to run php as an apache module, then the program ends up “owning” the direcotries/files it creates, as user “dhapache”. Changing the domain back to run PHP as CGI will prevent this from happening in the future, but you will need to contact support to remove the old stuff that “dhapache” created (and now owns!).

I don’t know if any of this applies to you, but if you had the domain set to run PHP as a module at one time, then performed any DH “one-click” installs, DH resets your domain to run PHP as CGI. anything that was created by a program running before that occured will still be owned by dhapache.

From the control panel,–.Manage Domains–>Edit button on relevant domain, you can confirm the user that the CGI process is running as.

If that is your user, you will need to contact support to have them remove the stuff that is owned by user dhapache, and hopefully, help you figure out how that happened.

Good Luck!
–rlparker