#include #include #include "privs.h" #include "die.h" void drop_privileges(bool enforce, uid_t uid, gid_t gid) { if (enforce) { if (uid == getuid()) panic("Uid cannot be the same as the current user!\n"); if (gid == getgid()) panic("Gid cannot be the same as the current user!\n"); } if (setgid(gid) != 0) panic("Unable to drop group privileges: %s!\n", strerror(errno)); if (setuid(uid) != 0) panic("Unable to drop user privileges: %s!\n", strerror(errno)); } z.ch/cgit.cgi/linux/net-next.git' title='net-next.git Git repository'/>
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-09-11 20:02:25 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2016-09-11 20:02:25 -0700
commit9395452b4aab7bc2475ef8935b4a4fb99d778d70 (patch)
treea94823df7dc23abdb9ed7c219e9aef3c6cffe8a2
parentbd0b841fee49de421f615cc173ccff063303672f (diff)
Linux 4.8-rc6