diff --git a/src/local.c b/src/local.c index 8066d47f..e8faceac 100644 --- a/src/local.c +++ b/src/local.c @@ -1440,8 +1440,11 @@ main(int argc, char **argv) LOGI("listening at %s:%s", local_addr, local_port); // setuid - if (user != NULL) { - run_as(user); + if (user != NULL && ! run_as(user)) { + FATAL("failed to switch user"); + } + if (geteuid() == 0){ + LOGI("You are running this process as the root user!"); } // Init connections diff --git a/src/manager.c b/src/manager.c index 7ef7459c..78bca1f4 100644 --- a/src/manager.c +++ b/src/manager.c @@ -845,11 +845,14 @@ main(int argc, char **argv) struct ev_loop *loop = EV_DEFAULT; // setuid - if (user != NULL) { - run_as(user); + if (user != NULL && ! run_as(user)) { + FATAL("failed to switch user"); + } + if (geteuid() == 0){ + LOGI("You are running this process as the root user!"); } - struct passwd *pw = getpwuid(getuid()); + struct passwd *pw = getpwuid(geteuid()); const char *homedir = pw->pw_dir; working_dir_size = strlen(homedir) + 15; working_dir = malloc(working_dir_size); diff --git a/src/redir.c b/src/redir.c index 8daeb2f2..5880c936 100644 --- a/src/redir.c +++ b/src/redir.c @@ -1021,8 +1021,11 @@ main(int argc, char **argv) LOGI("listening at %s:%s", local_addr, local_port); // setuid - if (user != NULL) { - run_as(user); + if (user != NULL && ! run_as(user)) { + FATAL("failed to switch user"); + } + if (geteuid() == 0){ + LOGI("You are running this process as the root user!"); } ev_run(loop, 0); diff --git a/src/server.c b/src/server.c index 0569d68a..3f1b4e1a 100644 --- a/src/server.c +++ b/src/server.c @@ -1871,8 +1871,11 @@ main(int argc, char **argv) ev_timer_start(EV_DEFAULT, &block_list_watcher); // setuid - if (user != NULL) { - run_as(user); + if (user != NULL && ! run_as(user)) { + FATAL("failed to switch user"); + } + if (geteuid() == 0){ + LOGI("You are running this process as the root user!"); } // init block list diff --git a/src/tunnel.c b/src/tunnel.c index 4ddfe0b6..0bfe2ec0 100644 --- a/src/tunnel.c +++ b/src/tunnel.c @@ -1028,8 +1028,11 @@ main(int argc, char **argv) LOGI("listening at %s:%s", local_addr, local_port); // setuid - if (user != NULL) { - run_as(user); + if (user != NULL && ! run_as(user)) { + FATAL("failed to switch user"); + } + if (geteuid() == 0){ + LOGI("You are running this process as the root user!"); } ev_run(loop, 0);