tags:

views:

53

answers:

1

I need some help with priviligies in centos I have a file in home/admin/public_html/generate.php

that I want to do some file copy with using php copy function

When I set the file to chown admin:admin generate.php I can access the file but I cannot execute the php copy command because I don't have the proper rights.

When I set the file to root:root generate.php I cant access the file beacuse its under admin user folder home/admin/public_html/generate.php

how do I solve please, thankful for any help.

Bottom line is that I want my generate.php which is owned by admin:admin to be able to copy files from sources outside its home dir and to other home dirs

I am using CENTOS

A: 

There are a few things you need to determine to make this work:

  • The userid of the web server process. It's usually httpd or www-data or apache
  • Does that user have access to read the file you're copying?
  • Does that user have access to write to the destination?

Assuming that the web server process is running as httpd, you could run chown httpd destination, where destination refers to the file or directory you're trying to copy into.

To access the file that you're copying, the httpd user needs to be able to access all directories leading to the file, which is controlled by the execute bit (x in the ls -l listing, most likely the last character), as well as have read access to the file itself (r in ls -l)

Chris AtLee
how do I check the user for apache? and how do I set it to be able to copy anything from any source in /home to any destination in /home?
vick
ps -ef | grep http, or ps -ef | grep apache should tell you who apache is running as.Copying *to* any destination in /home sounds like a terrible security risk. I would recommend investigating sudo to handle this.
Chris AtLee
this is a test im doing, so security is not an issue today. the users are root and nobody, how do I give proper rights?
vick
fastest way is probably `chmod -R o+w /home`
Chris AtLee
what would be a safe way of doing this?
vick