0

So I have a NodeJS app with a node module called linux-user it just provides a api to view / change Linux users through javascript. In my app I just have it scanning and outputting what the userid is and the username for the linux host. I want to put this file into production but it requires the JavaScript file to be run as root to run. However I don't want someone to tamper with it without the proper permissions but still able to run without running the app as root when I call it. What is the process to change the ownership of this file?

The file must do this:

  • Execute without needing root.
  • Can only edit the script with sudo
4

1 回答 1

0

授予脚本 root 用户权限可能不是最好的主意。这可能会造成很大的损害。但是,考虑到这是您想要做的,您需要将所有者更改为 root,然后以一种只有所有者具有写入+执行权限的方式设置权限才能将所有者更改为 root:

sudo chown root <filename>

然后您需要设置权限,以便其他人无法通过以下方式执行它:

sudo chmod 740 <filename>

740 = Owner 可以读、写、执行;同组用户可以阅读;其余用户无法读取、写入或执行。

于 2015-12-03T02:51:21.283 回答