*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.2 1996/07/23 03:35:11 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.3 1996/07/27 02:27:55 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
}
/*
- * fe_getauthname -- returns a pointer to static space containing whatever
+ * fe_getauthname -- returns a pointer to dynamic space containing whatever
* name the user has authenticated to the system
* if there is an error, return the error message in PQerrormsg
*/
fe_getauthname(char* PQerrormsg)
{
char *name = (char *) NULL;
+ char *authn = (char *) NULL;
MsgType authsvc;
authsvc = fe_getauthsvc(PQerrormsg);
case STARTUP_MSG:
{
struct passwd *pw = getpwuid(geteuid());
- if (pw &&
- pw->pw_name &&
- (name = (char *) malloc(strlen(pw->pw_name) + 1))) {
- (void) strcpy(name, pw->pw_name);
- }
+ if (pw) name = pw->pw_name;
}
break;
default:
authsvc);
break;
}
- return(name);
+
+ if(name && (authn = (char *) malloc(strlen(name) + 1)))
+ (void) strcpy(authn, name);
+ return(authn);
}