indent
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17206 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997-2002 Kungliga Tekniska H<>gskolan
|
||||
* Copyright (c) 1997-2006 Kungliga Tekniska H<>gskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -73,33 +73,54 @@ krb5_recvauth_match_version(krb5_context context,
|
||||
krb5_keytab keytab,
|
||||
krb5_ticket **ticket)
|
||||
{
|
||||
krb5_error_code ret;
|
||||
const char *version = KRB5_SENDAUTH_VERSION;
|
||||
char her_version[sizeof(KRB5_SENDAUTH_VERSION)];
|
||||
char *her_appl_version;
|
||||
u_int32_t len;
|
||||
u_char repl;
|
||||
krb5_data data;
|
||||
krb5_flags ap_options;
|
||||
ssize_t n;
|
||||
krb5_error_code ret;
|
||||
const char *version = KRB5_SENDAUTH_VERSION;
|
||||
char her_version[sizeof(KRB5_SENDAUTH_VERSION)];
|
||||
char *her_appl_version;
|
||||
u_int32_t len;
|
||||
u_char repl;
|
||||
krb5_data data;
|
||||
krb5_flags ap_options;
|
||||
ssize_t n;
|
||||
|
||||
/*
|
||||
* If there are no addresses in auth_context, get them from `fd'.
|
||||
*/
|
||||
/*
|
||||
* If there are no addresses in auth_context, get them from `fd'.
|
||||
*/
|
||||
|
||||
if (*auth_context == NULL) {
|
||||
ret = krb5_auth_con_init (context, auth_context);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
if (*auth_context == NULL) {
|
||||
ret = krb5_auth_con_init (context, auth_context);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = krb5_auth_con_setaddrs_from_fd (context,
|
||||
*auth_context,
|
||||
p_fd);
|
||||
if (ret)
|
||||
return ret;
|
||||
ret = krb5_auth_con_setaddrs_from_fd (context,
|
||||
*auth_context,
|
||||
p_fd);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if(!(flags & KRB5_RECVAUTH_IGNORE_VERSION)) {
|
||||
n = krb5_net_read (context, p_fd, &len, 4);
|
||||
if (n < 0) {
|
||||
ret = errno;
|
||||
krb5_set_error_string (context, "read: %s", strerror(errno));
|
||||
return ret;
|
||||
}
|
||||
if (n == 0) {
|
||||
krb5_clear_error_string (context);
|
||||
return KRB5_SENDAUTH_BADAUTHVERS;
|
||||
}
|
||||
len = ntohl(len);
|
||||
if (len != sizeof(her_version)
|
||||
|| krb5_net_read (context, p_fd, her_version, len) != len
|
||||
|| strncmp (version, her_version, len)) {
|
||||
repl = 1;
|
||||
krb5_net_write (context, p_fd, &repl, 1);
|
||||
krb5_clear_error_string (context);
|
||||
return KRB5_SENDAUTH_BADAUTHVERS;
|
||||
}
|
||||
}
|
||||
|
||||
if(!(flags & KRB5_RECVAUTH_IGNORE_VERSION)) {
|
||||
n = krb5_net_read (context, p_fd, &len, 4);
|
||||
if (n < 0) {
|
||||
ret = errno;
|
||||
@@ -108,104 +129,83 @@ krb5_recvauth_match_version(krb5_context context,
|
||||
}
|
||||
if (n == 0) {
|
||||
krb5_clear_error_string (context);
|
||||
return KRB5_SENDAUTH_BADAUTHVERS;
|
||||
return KRB5_SENDAUTH_BADAPPLVERS;
|
||||
}
|
||||
len = ntohl(len);
|
||||
if (len != sizeof(her_version)
|
||||
|| krb5_net_read (context, p_fd, her_version, len) != len
|
||||
|| strncmp (version, her_version, len)) {
|
||||
repl = 1;
|
||||
krb5_net_write (context, p_fd, &repl, 1);
|
||||
krb5_clear_error_string (context);
|
||||
return KRB5_SENDAUTH_BADAUTHVERS;
|
||||
her_appl_version = malloc (len);
|
||||
if (her_appl_version == NULL) {
|
||||
repl = 2;
|
||||
krb5_net_write (context, p_fd, &repl, 1);
|
||||
krb5_set_error_string (context, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
if (krb5_net_read (context, p_fd, her_appl_version, len) != len
|
||||
|| !(*match_appl_version)(match_data, her_appl_version)) {
|
||||
repl = 2;
|
||||
krb5_net_write (context, p_fd, &repl, 1);
|
||||
krb5_set_error_string (context, "wrong sendauth version (%s)",
|
||||
her_appl_version);
|
||||
free (her_appl_version);
|
||||
return KRB5_SENDAUTH_BADAPPLVERS;
|
||||
}
|
||||
}
|
||||
|
||||
n = krb5_net_read (context, p_fd, &len, 4);
|
||||
if (n < 0) {
|
||||
ret = errno;
|
||||
krb5_set_error_string (context, "read: %s", strerror(errno));
|
||||
return ret;
|
||||
}
|
||||
if (n == 0) {
|
||||
krb5_clear_error_string (context);
|
||||
return KRB5_SENDAUTH_BADAPPLVERS;
|
||||
}
|
||||
len = ntohl(len);
|
||||
her_appl_version = malloc (len);
|
||||
if (her_appl_version == NULL) {
|
||||
repl = 2;
|
||||
krb5_net_write (context, p_fd, &repl, 1);
|
||||
krb5_set_error_string (context, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
if (krb5_net_read (context, p_fd, her_appl_version, len) != len
|
||||
|| !(*match_appl_version)(match_data, her_appl_version)) {
|
||||
repl = 2;
|
||||
krb5_net_write (context, p_fd, &repl, 1);
|
||||
krb5_set_error_string (context, "wrong sendauth version (%s)",
|
||||
her_appl_version);
|
||||
free (her_appl_version);
|
||||
return KRB5_SENDAUTH_BADAPPLVERS;
|
||||
}
|
||||
free (her_appl_version);
|
||||
|
||||
repl = 0;
|
||||
if (krb5_net_write (context, p_fd, &repl, 1) != 1) {
|
||||
ret = errno;
|
||||
krb5_set_error_string (context, "write: %s", strerror(errno));
|
||||
return ret;
|
||||
}
|
||||
repl = 0;
|
||||
if (krb5_net_write (context, p_fd, &repl, 1) != 1) {
|
||||
ret = errno;
|
||||
krb5_set_error_string (context, "write: %s", strerror(errno));
|
||||
return ret;
|
||||
}
|
||||
|
||||
krb5_data_zero (&data);
|
||||
ret = krb5_read_message (context, p_fd, &data);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = krb5_rd_req (context,
|
||||
auth_context,
|
||||
&data,
|
||||
server,
|
||||
keytab,
|
||||
&ap_options,
|
||||
ticket);
|
||||
krb5_data_free (&data);
|
||||
if (ret) {
|
||||
krb5_data error_data;
|
||||
krb5_error_code ret2;
|
||||
|
||||
ret2 = krb5_mk_error (context,
|
||||
ret,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
server,
|
||||
NULL,
|
||||
NULL,
|
||||
&error_data);
|
||||
if (ret2 == 0) {
|
||||
krb5_write_message (context, p_fd, &error_data);
|
||||
krb5_data_free (&error_data);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
len = 0;
|
||||
if (krb5_net_write (context, p_fd, &len, 4) != 4) {
|
||||
ret = errno;
|
||||
krb5_set_error_string (context, "write: %s", strerror(errno));
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (ap_options & AP_OPTS_MUTUAL_REQUIRED) {
|
||||
ret = krb5_mk_rep (context, *auth_context, &data);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = krb5_write_message (context, p_fd, &data);
|
||||
krb5_data_zero (&data);
|
||||
ret = krb5_read_message (context, p_fd, &data);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = krb5_rd_req (context,
|
||||
auth_context,
|
||||
&data,
|
||||
server,
|
||||
keytab,
|
||||
&ap_options,
|
||||
ticket);
|
||||
krb5_data_free (&data);
|
||||
}
|
||||
return 0;
|
||||
if (ret) {
|
||||
krb5_data error_data;
|
||||
krb5_error_code ret2;
|
||||
|
||||
ret2 = krb5_mk_error (context,
|
||||
ret,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
server,
|
||||
NULL,
|
||||
NULL,
|
||||
&error_data);
|
||||
if (ret2 == 0) {
|
||||
krb5_write_message (context, p_fd, &error_data);
|
||||
krb5_data_free (&error_data);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
len = 0;
|
||||
if (krb5_net_write (context, p_fd, &len, 4) != 4) {
|
||||
ret = errno;
|
||||
krb5_set_error_string (context, "write: %s", strerror(errno));
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (ap_options & AP_OPTS_MUTUAL_REQUIRED) {
|
||||
ret = krb5_mk_rep (context, *auth_context, &data);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = krb5_write_message (context, p_fd, &data);
|
||||
if (ret)
|
||||
return ret;
|
||||
krb5_data_free (&data);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user