169408Sache/* $NetBSD$ */ 259243Sobrien 359243Sobrien/* 459243Sobrien * Copyright (c) 1997-2000, 2005-2006 Kungliga Tekniska H��gskolan 559243Sobrien * (Royal Institute of Technology, Stockholm, Sweden). 659243Sobrien * All rights reserved. 759243Sobrien * 859243Sobrien * Redistribution and use in source and binary forms, with or without 959243Sobrien * modification, are permitted provided that the following conditions 1059243Sobrien * are met: 1159243Sobrien * 1259243Sobrien * 1. Redistributions of source code must retain the above copyright 1359243Sobrien * notice, this list of conditions and the following disclaimer. 1459243Sobrien * 1559243Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1659243Sobrien * notice, this list of conditions and the following disclaimer in the 1759243Sobrien * documentation and/or other materials provided with the distribution. 1859243Sobrien * 1959243Sobrien * 3. Neither the name of the Institute nor the names of its contributors 2059243Sobrien * may be used to endorse or promote products derived from this software 2159243Sobrien * without specific prior written permission. 2259243Sobrien * 2359243Sobrien * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 2459243Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2559243Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2659243Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 2759243Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2859243Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2959243Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3059243Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3159243Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3259243Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3359243Sobrien * SUCH DAMAGE. 3459243Sobrien */ 3559243Sobrien 3659243Sobrien#include "kadm5_locl.h" 3759243Sobrien 3859243Sobrien__RCSID("$NetBSD$"); 3959243Sobrien 4059243Sobrienkadm5_ret_t 4159243Sobrienkadm5_c_create_principal(void *server_handle, 4259243Sobrien kadm5_principal_ent_t princ, 4359243Sobrien uint32_t mask, 4459243Sobrien const char *password) 4559243Sobrien{ 4659243Sobrien kadm5_client_context *context = server_handle; 4759243Sobrien kadm5_ret_t ret; 4859243Sobrien krb5_storage *sp; 4959243Sobrien unsigned char buf[1024]; 5059243Sobrien int32_t tmp; 5159243Sobrien krb5_data reply; 5259243Sobrien 5359243Sobrien ret = _kadm5_connect(server_handle); 5459243Sobrien if(ret) 5559243Sobrien return ret; 5659243Sobrien 5759243Sobrien sp = krb5_storage_from_mem(buf, sizeof(buf)); 5859243Sobrien if (sp == NULL) { 5959243Sobrien krb5_clear_error_message(context->context); 6059243Sobrien return ENOMEM; 6159243Sobrien } 6259243Sobrien krb5_store_int32(sp, kadm_create); 6359243Sobrien kadm5_store_principal_ent(sp, princ); 6459243Sobrien krb5_store_int32(sp, mask); 6559243Sobrien krb5_store_string(sp, password); 6659243Sobrien ret = _kadm5_client_send(context, sp); 6759243Sobrien krb5_storage_free(sp); 6859243Sobrien if (ret) 6959243Sobrien return ret; 7059243Sobrien ret = _kadm5_client_recv(context, &reply); 7159243Sobrien if(ret) 7259243Sobrien return ret; 7359243Sobrien sp = krb5_storage_from_data (&reply); 7459243Sobrien if (sp == NULL) { 7559243Sobrien krb5_clear_error_message(context->context); 7659243Sobrien krb5_data_free (&reply); 7759243Sobrien return ENOMEM; 7859243Sobrien } 7959243Sobrien krb5_ret_int32(sp, &tmp); 8059243Sobrien krb5_clear_error_message(context->context); 8159243Sobrien krb5_storage_free(sp); 8259243Sobrien krb5_data_free (&reply); 8359243Sobrien return tmp; 8459243Sobrien} 8559243Sobrien 8659243Sobrien