0

I currently manage a Drupal install on a shared university computer (i.e. I don't have root access to the box), but the sites/default/files directory was created with all permissions and ownership set to a unknown user (as is shown below), therefore I have absolutely no way to delete or change anything in this folder without using the Drupal interface or contacting the sysadmin.

I believe the owner of these files is the webserver's user (which is on another box). Is there any way to change the uploaded files permissions/owner within Drupal (or at least delete/chown this folder)?

myself@sparta:~/public_html/drupal/sites/default/files$ ls -la
total 252
drwxrwxr-x 4     48        48   4096 Set  3 11:43 .
dr-xr-xr-x 3 myself  students   4096 Set  2 12:07 ..
-rw-r--r-- 1     48        48 227057 Set  3 11:43 Estatuto.pdf
-rw-rw-r-- 1     48        48     93 Set  2 12:30 .htaccess
drwxr-xr-x 2     48        48   4096 Set  3 11:25 imagefield_thumbs
drwxrwxr-x 2     48        48   4096 Set  3 10:47 languages
-rw-rw-r-- 1     48        48   2666 Set  3 11:25 posse.jpg

Thanks!

2 Answers 2

1

You can install the devel module and visit /devel/php on your site. This will give you a place to run ad-hoc PHP from where you could run chown() or something similar on the files in question.

I'm sure it doesn't need to be said but be careful, the last thing you want to do is make a mistake with permissions!

1
  • warning: chown() [function.chown]: Operation not permitted in /home/students/marc/public_html/drupal/modules/devel/devel.module(1148) : eval()'d code on line 2. And now, what should I do?
    – Marc
    Sep 5, 2011 at 0:13
1

So when you say you manage the installation, presumably you have ftp access to it. If so, you can use something like Filezilla to set permissions for files within the root drupal folder. You need ftp access to install modules also, but you are normally walled within the drupal folders. Ftp permissions changes will depend on the privileges of the Ftp user login.

When you open the Drupal folders in Filezilla, right click on the file you wish to change and choose:

enter image description here

Then you will see the permissions window:

enter image description here

From here you choose the permissions that you want.

OK, following your comment below: If the whole install is owned by your user, and you can make any changes from within the Drupal interface. Then, using your SSH access, create a new folder alongside 'sites/default/files' called 'files2' and copy over the files you want in there, make sure you 'chown -R files2 username:www-data' and then in Drupal go to 'admin/settings/file-system' and change the file system path to 'sites/default/files2' and hopefully, that'll work based on your explanation of the permissions you have. Make sure you protect any new folders using CHMOD on the permissions for the folder and separately for the files inside.

If you can't copy over the files to the new folder then you'll have to recreate them by downloading them from the Drupal site in question and then uploading them back into the new folder.

2
  • I have ssh access, and the whole install is owned by my user, the problem is with the files uploaded by Drupal which are owned by (at least that's what I think) the Apache daemon.
    – Marc
    Sep 4, 2011 at 23:47
  • see above addition.
    – David
    Sep 5, 2011 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.