Mounting afp as different user for php access

懵懂的女人 提交于 2019-12-06 14:27:59

问题


I've mounted an afp directory, afp://ServerName/Foo/, with "Finder->Go->Connect to Server" to /Volumes/Foo, now I'm trying to access it with:

opendir("/Volumes/Foo/dirname/");

However, I get an

Warning: opendir(/Volumes/Foo/dirname/) [function.opendir]: failed to open dir: Permission denied in...

mount in terminal gives me: afp_1VqvPY000e413wKcJE13gANY-7.2d000004 on /Volumes/Foo (afpfs, nodev, nosuid, mounted by daniel)

So I need to mount the folder as _www, or somehow allow _www to use my mount. How can I do either one of these? I'm guessing I want to possibly su to _www or something, but I don't know how to with terminal.


回答1:


Should be able to mount the volume as _www in the terminal.

sudo -u _www mount_afp -I //user@host/share /path/to/mountpoint.
Omit -I if you want to specify the password in the URI.

Either that or you could use mount_afp using system() or exec() from within the script.

If it is for a web server you will probably want to look into automatically mounting the share at startup.



来源:https://stackoverflow.com/questions/5013129/mounting-afp-as-different-user-for-php-access

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