Skip to content
Snippets Groups Projects
Commit bae30a4a authored by rswindell's avatar rswindell
Browse files

Back to setting userid AFTER spawning child threads (couldn't bind sockets).

Switched from fprintf(stderr,..) to lputs() for setuid warnings/status.
parent 1f67e814
No related branches found
No related tags found
No related merge requests found
...@@ -394,6 +394,7 @@ int main(int argc, char** argv) ...@@ -394,6 +394,7 @@ int main(int argc, char** argv)
{ {
int i; int i;
char ch; char ch;
char str[256];
char* arg; char* arg;
char* ctrl_dir; char* ctrl_dir;
BOOL quit=FALSE; BOOL quit=FALSE;
...@@ -588,26 +589,6 @@ int main(int argc, char** argv) ...@@ -588,26 +589,6 @@ int main(int argc, char** argv)
} }
} }
#ifdef __unix__
if(getuid()) /* are we running as a normal user? */
fprintf(stderr,
"*** Started as non-root user. Cannot bind() to ports below 1024.\n");
else if(!new_uid_name) /* check the user arg, if we have uid 0 */
fprintf(stderr,
"*** No user account specified and started as root. HAZARDOUS!\n");
else if (!do_setuid())
/* actually try to change the uid of this process */
fprintf(stderr,
"*** Setting new uid failed! (Does the user exist?)\n");
else
printf("*** Successfully changed to user %s.\n", new_uid_name);
#endif
_beginthread((void(*)(void*))bbs_thread,0,&bbs_startup); _beginthread((void(*)(void*))bbs_thread,0,&bbs_startup);
_beginthread((void(*)(void*))ftp_server,0,&ftp_startup); _beginthread((void(*)(void*))ftp_server,0,&ftp_startup);
_beginthread((void(*)(void*))mail_server,0,&mail_startup); _beginthread((void(*)(void*))mail_server,0,&mail_startup);
...@@ -621,6 +602,21 @@ int main(int argc, char** argv) ...@@ -621,6 +602,21 @@ int main(int argc, char** argv)
signal(SIGABRT, _sighandler_quit); signal(SIGABRT, _sighandler_quit);
signal(SIGTERM, _sighandler_quit); signal(SIGTERM, _sighandler_quit);
if(getuid()) /* are we running as a normal user? */
lputs("*** Started as non-root user. Cannot bind() to ports below 1024.\n");
else if(!new_uid_name) /* check the user arg, if we have uid 0 */
lputs("*** No user account specified and started as root. HAZARDOUS!\n");
else if (!do_setuid())
/* actually try to change the uid of this process */
lputs("*** Setting new uid failed! (Does the user exist?)\n");
else {
sprintf(str,"*** Successfully changed to user %s.\n", new_uid_name);
lputs(str);
}
if(!isatty(fileno(stdin))) /* redirected */ if(!isatty(fileno(stdin))) /* redirected */
select(0,NULL,NULL,NULL,NULL); /* so wait here until signaled */ select(0,NULL,NULL,NULL,NULL); /* so wait here until signaled */
else /* interactive */ else /* interactive */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment