[英]Run whole application as another user (other user than root)
https://github.com/mongodb/mongo/blob/master/debian/mongodb-org-server.postinst I could see in the above link that mongodb has created a newuser named 'mongodb'.and I got to know that many bigger projects run their project as a custom user (here as a user 'mongodb').I wrote a small application in python and running it as sudo right now,I would like to create a new custom user for my application and run the application as the custom user.how does actually bigger projects acheive this .what is the command they use to make run the whole application or package as a custom user? https://github.com/mongodb/mongo/blob/master/debian/mongodb-org-server.postinst我可以在上面的链接中看到mongodb创建了一个名为“ mongodb”的新用户。我知道很多较大的项目以自定义用户(此处为用户“ mongodb”)的身份运行他们的项目。我用python编写了一个小应用程序,现在以sudo方式运行,我想为我的应用程序创建一个新的自定义用户并运行该应用程序作为自定义用户。更大的项目实际上是如何实现的。他们使用什么命令以自定义用户身份运行整个应用程序或程序包? In a whole lot reading about this I found that we could use sudo -u <username> <command>
or by setting euid or uid by seteuid()
function. 通过大量阅读,我发现我们可以使用sudo -u <username> <command>
或通过seteuid()
函数设置euid或uid。 but I want to know how actually real projects implement it and follow that standard way in my project. 但我想知道实际的项目是如何实现它的,并在我的项目中遵循该标准方法。
就像您链接的文件一样,他们使用chown
将可执行文件的所有者更改为自定义chown
因此您可以在安装后脚本中使用该脚本(该脚本将配置应用程序正常运行所需的内容)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.