198944Sobrien/* $NetBSD: rename_c.c,v 1.2 2017/01/28 21:31:49 christos Exp $ */ 298944Sobrien 398944Sobrien/* 498944Sobrien * Copyright (c) 1997 - 1999 Kungliga Tekniska H��gskolan 598944Sobrien * (Royal Institute of Technology, Stockholm, Sweden). 698944Sobrien * All rights reserved. 798944Sobrien * 898944Sobrien * Redistribution and use in source and binary forms, with or without 998944Sobrien * modification, are permitted provided that the following conditions 1098944Sobrien * are met: 1198944Sobrien * 1298944Sobrien * 1. Redistributions of source code must retain the above copyright 1398944Sobrien * notice, this list of conditions and the following disclaimer. 1498944Sobrien * 1598944Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1698944Sobrien * notice, this list of conditions and the following disclaimer in the 1798944Sobrien * documentation and/or other materials provided with the distribution. 1898944Sobrien * 1998944Sobrien * 3. Neither the name of the Institute nor the names of its contributors 2098944Sobrien * may be used to endorse or promote products derived from this software 2198944Sobrien * without specific prior written permission. 2298944Sobrien * 23130803Smarcel * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 2498944Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2598944Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2698944Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 2798944Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2898944Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2998944Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3098944Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3198944Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3298944Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3398944Sobrien * SUCH DAMAGE. 3498944Sobrien */ 3598944Sobrien 3698944Sobrien#include "kadm5_locl.h" 3798944Sobrien 3898944Sobrien__RCSID("$NetBSD: rename_c.c,v 1.2 2017/01/28 21:31:49 christos Exp $"); 3998944Sobrien 4098944Sobrienkadm5_ret_t 4198944Sobrienkadm5_c_rename_principal(void *server_handle, 4298944Sobrien krb5_principal source, 4398944Sobrien krb5_principal target) 4498944Sobrien{ 4598944Sobrien kadm5_client_context *context = server_handle; 4698944Sobrien kadm5_ret_t ret; 4798944Sobrien krb5_storage *sp; 4898944Sobrien unsigned char buf[1024]; 4998944Sobrien int32_t tmp; 5098944Sobrien krb5_data reply; 5198944Sobrien 5298944Sobrien ret = _kadm5_connect(server_handle); 5398944Sobrien if(ret) 5498944Sobrien return ret; 5598944Sobrien 5698944Sobrien sp = krb5_storage_from_mem(buf, sizeof(buf)); 5798944Sobrien if (sp == NULL) 5898944Sobrien return ENOMEM; 5998944Sobrien krb5_store_int32(sp, kadm_rename); 6098944Sobrien krb5_store_principal(sp, source); 6198944Sobrien krb5_store_principal(sp, target); 6298944Sobrien ret = _kadm5_client_send(context, sp); 6398944Sobrien krb5_storage_free(sp); 6498944Sobrien if (ret) 6598944Sobrien return ret; 6698944Sobrien ret = _kadm5_client_recv(context, &reply); 6798944Sobrien if(ret) 6898944Sobrien return ret; 6998944Sobrien sp = krb5_storage_from_data (&reply); 7098944Sobrien if (sp == NULL) { 7198944Sobrien krb5_data_free (&reply); 7298944Sobrien return ENOMEM; 7398944Sobrien } 7498944Sobrien krb5_ret_int32(sp, &tmp); 7598944Sobrien ret = tmp; 7698944Sobrien krb5_storage_free(sp); 7798944Sobrien krb5_data_free (&reply); 7898944Sobrien return ret; 7998944Sobrien} 8098944Sobrien