aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-auth.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2000-08-25 10:00:35 +0000
committerPeter Eisentraut <peter_e@gmx.net>2000-08-25 10:00:35 +0000
commit996832caeec19ed43fdc36db33ae7ee48e348662 (patch)
tree737895a8d87f1c4d289dba6db7c12a5d43b02489 /src/interfaces/libpq/fe-auth.c
parent69cf335687eb47e80e56aee7804bf0c2c3facec8 (diff)
downloadpostgresql-996832caeec19ed43fdc36db33ae7ee48e348662.tar.gz
postgresql-996832caeec19ed43fdc36db33ae7ee48e348662.zip
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.
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;