1184588Sdfr/*- 2184588Sdfr * Copyright (c) 2008 Isilon Inc http://www.isilon.com/ 3184588Sdfr * Authors: Doug Rabson <dfr@rabson.org> 4184588Sdfr * Developed with Red Inc: Alfred Perlstein <alfred@freebsd.org> 5184588Sdfr * 6184588Sdfr * Redistribution and use in source and binary forms, with or without 7184588Sdfr * modification, are permitted provided that the following conditions 8184588Sdfr * are met: 9184588Sdfr * 1. Redistributions of source code must retain the above copyright 10184588Sdfr * notice, this list of conditions and the following disclaimer. 11184588Sdfr * 2. Redistributions in binary form must reproduce the above copyright 12184588Sdfr * notice, this list of conditions and the following disclaimer in the 13184588Sdfr * documentation and/or other materials provided with the distribution. 14184588Sdfr * 15184588Sdfr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16184588Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17184588Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18184588Sdfr * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19184588Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20184588Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21184588Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22184588Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23184588Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24184588Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25184588Sdfr * SUCH DAMAGE. 26184588Sdfr */ 27184588Sdfr 28184588Sdfr#include <sys/cdefs.h> 29184588Sdfr__FBSDID("$FreeBSD: releng/10.3/sys/kgssapi/gss_set_cred_option.c 244370 2012-12-18 00:25:48Z rmacklem $"); 30184588Sdfr 31184588Sdfr#include <sys/param.h> 32184588Sdfr#include <sys/kernel.h> 33184588Sdfr#include <sys/kobj.h> 34244370Srmacklem#include <sys/lock.h> 35184588Sdfr#include <sys/malloc.h> 36244370Srmacklem#include <sys/mutex.h> 37184588Sdfr 38184588Sdfr#include <kgssapi/gssapi.h> 39184588Sdfr#include <kgssapi/gssapi_impl.h> 40184588Sdfr 41184588Sdfr#include "gssd.h" 42184588Sdfr 43184588SdfrOM_uint32 44184588Sdfrgss_set_cred_option(OM_uint32 *minor_status, 45184588Sdfr gss_cred_id_t *cred, 46184588Sdfr const gss_OID option_name, 47184588Sdfr const gss_buffer_t option_value) 48184588Sdfr{ 49184588Sdfr struct set_cred_option_res res; 50184588Sdfr struct set_cred_option_args args; 51184588Sdfr enum clnt_stat stat; 52244370Srmacklem CLIENT *cl; 53184588Sdfr 54184588Sdfr *minor_status = 0; 55184588Sdfr 56244370Srmacklem cl = kgss_gssd_client(); 57244370Srmacklem if (cl == NULL) 58184588Sdfr return (GSS_S_FAILURE); 59184588Sdfr 60184588Sdfr if (cred) 61184588Sdfr args.cred = (*cred)->handle; 62184588Sdfr else 63184588Sdfr args.cred = 0; 64184588Sdfr args.option_name = option_name; 65184588Sdfr args.option_value = *option_value; 66184588Sdfr 67184588Sdfr bzero(&res, sizeof(res)); 68244370Srmacklem stat = gssd_set_cred_option_1(&args, &res, cl); 69244370Srmacklem CLNT_RELEASE(cl); 70184588Sdfr 71184588Sdfr if (stat != RPC_SUCCESS) { 72184588Sdfr *minor_status = stat; 73184588Sdfr return (GSS_S_FAILURE); 74184588Sdfr } 75184588Sdfr 76184588Sdfr if (res.major_status != GSS_S_COMPLETE) { 77184588Sdfr *minor_status = res.minor_status; 78184588Sdfr return (res.major_status); 79184588Sdfr } 80184588Sdfr 81184588Sdfr return (GSS_S_COMPLETE); 82184588Sdfr} 83