SUID not working with shell script

若如初见. 提交于 2019-11-27 09:16:43

From http://www.tuxation.com/setuid-on-shell-scripts.html:

"the truth is actually that the setuid bit is disabled on a lot of *nix implementations due the massive security holes it incurs"

An alternative approach - wrap the script in something that can use setuid, like this example c program. There are obviously differences to simply calling your script vs using a wrapper like this (e.g. ignored exit codes) but this should give you an idea anyway.

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
   setuid( 0 );
   system( "/path/to/script.sh" );

   return 0;
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!