|
|
|
|
@ -7,7 +7,7 @@ |
|
|
|
|
* |
|
|
|
|
* |
|
|
|
|
* IDENTIFICATION |
|
|
|
|
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.31 1998/09/01 04:28:44 momjian Exp $ |
|
|
|
|
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.32 1998/12/14 05:18:56 scrappy Exp $ |
|
|
|
|
* |
|
|
|
|
*------------------------------------------------------------------------- |
|
|
|
|
*/ |
|
|
|
|
@ -75,13 +75,13 @@ static int map_old_to_new(Port *port, UserAuth old, int status); |
|
|
|
|
static int |
|
|
|
|
pg_krb4_recvauth(Port *port) |
|
|
|
|
{ |
|
|
|
|
long krbopts = 0; /* one-way authentication */ |
|
|
|
|
KTEXT_ST clttkt; |
|
|
|
|
char instance[INST_SZ]; |
|
|
|
|
AUTH_DAT auth_data; |
|
|
|
|
Key_schedule key_sched; |
|
|
|
|
char version[KRB_SENDAUTH_VLEN]; |
|
|
|
|
int status; |
|
|
|
|
long krbopts = 0; /* one-way authentication */ |
|
|
|
|
KTEXT_ST clttkt; |
|
|
|
|
char instance[INST_SZ], |
|
|
|
|
version[KRB_SENDAUTH_VLEN]; |
|
|
|
|
AUTH_DAT auth_data; |
|
|
|
|
Key_schedule key_sched; |
|
|
|
|
int status; |
|
|
|
|
|
|
|
|
|
strcpy(instance, "*"); /* don't care, but arg gets expanded
|
|
|
|
|
* anyway */ |
|
|
|
|
@ -98,28 +98,25 @@ pg_krb4_recvauth(Port *port) |
|
|
|
|
version); |
|
|
|
|
if (status != KSUCCESS) |
|
|
|
|
{ |
|
|
|
|
sprintf(PQerrormsg, |
|
|
|
|
"pg_krb4_recvauth: kerberos error: %s\n", |
|
|
|
|
krb_err_txt[status]); |
|
|
|
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH, |
|
|
|
|
"pg_krb4_recvauth: kerberos error: %s\n", krb_err_txt[status]); |
|
|
|
|
fputs(PQerrormsg, stderr); |
|
|
|
|
pqdebug("%s", PQerrormsg); |
|
|
|
|
return STATUS_ERROR; |
|
|
|
|
} |
|
|
|
|
if (strncmp(version, PG_KRB4_VERSION, KRB_SENDAUTH_VLEN)) |
|
|
|
|
{ |
|
|
|
|
sprintf(PQerrormsg, |
|
|
|
|
"pg_krb4_recvauth: protocol version != \"%s\"\n", |
|
|
|
|
PG_KRB4_VERSION); |
|
|
|
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH, |
|
|
|
|
"pg_krb4_recvauth: protocol version != \"%s\"\n", PG_KRB4_VERSION); |
|
|
|
|
fputs(PQerrormsg, stderr); |
|
|
|
|
pqdebug("%s", PQerrormsg); |
|
|
|
|
return STATUS_ERROR; |
|
|
|
|
} |
|
|
|
|
if (strncmp(port->user, auth_data.pname, SM_USER)) |
|
|
|
|
{ |
|
|
|
|
sprintf(PQerrormsg, |
|
|
|
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH, |
|
|
|
|
"pg_krb4_recvauth: name \"%s\" != \"%s\"\n", |
|
|
|
|
port->user, |
|
|
|
|
auth_data.pname); |
|
|
|
|
port->user, auth_data.pname); |
|
|
|
|
fputs(PQerrormsg, stderr); |
|
|
|
|
pqdebug("%s", PQerrormsg); |
|
|
|
|
return STATUS_ERROR; |
|
|
|
|
@ -131,9 +128,8 @@ pg_krb4_recvauth(Port *port) |
|
|
|
|
static int |
|
|
|
|
pg_krb4_recvauth(Port *port) |
|
|
|
|
{ |
|
|
|
|
sprintf(PQerrormsg, |
|
|
|
|
"pg_krb4_recvauth: Kerberos not implemented on this " |
|
|
|
|
"server.\n"); |
|
|
|
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH, |
|
|
|
|
"pg_krb4_recvauth: Kerberos not implemented on this server.\n"); |
|
|
|
|
fputs(PQerrormsg, stderr); |
|
|
|
|
pqdebug("%s", PQerrormsg); |
|
|
|
|
|
|
|
|
|
@ -226,9 +222,8 @@ pg_krb5_recvauth(Port *port) |
|
|
|
|
*hostp = '\0'; |
|
|
|
|
if (code = krb5_parse_name(servbuf, &server)) |
|
|
|
|
{ |
|
|
|
|
sprintf(PQerrormsg, |
|
|
|
|
"pg_krb5_recvauth: Kerberos error %d in krb5_parse_name\n", |
|
|
|
|
code); |
|
|
|
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH, |
|
|
|
|
"pg_krb5_recvauth: Kerberos error %d in krb5_parse_name\n", code); |
|
|
|
|
com_err("pg_krb5_recvauth", code, "in krb5_parse_name"); |
|
|
|
|
return STATUS_ERROR; |
|
|
|
|
} |
|
|
|
|
@ -260,9 +255,8 @@ pg_krb5_recvauth(Port *port) |
|
|
|
|
(krb5_ticket **) NULL, |
|
|
|
|
(krb5_authenticator **) NULL)) |
|
|
|
|
{ |
|
|
|
|
sprintf(PQerrormsg, |
|
|
|
|
"pg_krb5_recvauth: Kerberos error %d in krb5_recvauth\n", |
|
|
|
|
code); |
|
|
|
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH, |
|
|
|
|
"pg_krb5_recvauth: Kerberos error %d in krb5_recvauth\n", code); |
|
|
|
|
com_err("pg_krb5_recvauth", code, "in krb5_recvauth"); |
|
|
|
|
krb5_free_principal(server); |
|
|
|
|
return STATUS_ERROR; |
|
|
|
|
@ -276,9 +270,8 @@ pg_krb5_recvauth(Port *port) |
|
|
|
|
*/ |
|
|
|
|
if ((code = krb5_unparse_name(client, &kusername))) |
|
|
|
|
{ |
|
|
|
|
sprintf(PQerrormsg, |
|
|
|
|
"pg_krb5_recvauth: Kerberos error %d in krb5_unparse_name\n", |
|
|
|
|
code); |
|
|
|
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH, |
|
|
|
|
"pg_krb5_recvauth: Kerberos error %d in krb5_unparse_name\n", code); |
|
|
|
|
com_err("pg_krb5_recvauth", code, "in krb5_unparse_name"); |
|
|
|
|
krb5_free_principal(client); |
|
|
|
|
return STATUS_ERROR; |
|
|
|
|
@ -286,7 +279,7 @@ pg_krb5_recvauth(Port *port) |
|
|
|
|
krb5_free_principal(client); |
|
|
|
|
if (!kusername) |
|
|
|
|
{ |
|
|
|
|
sprintf(PQerrormsg, |
|
|
|
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH, |
|
|
|
|
"pg_krb5_recvauth: could not decode username\n"); |
|
|
|
|
fputs(PQerrormsg, stderr); |
|
|
|
|
pqdebug("%s", PQerrormsg); |
|
|
|
|
@ -295,9 +288,8 @@ pg_krb5_recvauth(Port *port) |
|
|
|
|
kusername = pg_an_to_ln(kusername); |
|
|
|
|
if (strncmp(username, kusername, SM_USER)) |
|
|
|
|
{ |
|
|
|
|
sprintf(PQerrormsg, |
|
|
|
|
"pg_krb5_recvauth: name \"%s\" != \"%s\"\n", |
|
|
|
|
port->user, kusername); |
|
|
|
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH, |
|
|
|
|
"pg_krb5_recvauth: name \"%s\" != \"%s\"\n", port->user, kusername); |
|
|
|
|
fputs(PQerrormsg, stderr); |
|
|
|
|
pqdebug("%s", PQerrormsg); |
|
|
|
|
pfree(kusername); |
|
|
|
|
@ -311,9 +303,8 @@ pg_krb5_recvauth(Port *port) |
|
|
|
|
static int |
|
|
|
|
pg_krb5_recvauth(Port *port) |
|
|
|
|
{ |
|
|
|
|
sprintf(PQerrormsg, |
|
|
|
|
"pg_krb5_recvauth: Kerberos not implemented on this " |
|
|
|
|
"server.\n"); |
|
|
|
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH, |
|
|
|
|
"pg_krb5_recvauth: Kerberos not implemented on this server.\n"); |
|
|
|
|
fputs(PQerrormsg, stderr); |
|
|
|
|
pqdebug("%s", PQerrormsg); |
|
|
|
|
|
|
|
|
|
@ -367,7 +358,7 @@ pg_passwordv0_recvauth(void *arg, PacketLen len, void *pkt) |
|
|
|
|
|
|
|
|
|
if (user == NULL || password == NULL) |
|
|
|
|
{ |
|
|
|
|
sprintf(PQerrormsg, |
|
|
|
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH, |
|
|
|
|
"pg_password_recvauth: badly formed password packet.\n"); |
|
|
|
|
fputs(PQerrormsg, stderr); |
|
|
|
|
pqdebug("%s", PQerrormsg); |
|
|
|
|
|