logo

inaban

Unnamed repository; edit this file 'description' to name the repository.
commit: 8ff6a2588f0df6687b65c4d5d4808350219737bf
parent: f2a00a12d4ce90055ad2513e72155e12d6ab8708
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon,  1 Jul 2019 07:51:11 +0200

Consider running as root only if setuid(0) fails

This is sway’s behaviour

Diffstat:

Minaban.c17++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/inaban.c b/inaban.c @@ -1,5 +1,6 @@ // Based on wlroots's TinyWL which is distributed under CC0 #include "inaban.h" + #include "config.h" #include <getopt.h> @@ -774,12 +775,11 @@ drop_permissions(void) wlr_log(WLR_ERROR, "Unable to drop root, refusing to continue"); return false; } - if(geteuid() == 0 && getegid() == 0) - { - wlr_log(WLR_ERROR, - "Still effectively running as root after dropping permissions, refusing to continue"); - return false; - } + } + if(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; } return true; @@ -788,11 +788,6 @@ drop_permissions(void) int main(int argc, char *argv[]) { - if(geteuid() == 0 && getegid() == 0) - { - wlr_log(WLR_ERROR, "Running as root is unsupported, refusing to continue"); - return false; - } wlr_log_init(WLR_DEBUG, NULL); char *startup_cmd = NULL;