aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-auth.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces/libpq/fe-auth.c')
-rw-r--r--src/interfaces/libpq/fe-auth.c46
1 files changed, 21 insertions, 25 deletions
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c
index e0f1bd75332..8af4c193ae1 100644
--- a/src/interfaces/libpq/fe-auth.c
+++ b/src/interfaces/libpq/fe-auth.c
@@ -10,7 +10,7 @@
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.43 2000/06/17 00:10:09 petere Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.44 2000/08/25 10:00:35 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -565,41 +565,37 @@ fe_getauthname(char *PQerrormsg)
MsgType authsvc;
authsvc = fe_getauthsvc(PQerrormsg);
- switch ((int) authsvc)
- {
+
#ifdef KRB4
- case STARTUP_KRB4_MSG:
- name = pg_krb4_authname(PQerrormsg);
- break;
+ if (authsvc == STARTUP_KRB4_MSG)
+ name = pg_krb4_authname(PQerrormsg);
#endif
#ifdef KRB5
- case STARTUP_KRB5_MSG:
- name = pg_krb5_authname(PQerrormsg);
- break;
+ if (authsvc == STARTUP_KRB5_MSG)
+ name = pg_krb5_authname(PQerrormsg);
#endif
- case STARTUP_MSG:
- {
+
+ if (authsvc == STARTUP_MSG
+ || (authsvc == STARTUP_KRB4_MSG && !name)
+ || (authsvc == STARTUP_KRB5_MSG && !name))
+ {
#ifdef WIN32
- char username[128];
- DWORD namesize = sizeof(username) - 1;
+ char username[128];
+ DWORD namesize = sizeof(username) - 1;
- if (GetUserName(username, &namesize))
- name = username;
+ if (GetUserName(username, &namesize))
+ name = username;
#else
- struct passwd *pw = getpwuid(geteuid());
+ struct passwd *pw = getpwuid(geteuid());
- if (pw)
- name = pw->pw_name;
+ if (pw)
+ name = pw->pw_name;
#endif
- }
- break;
- default:
- (void) sprintf(PQerrormsg,
- "fe_getauthname: invalid authentication system: %d\n",
- authsvc);
- break;
}
+ if (authsvc != STARTUP_MSG && authsvc != STARTUP_KRB4_MSG && authsvc != STARTUP_KRB5_MSG)
+ sprintf(PQerrormsg,"fe_getauthname: invalid authentication system: %d\n", authsvc);
+
if (name && (authn = (char *) malloc(strlen(name) + 1)))
strcpy(authn, name);
return authn;