mercredi 6 janvier 2016

Changing user in a php program using apache

I'm developping a web site using php. This website is running with a server Apache

My goal is to be able to control the people that can upload a file. They can only upload a file if they belong to a specific group in Apache (linux group). The problem is that when someone upload a file, its not there user that upload the file its apache because they are not connected to the server, so when someone uploads a file the owner of the file its apache so I cant change the owner or the group of this file

I thought, to resolve this problem I'm going to use the command "su - user", to change the user and when I create the file, the owner it would be me not apache. But the problem its that when I use this commande, it call the pompt window to write the code but i'm using php so it wouldnt work

I have found this bash to run it in my php program but the only problem its that it doesnt work. So if you have any ideas I would be really greatfull with your help

> spawn su user_name
expect "Password:" { send "my_password\r" }
expect "$ " { send "/bin/sh my_script_bash\r" }
expect "$ " { exit }

Important note: I dont have access to the user root and its password, because I'm working in a big company and I dont have the right to know some passwords




Aucun commentaire:

Enregistrer un commentaire