简体   繁体   中英

PHP OSX XAMPP - exec mount command

Good Afternoon, I am currently working on a PHP project which requires a php script to mount a windows shared drive. Currently building using OSX with XAMPP.

exec('mount -t smbfs //user:pass@192.168.1.1/Share /Volumes/Share 2> temp/error.txt');

Now i understand why this does not work. Its due to permissions. Apache is running as user daemon. Now i could change the user that Apache runs to fix this "challenge" but want to avoid any changes to the server if possible. I would like to reach out and see if there is a better way to go about this.

Any ideas?

Ok, So i got it working. I just needed the web server (user daemon) to own a folder in which the share is mounted.

EG. created a folder called "tempshare" that user daemon owns and is in the same folder as the php script (don't worry, it will be placed out of the web root when complete)

exec('mount -t smbfs //user:pass@192.168.1.1/Share /path/to/tempshare 2> temp/error.txt');

Seemed to work. Any advice on security using this method?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM