From a1aa0dc4e2b50b937b73f7f72a396d5316e69d5e Mon Sep 17 00:00:00 2001 From: Scott Tringali Date: Thu, 10 Apr 2003 18:37:27 +0000 Subject: [PATCH] Don't quit if getpwuid() fails. It can fail if some nameservices are not responding through no fault of the user. --- util/utils.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/util/utils.c b/util/utils.c index 2078ef8..aad6887 100644 --- a/util/utils.c +++ b/util/utils.c @@ -1,4 +1,4 @@ -static const char CVSID[] = "$Id: utils.c,v 1.19 2002/11/28 23:22:29 yooden Exp $"; +static const char CVSID[] = "$Id: utils.c,v 1.20 2003/04/10 18:37:27 tringali Exp $"; /******************************************************************************* * * * utils.c -- miscellaneous non-GUI routines * @@ -137,13 +137,17 @@ const char passwdEntry = getpwuid(getuid()); if (!passwdEntry) { - /* This is really serious, so just exit. */ - perror("nedit: getpwuid() failed "); - exit(EXIT_FAILURE); + /* This is really serious, but sometimes username service + is misconfigured through no fault of the user. Be nice + and let the user start nc anyway. */ + perror("nedit: getpwuid() failed - reverting to $USER"); + return getenv("USER"); + } + else { + userName=malloc(strlen(passwdEntry->pw_name)+1); + strcpy(userName, passwdEntry->pw_name); + return userName; } - userName=malloc(strlen(passwdEntry->pw_name)+1); - strcpy(userName, passwdEntry->pw_name); - return userName; #endif /* VMS */ } -- 2.11.4.GIT