mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-28 03:33:42 +00:00
exit when running as a nonexistent user and warn when running as root (#948)
This commit is contained in:
+5
-2
@@ -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
|
||||
|
||||
+6
-3
@@ -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);
|
||||
|
||||
+5
-2
@@ -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);
|
||||
|
||||
+5
-2
@@ -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
|
||||
|
||||
+5
-2
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user