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

do_seteuid() callback does nothing if username not set.

parent 3a2f438c
No related branches found
No related tags found
No related merge requests found
...@@ -86,6 +86,8 @@ ulong served=0; ...@@ -86,6 +86,8 @@ ulong served=0;
int prompt_len=0; int prompt_len=0;
#ifdef __unix__ #ifdef __unix__
char* new_uid_name=NULL;
char* new_gid_name=NULL;
uid_t new_uid; uid_t new_uid;
uid_t old_uid; uid_t old_uid;
gid_t new_gid; gid_t new_gid;
...@@ -203,6 +205,9 @@ static BOOL do_seteuid(BOOL to_new) ...@@ -203,6 +205,9 @@ static BOOL do_seteuid(BOOL to_new)
static pthread_mutex_t mutex; static pthread_mutex_t mutex;
static BOOL mutex_initialized; static BOOL mutex_initialized;
if(new_uid_name==NULL) /* not set? */
return(TRUE); /* do nothing */
if(!mutex_initialized) { if(!mutex_initialized) {
pthread_mutex_init(&mutex,NULL); pthread_mutex_init(&mutex,NULL);
mutex_initialized=TRUE; mutex_initialized=TRUE;
...@@ -606,8 +611,6 @@ int main(int argc, char** argv) ...@@ -606,8 +611,6 @@ int main(int argc, char** argv)
char* ctrl_dir; char* ctrl_dir;
BOOL quit=FALSE; BOOL quit=FALSE;
#ifdef __unix__ #ifdef __unix__
char* new_uid_name=NULL;
char* new_gid_name=NULL;
FILE *pidfile; FILE *pidfile;
struct passwd* pw_entry; struct passwd* pw_entry;
struct group* gr_entry; struct group* gr_entry;
...@@ -1014,7 +1017,7 @@ int main(int argc, char** argv) ...@@ -1014,7 +1017,7 @@ int main(int argc, char** argv)
if(getuid()) /* are we running as a normal user? */ if(getuid()) /* are we running as a normal user? */
bbs_lputs("!Started as non-root user. Cannot bind() to ports below 1024."); bbs_lputs("!Started as non-root user. Cannot bind() to ports below 1024.");
else if(!new_uid_name) /* check the user arg, if we have uid 0 */ else if(new_uid_name==NULL) /* check the user arg, if we have uid 0 */
bbs_lputs("Warning: No user account specified, running as root."); bbs_lputs("Warning: No user account specified, running as root.");
else else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment