允许node.js应用程序在没有sudo的情况下运行libpcap(“Symlink”问题)

我想使用下面的命令来允许使用libpcap软件包,而不用sudo(在debian系统上):

sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' /usr/bin/nodejs 

我得到这个错误:

 Failed to set capabilities on file `/usr/bin/nodejs' (Invalid argument) The value of the capability argument is not permitted for a file. Or the file is not a regular (non-symlink) file 

但是/usr/bin/nodejs不是符号链接:

 -rwxr-xr-x 1 root root 18M Jun 3 03:20 /usr/bin/nodejs USER@HOST:~$ which nodejs /usr/bin/nodejs 

我的驱动器是这样安装的:

 USER@HOST:~$ cat /etc/fstab # # /etc/fstab # # <device> <mountpoint> <filesystemtype> <options> <dump> <fsckorder> /dev/mmcblk0p1 / ext3 defaults 0 1 

检查顺序:

  1. 仔细检查/usr/bin/nodejs是否是一个文件。
  2. 这些function是允许的文件,也许你不能改变它们,甚至作为根。 确保以下内容:
    • 包含/usr/bin/nodejs的分区被挂载rw。
    • 分区没有使用选项nosuid挂载,这将阻止文件系统上的某些操作(nosuid挂载选项指定文件系统不能包含set userid文件)。