PHP OSX XAMPP - exec mount command

半腔热情 提交于 2019-12-12 01:55:24

问题


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?


回答1:


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?



来源:https://stackoverflow.com/questions/28444414/php-osx-xampp-exec-mount-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!