From 0dff021161863972c0e482d0c7a24f10076df287 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sun, 20 Mar 2011 20:57:24 +1100 Subject: [PATCH] add krb5 glue for userok --- lib/gssapi/Makefile.am | 1 + lib/gssapi/gssapi_mech.h | 4 ++-- lib/gssapi/krb5/external.c | 5 +++- lib/gssapi/krb5/userok.c | 50 ++++++++++++++++++++++++++++++++++++++++ lib/gssapi/libgssapi-exports.def | 10 ++++++++ 5 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 lib/gssapi/krb5/userok.c diff --git a/lib/gssapi/Makefile.am b/lib/gssapi/Makefile.am index 5b525d849..a321efd01 100644 --- a/lib/gssapi/Makefile.am +++ b/lib/gssapi/Makefile.am @@ -70,6 +70,7 @@ krb5src = \ krb5/set_sec_context_option.c \ krb5/ticket_flags.c \ krb5/unwrap.c \ + krb5/userok.c \ krb5/verify_mic.c \ krb5/wrap.c diff --git a/lib/gssapi/gssapi_mech.h b/lib/gssapi/gssapi_mech.h index 241be1391..43d737ef9 100644 --- a/lib/gssapi/gssapi_mech.h +++ b/lib/gssapi/gssapi_mech.h @@ -564,6 +564,8 @@ typedef struct gssapi_mech_interface_desc { _gss_cred_label_set_t *gm_cred_label_set; gss_mo_desc *gm_mo; size_t gm_mo_num; + _gss_pname_to_uid_t *gm_pname_to_uid; + _gss_userok_t *gm_userok; _gss_display_name_ext_t *gm_display_name_ext; _gss_inquire_name_t *gm_inquire_name; _gss_get_name_attribute_t *gm_get_name_attribute; @@ -572,8 +574,6 @@ typedef struct gssapi_mech_interface_desc { _gss_export_name_composite_t *gm_export_name_composite; _gss_acquire_cred_with_password_t *gm_acquire_cred_with_password; _gss_add_cred_with_password_t *gm_add_cred_with_password; - _gss_pname_to_uid_t *gm_pname_to_uid; - _gss_userok_t *gm_userok; struct gss_mech_compat_desc_struct *gm_compat; } gssapi_mech_interface_desc, *gssapi_mech_interface; diff --git a/lib/gssapi/krb5/external.c b/lib/gssapi/krb5/external.c index d6f14a48f..43d17dbe5 100644 --- a/lib/gssapi/krb5/external.c +++ b/lib/gssapi/krb5/external.c @@ -323,7 +323,10 @@ static gssapi_mech_interface_desc krb5_mech = { NULL, NULL, krb5_mo, - sizeof(krb5_mo) / sizeof(krb5_mo[0]) + sizeof(krb5_mo) / sizeof(krb5_mo[0]), + NULL, + _gsskrb5_userok, + NULL }; gssapi_mech_interface diff --git a/lib/gssapi/krb5/userok.c b/lib/gssapi/krb5/userok.c new file mode 100644 index 000000000..af53ea735 --- /dev/null +++ b/lib/gssapi/krb5/userok.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2011, PADL Software Pty Ltd. + * All rights reserved. + * + * 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. + * + * 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 PADL Software 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 PADL SOFTWARE 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 PADL SOFTWARE 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 "gsskrb5_locl.h" + +OM_uint32 +_gsskrb5_userok(OM_uint32 *minor_status, + const gss_name_t input_name, + const char *user, + int *user_ok) +{ + krb5_context context; + krb5_const_principal princ = (krb5_const_principal)input_name; + + GSSAPI_KRB5_INIT(&context); + + *minor_status = 0; + *user_ok = krb5_kuserok(context, princ, user); + + return GSS_S_COMPLETE; +} diff --git a/lib/gssapi/libgssapi-exports.def b/lib/gssapi/libgssapi-exports.def index ee3aaf3b3..ed31953a6 100644 --- a/lib/gssapi/libgssapi-exports.def +++ b/lib/gssapi/libgssapi-exports.def @@ -11,8 +11,10 @@ EXPORTS __gss_c_attr_stream_sizes_oid_desc DATA gss_accept_sec_context gss_acquire_cred + gss_acquire_cred_with_password gss_add_buffer_set_member gss_add_cred + gss_add_cred_with_password gss_add_oid_set_member gss_canonicalize_name gss_compare_name @@ -21,17 +23,21 @@ EXPORTS gss_create_empty_buffer_set gss_create_empty_oid_set gss_decapsulate_token + gss_delete_name_attribute gss_delete_sec_context gss_display_mech_attr gss_display_name + gss_display_name_ext gss_display_status gss_duplicate_name gss_duplicate_oid gss_encapsulate_token gss_export_cred gss_export_name + gss_export_name_composite gss_export_sec_context gss_get_mic + gss_get_name_attribute gss_import_cred gss_import_name gss_import_sec_context @@ -45,6 +51,7 @@ EXPORTS gss_inquire_cred_by_oid gss_inquire_mech_for_saslname gss_inquire_mechs_for_name + gss_inquire_name gss_inquire_names_for_mech gss_inquire_saslname_for_mech gss_inquire_sec_context_by_oid ;! @@ -64,6 +71,7 @@ EXPORTS gss_oid_to_name gss_oid_equal gss_oid_to_str + gss_pname_to_uid gss_process_context_token gss_pseudo_random gss_release_buffer @@ -75,12 +83,14 @@ EXPORTS gss_release_oid_set gss_seal gss_set_cred_option + gss_set_name_attribute gss_set_sec_context_option gss_sign gss_test_oid_set_member gss_unseal gss_unwrap gss_unwrap_iov + gss_userok gss_verify gss_verify_mic gss_wrap -- 2.11.4.GIT