K
K
Kir Shatrov2011-02-20 23:30:56
*nix-like systems
Kir Shatrov, 2011-02-20 23:30:56

Delete file created by www-data?

There is a user user on the server, and a www directory in his home folder. It contains a PHP script that allows you to upload files to the server.
All files loaded by the script are owned by www-data.
The problem is that these files cannot be deleted via ssh (Permission denied) because the user does not have rights to operate on www-data files.
So how do you delete these files?
OS - Ubuntu Server 10.04.

Answer the question

In order to leave comments, you need to log in

10 answer(s)
B
bigdogsru, 2011-02-21
@RazoR_Empire

Just put Apache with MPM, then the scripts will be executed with user rights, not Apache.

A
Atrax, 2011-02-20
@Atrax

Remove it from php script.

[
[email protected]><e, 2011-02-20
@barmaley_exe

So can play with groups? Let's say, forcibly change the group of all files in the user's directory or combine www-data and the user in one group.

H
holyorb2, 2011-02-20
@holyorb2

if you have root access, then delete
sudo rm file
As I understand that you do not have such access. then there is a way out in the support or removal through the panel provided by the hoster. For example, cpanel has a file manager, it should delete files.
Although in such cases I ALWAYS tell the hoster that my account can delete the files that make my sites and I think this is the right way out

M
MiXei4, 2011-02-20
@MiXei4

You can delete files with a php script, or correct the rights to folders / files with a php script if you have enough rights.

D
darkslesh, 2011-02-20
@darkslesh

<? unlink('/path/filename.ext');?>

V
Vlad Zhivotnev, 2011-02-21
@inkvizitor68sl

And it’s not good to use unconfigured mod_php.
Or in CGI, switch the php mode or drop the necessary users into the www-data group. Only throwing into the group will not save you from stubborn scripts anyway.

S
Sergey, 2011-02-21
@seriyPS

I think we need to do this:
1) we give the uploaded files rwx rwx r--group and user rights, respectively www-data.
2) add the user to the group www-data.
Well or the truth something to stir up with ACL. It is possible for each user to have a separate Apache process launched from the user, but this is expensive and takes a long time to set up ...

S
Sergey Fedotov, 2011-02-21
@FSA

Once set up a web server for several users under FreeBSD. Each user had their own folder. Everything that was in the folder and the folder itself belonged to this user, the group was www (Apache ran from it). In order for files created by the web server to be owned by the user, SUIDDIR (chmod 4770) was used. Those. to all files created on behalf of www, the user was replaced with the one who owned the folder.
Almost everything worked, except for one thing - files were not loaded via php. The problem arose due to the fact that the file was loaded into a temporary folder and received permissions 600. As a result, the newly loaded php file could not be transferred to the destination.

L
LoneCat, 2011-02-21
@LoneCat

Do a chmod of the downloaded files 666 (don't think it's evil witchcraft :)), and delete as you wish, the first digit is the owner's rights to the file, the second is the group's rights to the file, the third is the rights of any user, 6 is the right to read / write .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question