delete_c.c revision 1.1.1.1.22.1
1285SN/A/* $NetBSD: delete_c.c,v 1.1.1.1.22.1 2014/08/10 06:47:30 tls Exp $ */ 2285SN/A 3285SN/A/* 4285SN/A * Copyright (c) 1997 - 1999 Kungliga Tekniska H��gskolan 5285SN/A * (Royal Institute of Technology, Stockholm, Sweden). 6462SN/A * All rights reserved. 7285SN/A * 8285SN/A * Redistribution and use in source and binary forms, with or without 9285SN/A * modification, are permitted provided that the following conditions 10285SN/A * are met: 11285SN/A * 12285SN/A * 1. Redistributions of source code must retain the above copyright 13285SN/A * notice, this list of conditions and the following disclaimer. 14285SN/A * 15285SN/A * 2. Redistributions in binary form must reproduce the above copyright 16285SN/A * notice, this list of conditions and the following disclaimer in the 17285SN/A * documentation and/or other materials provided with the distribution. 18285SN/A * 19285SN/A * 3. Neither the name of the Institute nor the names of its contributors 20285SN/A * may be used to endorse or promote products derived from this software 21285SN/A * without specific prior written permission. 22285SN/A * 23285SN/A * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 24285SN/A * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25285SN/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26285SN/A * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 27285SN/A * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28285SN/A * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29285SN/A * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30285SN/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31285SN/A * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32285SN/A * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33285SN/A * SUCH DAMAGE. 34285SN/A */ 35285SN/A 36285SN/A#include "kadm5_locl.h" 37285SN/A 38285SN/A__RCSID("NetBSD"); 39285SN/A 40285SN/Akadm5_ret_t 41285SN/Akadm5_c_delete_principal(void *server_handle, krb5_principal princ) 42285SN/A{ 43285SN/A kadm5_client_context *context = server_handle; 44285SN/A kadm5_ret_t ret; 45285SN/A krb5_storage *sp; 46285SN/A unsigned char buf[1024]; 47285SN/A int32_t tmp; 48285SN/A krb5_data reply; 49285SN/A 50285SN/A ret = _kadm5_connect(server_handle); 51285SN/A if(ret) 52285SN/A return ret; 53285SN/A 54285SN/A sp = krb5_storage_from_mem(buf, sizeof(buf)); 55285SN/A if (sp == NULL) { 56285SN/A krb5_clear_error_message(context->context); 57285SN/A return ENOMEM; 58285SN/A } 59285SN/A krb5_store_int32(sp, kadm_delete); 60285SN/A krb5_store_principal(sp, princ); 61285SN/A ret = _kadm5_client_send(context, sp); 62285SN/A krb5_storage_free(sp); 63285SN/A if (ret) 64285SN/A return ret; 65285SN/A ret = _kadm5_client_recv(context, &reply); 66285SN/A if (ret) 67285SN/A return ret; 68285SN/A sp = krb5_storage_from_data (&reply); 69285SN/A if(sp == NULL) { 70285SN/A krb5_clear_error_message(context->context); 71285SN/A krb5_data_free (&reply); 72285SN/A return ENOMEM; 73285SN/A } 74285SN/A krb5_ret_int32(sp, &tmp); 75285SN/A krb5_clear_error_message(context->context); 76285SN/A krb5_storage_free(sp); 77285SN/A krb5_data_free (&reply); 78285SN/A return tmp; 79285SN/A} 80285SN/A