mirror of
https://cagebreak.project-repo.co/cagebreak.git
synced 2026-08-20 20:44:18 +02:00
Fix permission dropping
This commit is contained in:
parent
4de82c076f
commit
35a15670ea
1 changed files with 3 additions and 2 deletions
|
|
@ -88,13 +88,14 @@ sig_chld_handler(int signal) {
|
|||
static bool
|
||||
drop_permissions(void) {
|
||||
if(getuid() != geteuid() || getgid() != getegid()) {
|
||||
if(setuid(getuid()) != 0 || setgid(getgid()) != 0) {
|
||||
// Set gid before uid
|
||||
if(setgid(getgid()) != 0 || setuid(getuid()) != 0) {
|
||||
wlr_log(WLR_ERROR, "Unable to drop root, refusing to start");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(setuid(0) != -1) {
|
||||
if(setgid(0) != -1 || setuid(0) != -1) {
|
||||
wlr_log(WLR_ERROR, "Unable to drop root (we shouldn't be able to "
|
||||
"restore it after setuid), refusing to start");
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue