mirror of
https://github.com/swaywm/sway.git
synced 2026-04-23 06:46:27 -04:00
main: allow running as root when not using setuid bit
This commit is contained in:
parent
1b86008721
commit
895c347006
1 changed files with 5 additions and 0 deletions
|
|
@ -150,7 +150,12 @@ static void log_kernel(void) {
|
|||
|
||||
|
||||
static bool drop_permissions(void) {
|
||||
if (getuid() == 0 || getgid() == 0) {
|
||||
sway_log(SWAY_INFO, "Running as root user, this is dangerous");
|
||||
return true;
|
||||
}
|
||||
if (getuid() != geteuid() || getgid() != getegid()) {
|
||||
sway_log(SWAY_INFO, "setuid/setgid bit detected, dropping permissions");
|
||||
// Set the gid and uid in the correct order.
|
||||
if (setgid(getgid()) != 0) {
|
||||
sway_log(SWAY_ERROR, "Unable to drop root group, refusing to start");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue