arogue5: avoid segfaulting if getpwuid() fails.

This commit is contained in:
John "Elwin" Edwards 2012-08-11 23:45:34 +00:00
parent 6e2b154419
commit 355fb33eb7
2 changed files with 14 additions and 5 deletions

View file

@ -49,14 +49,14 @@ char **envp;
register char *env;
int lowtime;
time_t now;
char *roguedir = md_getroguedir();
char *roguedir;
roguedir = md_getroguedir();
md_init();
/*
* get home and options from environment
*/
strncpy(home,md_gethomedir(),LINELEN);
#ifdef SAVEDIR

View file

@ -234,7 +234,10 @@ md_getusername()
pw = getpwuid(getuid());
l = pw->pw_name;
if (pw != NULL)
l = pw->pw_name;
else
l = "";
#endif
if ((l == NULL) || (*l == '\0'))
@ -265,7 +268,10 @@ md_gethomedir()
struct passwd *pw;
pw = getpwuid(getuid());
h = pw->pw_dir;
if (pw != NULL)
h = pw->pw_dir;
else
h = "";
if (strcmp(h,"/") == 0)
h = NULL;
@ -325,7 +331,10 @@ md_getshell()
char *def = "/bin/sh";
struct passwd *pw;
pw = getpwuid(getuid());
s = pw->pw_shell;
if (pw != NULL)
s = pw->pw_shell;
else
s = "";
#endif
if ((s == NULL) || (*s == '\0'))
if ( (s = getenv("COMSPEC")) == NULL)