Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Good way to bind 2 server folders from a web page 1

Status
Not open for further replies.
May 13, 2005
56
US
Hi there, I am trying to make an interface to do some scripting tools I normally run from a bash script and convert them to php pages.

I need to figure out how to run the command from a webpage
Code:
mount --bind /olddir /newdir

This allows me to access files in /olddir by going to /newdir (I'm using it to isolate ftp directories)

So, I have figured out how to permanently enter this in the fstab file, but I would also like to put in the above code to make it active before a reboot.

I have tried
Code:
exec("mount --bind /olddir /newdir");
along with shell_exec() and system()... I am assuming that this is a permissions thing, but I dont know what I need to do to fix it?
 
It's probably the user as which you are trying to run the command. A lot of unix-like OSes limit the commands a non-root user can run. Anything run through a web browser is going to run as the user as which the web server runs, and that user is typically non-root for very good reasons.

You might try running the command through sudo.

You might play around with Apache suExec (


Want the best answers? Ask the best questions! TANSTAAFL!
 
Thanks for pointing me in the right direction...

I ended up using the command
Code:
exec("sudo mount --bind /olddir /newdir");

and adding the line
Code:
apache          ALL=/bin/mount, NOPASSWD: /bin/mount

to my /etc/sudousers file

This only allows apache to sudo the mount command.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top