开发者

Setting SUID flag on a file?

I have a python file that I would like to set the SUID flag on. So that if any normal user executes it it executes as root. I know it's a security issue but I still need to set the SUI开发者_JAVA技巧D flag.


You need a native image for the suid bit to work on modern Unixes. If you really have that requirement, I would write a C/C++ program with the embedded Python code that cleans the environment and then executes the script.

A good way to do that is to use boost::python to embed Python into a C++ program so that you can build a safe, statically linked image.

Depending on what you are really trying to do, another option would be to turn your script into a daemon process, started from a known context (eg. using daemontools), and then have users communicate with it when they need something done, for example using a named pipe with appropriate access control.

Whether the second option is appropriate depends on what you really need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜