From 996832caeec19ed43fdc36db33ae7ee48e348662 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 25 Aug 2000 10:00:35 +0000 Subject: Make the location of the Kerberos server key file run time configurable (rather than compile time). For libpq, even when Kerberos support is compiled in, the default user name should still fall back to geteuid() if it can't be determined via the Kerberos system. A couple of fixes for string type configuration parameters, now that there is one. --- src/interfaces/libpq/fe-auth.c | 46 +++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 25 deletions(-) (limited to 'src/interfaces/libpq/fe-auth.c') 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; -- cgit v1.2.3