I am root on my own webserver and I did write a perl-script for maintaining my website. Called from a browser this script displayes a user-interface for maintainance. To be able to start this script from my browser, I must enter a username and a password, so nobody but me can run this script.
I want that this script renames some files on the server when I click on the according button. From the perl-script I call the shell-command `mv oldFilename newFilename`, but nothing happens. Apache’s error log displays this message:
[timestring] [error] [client n.n.n.n] mv: cannot move oldFilename to newFilename: Permission denied, referer: referrer
filename‘s owner is root, permissions are set to 0644 (everybody can read, only root can write)
What is the best solution for this problem? Is there a better way than changing the files permissions to 0666? I want to refrain from changing the permissions. I would prefere a solution where the perl-script sayes to the shell something like: “Dear shell, here is the password for root. Now please rename file X to Y!“
Isn’t this the exact problem that Unix groups were meant to solve? Set file permission to
0664, directory permissions to0775, and assign the files and directories to a group that the webserver user belongs to.