aboutsummaryrefslogtreecommitdiff
path: root/lib/krb5/recvauth.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/krb5/recvauth.c')
-rw-r--r--lib/krb5/recvauth.c93
1 files changed, 51 insertions, 42 deletions
diff --git a/lib/krb5/recvauth.c b/lib/krb5/recvauth.c
index 03482851268c..78e98a10fc1b 100644
--- a/lib/krb5/recvauth.c
+++ b/lib/krb5/recvauth.c
@@ -1,40 +1,38 @@
/*
- * Copyright (c) 1997-2007 Kungliga Tekniska Högskolan
- * (Royal Institute of Technology, Stockholm, Sweden).
- * All rights reserved.
+ * Copyright (c) 1997-2007 Kungliga Tekniska Högskolan
+ * (Royal Institute of Technology, Stockholm, Sweden).
+ * All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
*
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
*
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
- * 3. Neither the name of the Institute nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
*/
#include "krb5_locl.h"
-RCSID("$Id: recvauth.c 20306 2007-04-11 11:15:55Z lha $");
-
/*
* See `sendauth.c' for the format.
*/
@@ -45,7 +43,7 @@ match_exact(const void *data, const char *appl_version)
return strcmp(data, appl_version) == 0;
}
-krb5_error_code KRB5_LIB_FUNCTION
+KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_recvauth(krb5_context context,
krb5_auth_context *auth_context,
krb5_pointer p_fd,
@@ -61,11 +59,11 @@ krb5_recvauth(krb5_context context,
keytab, ticket);
}
-krb5_error_code KRB5_LIB_FUNCTION
+KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_recvauth_match_version(krb5_context context,
krb5_auth_context *auth_context,
krb5_pointer p_fd,
- krb5_boolean (*match_appl_version)(const void *,
+ krb5_boolean (*match_appl_version)(const void *,
const char*),
const void *match_data,
krb5_principal server,
@@ -103,11 +101,12 @@ krb5_recvauth_match_version(krb5_context context,
n = krb5_net_read (context, p_fd, &len, 4);
if (n < 0) {
ret = errno;
- krb5_set_error_string (context, "read: %s", strerror(errno));
+ krb5_set_error_message(context, ret, "read: %s", strerror(ret));
return ret;
}
if (n == 0) {
- krb5_set_error_string (context, "Failed to receive sendauth data");
+ krb5_set_error_message(context, KRB5_SENDAUTH_BADAUTHVERS,
+ N_("Failed to receive sendauth data", ""));
return KRB5_SENDAUTH_BADAUTHVERS;
}
len = ntohl(len);
@@ -116,7 +115,7 @@ krb5_recvauth_match_version(krb5_context context,
|| strncmp (version, her_version, len)) {
repl = 1;
krb5_net_write (context, p_fd, &repl, 1);
- krb5_clear_error_string (context);
+ krb5_clear_error_message (context);
return KRB5_SENDAUTH_BADAUTHVERS;
}
}
@@ -124,11 +123,11 @@ krb5_recvauth_match_version(krb5_context context,
n = krb5_net_read (context, p_fd, &len, 4);
if (n < 0) {
ret = errno;
- krb5_set_error_string (context, "read: %s", strerror(errno));
+ krb5_set_error_message(context, ret, "read: %s", strerror(ret));
return ret;
}
if (n == 0) {
- krb5_clear_error_string (context);
+ krb5_clear_error_message (context);
return KRB5_SENDAUTH_BADAPPLVERS;
}
len = ntohl(len);
@@ -136,14 +135,16 @@ krb5_recvauth_match_version(krb5_context context,
if (her_appl_version == NULL) {
repl = 2;
krb5_net_write (context, p_fd, &repl, 1);
- krb5_set_error_string (context, "malloc: out of memory");
+ krb5_set_error_message(context, ENOMEM,
+ N_("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)",
+ krb5_set_error_message(context, KRB5_SENDAUTH_BADAPPLVERS,
+ N_("wrong sendauth version (%s)", ""),
her_appl_version);
free (her_appl_version);
return KRB5_SENDAUTH_BADAPPLVERS;
@@ -153,7 +154,7 @@ krb5_recvauth_match_version(krb5_context context,
repl = 0;
if (krb5_net_write (context, p_fd, &repl, 1) != 1) {
ret = errno;
- krb5_set_error_string (context, "write: %s", strerror(errno));
+ krb5_set_error_message(context, ret, "write: %s", strerror(ret));
return ret;
}
@@ -188,23 +189,31 @@ krb5_recvauth_match_version(krb5_context context,
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));
+ krb5_set_error_message(context, ret, "write: %s", strerror(ret));
+ krb5_free_ticket(context, *ticket);
+ *ticket = NULL;
return ret;
}
if (ap_options & AP_OPTS_MUTUAL_REQUIRED) {
ret = krb5_mk_rep (context, *auth_context, &data);
- if (ret)
+ if (ret) {
+ krb5_free_ticket(context, *ticket);
+ *ticket = NULL;
return ret;
+ }
ret = krb5_write_message (context, p_fd, &data);
- if (ret)
+ if (ret) {
+ krb5_free_ticket(context, *ticket);
+ *ticket = NULL;
return ret;
+ }
krb5_data_free (&data);
}
return 0;