1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * Copyright 2002 Sun Microsystems, Inc. All rights reserved. 3*0Sstevel@tonic-gate * Use is subject to license terms. 4*0Sstevel@tonic-gate */ 5*0Sstevel@tonic-gate 6*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 7*0Sstevel@tonic-gate 8*0Sstevel@tonic-gate /* 9*0Sstevel@tonic-gate * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 10*0Sstevel@tonic-gate * 11*0Sstevel@tonic-gate * Openvision retains the copyright to derivative works of 12*0Sstevel@tonic-gate * this source code. Do *NOT* create a derivative of this 13*0Sstevel@tonic-gate * source code before consulting with your legal department. 14*0Sstevel@tonic-gate * Do *NOT* integrate *ANY* of this source code into another 15*0Sstevel@tonic-gate * product before consulting with your legal department. 16*0Sstevel@tonic-gate * 17*0Sstevel@tonic-gate * For further information, read the top-level Openvision 18*0Sstevel@tonic-gate * copyright which is contained in the top-level MIT Kerberos 19*0Sstevel@tonic-gate * copyright. 20*0Sstevel@tonic-gate * 21*0Sstevel@tonic-gate * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 22*0Sstevel@tonic-gate * 23*0Sstevel@tonic-gate */ 24*0Sstevel@tonic-gate 25*0Sstevel@tonic-gate 26*0Sstevel@tonic-gate /* 27*0Sstevel@tonic-gate * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved 28*0Sstevel@tonic-gate * 29*0Sstevel@tonic-gate * $Header: /cvs/krbdev/krb5/src/lib/kadm5/clnt/clnt_policy.c,v 1.2 1998/02/14 02:32:57 tlyu Exp $ 30*0Sstevel@tonic-gate */ 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #if !defined(lint) && !defined(__CODECENTER__) 33*0Sstevel@tonic-gate static char *rcsid = "$Header: /cvs/krbdev/krb5/src/lib/kadm5/clnt/clnt_policy.c,v 1.2 1998/02/14 02:32:57 tlyu Exp $"; 34*0Sstevel@tonic-gate #endif 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #include <rpc/rpc.h> /* SUNWresync121 XXX */ 37*0Sstevel@tonic-gate #include <kadm5/admin.h> 38*0Sstevel@tonic-gate #include <kadm5/kadm_rpc.h> 39*0Sstevel@tonic-gate #include "client_internal.h" 40*0Sstevel@tonic-gate #include <stdlib.h> 41*0Sstevel@tonic-gate #include <string.h> 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gate kadm5_ret_t 44*0Sstevel@tonic-gate kadm5_create_policy(void *server_handle, 45*0Sstevel@tonic-gate kadm5_policy_ent_t policy, long mask) 46*0Sstevel@tonic-gate { 47*0Sstevel@tonic-gate cpol_arg arg; 48*0Sstevel@tonic-gate generic_ret *r; 49*0Sstevel@tonic-gate kadm5_server_handle_t handle = server_handle; 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate CHECK_HANDLE(server_handle); 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate if(policy == (kadm5_policy_ent_t) NULL) 54*0Sstevel@tonic-gate return EINVAL; 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gate arg.mask = mask; 57*0Sstevel@tonic-gate arg.api_version = handle->api_version; 58*0Sstevel@tonic-gate memcpy(&arg.rec, policy, sizeof(kadm5_policy_ent_rec)); 59*0Sstevel@tonic-gate r = create_policy_1(&arg, handle->clnt); 60*0Sstevel@tonic-gate if(r == NULL) 61*0Sstevel@tonic-gate return KADM5_RPC_ERROR; 62*0Sstevel@tonic-gate return r->code; 63*0Sstevel@tonic-gate } 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate kadm5_ret_t 66*0Sstevel@tonic-gate kadm5_delete_policy(void *server_handle, char *name) 67*0Sstevel@tonic-gate { 68*0Sstevel@tonic-gate dpol_arg arg; 69*0Sstevel@tonic-gate generic_ret *r; 70*0Sstevel@tonic-gate kadm5_server_handle_t handle = server_handle; 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gate CHECK_HANDLE(server_handle); 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate if(name == NULL) 75*0Sstevel@tonic-gate return EINVAL; 76*0Sstevel@tonic-gate 77*0Sstevel@tonic-gate arg.name = name; 78*0Sstevel@tonic-gate arg.api_version = handle->api_version; 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gate r = delete_policy_1(&arg, handle->clnt); 81*0Sstevel@tonic-gate if(r == NULL) 82*0Sstevel@tonic-gate return KADM5_RPC_ERROR; 83*0Sstevel@tonic-gate return r->code; 84*0Sstevel@tonic-gate } 85*0Sstevel@tonic-gate 86*0Sstevel@tonic-gate kadm5_ret_t 87*0Sstevel@tonic-gate kadm5_modify_policy(void *server_handle, 88*0Sstevel@tonic-gate kadm5_policy_ent_t policy, long mask) 89*0Sstevel@tonic-gate 90*0Sstevel@tonic-gate { 91*0Sstevel@tonic-gate mpol_arg arg; 92*0Sstevel@tonic-gate generic_ret *r; 93*0Sstevel@tonic-gate kadm5_server_handle_t handle = server_handle; 94*0Sstevel@tonic-gate 95*0Sstevel@tonic-gate CHECK_HANDLE(server_handle); 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gate if(policy == (kadm5_policy_ent_t) NULL) 98*0Sstevel@tonic-gate return EINVAL; 99*0Sstevel@tonic-gate 100*0Sstevel@tonic-gate arg.mask = mask; 101*0Sstevel@tonic-gate arg.api_version = handle->api_version; 102*0Sstevel@tonic-gate 103*0Sstevel@tonic-gate memcpy(&arg.rec, policy, sizeof(kadm5_policy_ent_rec)); 104*0Sstevel@tonic-gate r = modify_policy_1(&arg, handle->clnt); 105*0Sstevel@tonic-gate if(r == NULL) 106*0Sstevel@tonic-gate return KADM5_RPC_ERROR; 107*0Sstevel@tonic-gate return r->code; 108*0Sstevel@tonic-gate } 109*0Sstevel@tonic-gate 110*0Sstevel@tonic-gate kadm5_ret_t 111*0Sstevel@tonic-gate kadm5_get_policy(void *server_handle, char *name, kadm5_policy_ent_t ent) 112*0Sstevel@tonic-gate 113*0Sstevel@tonic-gate { 114*0Sstevel@tonic-gate gpol_arg arg; 115*0Sstevel@tonic-gate gpol_ret *r; 116*0Sstevel@tonic-gate kadm5_server_handle_t handle = server_handle; 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate CHECK_HANDLE(server_handle); 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate arg.name = name; 121*0Sstevel@tonic-gate arg.api_version = handle->api_version; 122*0Sstevel@tonic-gate 123*0Sstevel@tonic-gate if(name == NULL) 124*0Sstevel@tonic-gate return EINVAL; 125*0Sstevel@tonic-gate 126*0Sstevel@tonic-gate r = get_policy_1(&arg, handle->clnt); 127*0Sstevel@tonic-gate if(r == NULL) 128*0Sstevel@tonic-gate return KADM5_RPC_ERROR; 129*0Sstevel@tonic-gate if (handle->api_version == KADM5_API_VERSION_1) { 130*0Sstevel@tonic-gate kadm5_policy_ent_t *entp; 131*0Sstevel@tonic-gate 132*0Sstevel@tonic-gate entp = (kadm5_policy_ent_t *) ent; 133*0Sstevel@tonic-gate if(r->code == 0) { 134*0Sstevel@tonic-gate if (!(*entp = (kadm5_policy_ent_t) 135*0Sstevel@tonic-gate malloc(sizeof(kadm5_policy_ent_rec)))) 136*0Sstevel@tonic-gate return ENOMEM; 137*0Sstevel@tonic-gate memcpy(*entp, &r->rec, sizeof(**entp)); 138*0Sstevel@tonic-gate } else { 139*0Sstevel@tonic-gate *entp = NULL; 140*0Sstevel@tonic-gate } 141*0Sstevel@tonic-gate } else { 142*0Sstevel@tonic-gate if (r->code == 0) 143*0Sstevel@tonic-gate memcpy(ent, &r->rec, sizeof(r->rec)); 144*0Sstevel@tonic-gate } 145*0Sstevel@tonic-gate 146*0Sstevel@tonic-gate return r->code; 147*0Sstevel@tonic-gate } 148*0Sstevel@tonic-gate 149*0Sstevel@tonic-gate kadm5_ret_t 150*0Sstevel@tonic-gate kadm5_get_policies(void *server_handle, 151*0Sstevel@tonic-gate char *exp, char ***pols, int *count) 152*0Sstevel@tonic-gate { 153*0Sstevel@tonic-gate gpols_arg arg; 154*0Sstevel@tonic-gate gpols_ret *r; 155*0Sstevel@tonic-gate kadm5_server_handle_t handle = server_handle; 156*0Sstevel@tonic-gate 157*0Sstevel@tonic-gate CHECK_HANDLE(server_handle); 158*0Sstevel@tonic-gate 159*0Sstevel@tonic-gate if(pols == NULL || count == NULL) 160*0Sstevel@tonic-gate return EINVAL; 161*0Sstevel@tonic-gate arg.exp = exp; 162*0Sstevel@tonic-gate arg.api_version = handle->api_version; 163*0Sstevel@tonic-gate r = get_pols_1(&arg, handle->clnt); 164*0Sstevel@tonic-gate if(r == NULL) 165*0Sstevel@tonic-gate return KADM5_RPC_ERROR; 166*0Sstevel@tonic-gate if(r->code == 0) { 167*0Sstevel@tonic-gate *count = r->count; 168*0Sstevel@tonic-gate *pols = r->pols; 169*0Sstevel@tonic-gate } else { 170*0Sstevel@tonic-gate *count = 0; 171*0Sstevel@tonic-gate *pols = NULL; 172*0Sstevel@tonic-gate } 173*0Sstevel@tonic-gate 174*0Sstevel@tonic-gate return r->code; 175*0Sstevel@tonic-gate } 176