2015-02-06 10:18
浏览 56


I've been at this for two days now and haven't been able to find any way (good or bad) of doing that to work.

I have to be able of dynamically mounting drives over network from my website's pages (that part is inevitable).

I have no problems doing it directly on the console with the following command

mount -t cifs //IP-REMOTE-MACHINE/Folder -o username=username,password=password /mnt/share

Obviously trying to just do a shell_exec() of this command wouldn't work with no root rights.

I tried to shell_exec() a script in which I would switch to root user (via su or sudo mycommand) but both of them wouldn't work (never been able to succeed in doing a script who would automatically switch my user to root even with the root pwd hard coded (even if that feels an extremely bad idea I could have accepted that atm).

After that I tried to use pmountbut never found a way to access to a remote shared file (don't think it's even possible but I may have missed something here?)

All that is running on a Debian machine with apache2.

图片转代码服务由CSDN问答提供 功能建议

我已经在这里呆了两天而且找不到任何办法(好的或坏的) 这样做是为了工作。



  mount -t cifs // IP-REMOTE-MACHINE  / Folder -o username = username,password = password / mnt / share 

显然只是想做一个 shell_exec() 命令无法使用root权限。

我尝试 shell_exec()一个脚本,我将切换到root用户(通过su或sudo mycommand) )但是它们都不起作用(从来没有能够成功地做一个脚本,即使用root pwd硬编码也会自动将我的用户切换到root用户(即使我认为这是一个非常糟糕的主意我可以接受那个atm) 。

之后我尝试使用 pmount 但从未找到过访问远程共享文件的方法(不要认为它甚至可能,但我可能有 错过了什么?)


  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

  • duanpao4522 2015-02-06 10:25

    I have a wild idea...

    You could set a cron to run as root that checks for mount commands from your script. The script would simply set a mount command to be processed, and when the cron gets to it, runs the mount, marks the command as processed, and writes to a log file which you could then display.

    解决 无用
    打赏 举报

相关推荐 更多相似问题