用sudo运行节点exec

时间:2013-07-23 00:44:56

标签: node.js sudo mount

我想在Node中创建一个网络安装脚本,允许用户在服务器上安装nfs共享。我的代码如下:

// Create our mount string command.
var str = 'mount -o nolock -t nfs '+ escapePath(p) +' '+ escapePath(mountPoint);

exec(str, function(err, stdout, stderr){
  if (err) return fn(err);
  return fn(null, mountPoint);
});

但是,当然,挂载网络共享需要sudo。如果我使用sudo运行我的节点应用程序,这工作正常...但我怀疑这不是最好的方法。有没有办法可以在不调用sudo的情况下运行mount命令? ...或者至少,没有使用sudo运行我的应用程序?这里最好的方法是什么?

0 个答案:

没有答案
相关问题