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 30*0Sstevel@tonic-gate #include <rpc/rpc.h> 31*0Sstevel@tonic-gate #include <krb5.h> 32*0Sstevel@tonic-gate #include <k5-int.h> 33*0Sstevel@tonic-gate #include <kadm5/admin.h> 34*0Sstevel@tonic-gate #include <kadm5/kadm_rpc.h> 35*0Sstevel@tonic-gate #include <stdlib.h> 36*0Sstevel@tonic-gate #include <string.h> 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gate static bool_t 39*0Sstevel@tonic-gate _xdr_kadm5_principal_ent_rec(XDR *xdrs, kadm5_principal_ent_rec *objp, 40*0Sstevel@tonic-gate int v); 41*0Sstevel@tonic-gate 42*0Sstevel@tonic-gate bool_t 43*0Sstevel@tonic-gate xdr_krb5_salttype(XDR *xdrs, krb5_int32 *objp); /* SUNWresync121 XXX */ 44*0Sstevel@tonic-gate /* 45*0Sstevel@tonic-gate * Function: xdr_ui_4 46*0Sstevel@tonic-gate * 47*0Sstevel@tonic-gate * Purpose: XDR function which serves as a wrapper for xdr_u_int, 48*0Sstevel@tonic-gate * to prevent compiler warnings about type clashes between u_int32 49*0Sstevel@tonic-gate * and krb5_ui_4. 50*0Sstevel@tonic-gate */ 51*0Sstevel@tonic-gate bool_t xdr_ui_4(XDR *xdrs, krb5_ui_4 *objp) 52*0Sstevel@tonic-gate { 53*0Sstevel@tonic-gate /* Assumes that krb5_ui_4 and u_int32 are both four bytes long. 54*0Sstevel@tonic-gate This should not be a harmful assumption. */ 55*0Sstevel@tonic-gate return xdr_u_int(xdrs, (rpc_u_int32 *) objp); 56*0Sstevel@tonic-gate } 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate /* 60*0Sstevel@tonic-gate * Function: xdr_nullstring 61*0Sstevel@tonic-gate * 62*0Sstevel@tonic-gate * Purpose: XDR function for "strings" that are either NULL-terminated 63*0Sstevel@tonic-gate * or NULL. 64*0Sstevel@tonic-gate */ 65*0Sstevel@tonic-gate bool_t xdr_nullstring(XDR *xdrs, char **objp) 66*0Sstevel@tonic-gate { 67*0Sstevel@tonic-gate u_int size; 68*0Sstevel@tonic-gate 69*0Sstevel@tonic-gate if (xdrs->x_op == XDR_ENCODE) { 70*0Sstevel@tonic-gate if (*objp == NULL) 71*0Sstevel@tonic-gate size = 0; 72*0Sstevel@tonic-gate else 73*0Sstevel@tonic-gate size = strlen(*objp) + 1; 74*0Sstevel@tonic-gate } 75*0Sstevel@tonic-gate if (! xdr_u_int(xdrs, &size)) { 76*0Sstevel@tonic-gate return FALSE; 77*0Sstevel@tonic-gate } 78*0Sstevel@tonic-gate switch (xdrs->x_op) { 79*0Sstevel@tonic-gate case XDR_DECODE: 80*0Sstevel@tonic-gate if (size == 0) { 81*0Sstevel@tonic-gate *objp = NULL; 82*0Sstevel@tonic-gate return TRUE; 83*0Sstevel@tonic-gate } else if (*objp == NULL) { 84*0Sstevel@tonic-gate *objp = (char *) mem_alloc(size); 85*0Sstevel@tonic-gate if (*objp == NULL) { 86*0Sstevel@tonic-gate errno = ENOMEM; 87*0Sstevel@tonic-gate return FALSE; 88*0Sstevel@tonic-gate } 89*0Sstevel@tonic-gate } 90*0Sstevel@tonic-gate return (xdr_opaque(xdrs, *objp, size)); 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate case XDR_ENCODE: 93*0Sstevel@tonic-gate if (size != 0) 94*0Sstevel@tonic-gate return (xdr_opaque(xdrs, *objp, size)); 95*0Sstevel@tonic-gate return TRUE; 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gate case XDR_FREE: 98*0Sstevel@tonic-gate if (*objp != NULL) 99*0Sstevel@tonic-gate mem_free(*objp, size); 100*0Sstevel@tonic-gate *objp = NULL; 101*0Sstevel@tonic-gate return TRUE; 102*0Sstevel@tonic-gate } 103*0Sstevel@tonic-gate 104*0Sstevel@tonic-gate return FALSE; 105*0Sstevel@tonic-gate } 106*0Sstevel@tonic-gate 107*0Sstevel@tonic-gate /* 108*0Sstevel@tonic-gate * Function: xdr_nulltype 109*0Sstevel@tonic-gate * 110*0Sstevel@tonic-gate * Purpose: XDR function for arbitrary pointer types that are either 111*0Sstevel@tonic-gate * NULL or contain data. 112*0Sstevel@tonic-gate */ 113*0Sstevel@tonic-gate bool_t xdr_nulltype(XDR *xdrs, void **objp, xdrproc_t proc) 114*0Sstevel@tonic-gate { 115*0Sstevel@tonic-gate bool_t null; 116*0Sstevel@tonic-gate 117*0Sstevel@tonic-gate switch (xdrs->x_op) { 118*0Sstevel@tonic-gate case XDR_DECODE: 119*0Sstevel@tonic-gate if (!xdr_bool(xdrs, &null)) 120*0Sstevel@tonic-gate return FALSE; 121*0Sstevel@tonic-gate if (null) { 122*0Sstevel@tonic-gate *objp = NULL; 123*0Sstevel@tonic-gate return TRUE; 124*0Sstevel@tonic-gate } 125*0Sstevel@tonic-gate return (*proc)(xdrs, objp); 126*0Sstevel@tonic-gate 127*0Sstevel@tonic-gate case XDR_ENCODE: 128*0Sstevel@tonic-gate if (*objp == NULL) 129*0Sstevel@tonic-gate null = TRUE; 130*0Sstevel@tonic-gate else 131*0Sstevel@tonic-gate null = FALSE; 132*0Sstevel@tonic-gate if (!xdr_bool(xdrs, &null)) 133*0Sstevel@tonic-gate return FALSE; 134*0Sstevel@tonic-gate if (null == FALSE) 135*0Sstevel@tonic-gate return (*proc)(xdrs, objp); 136*0Sstevel@tonic-gate return TRUE; 137*0Sstevel@tonic-gate 138*0Sstevel@tonic-gate case XDR_FREE: 139*0Sstevel@tonic-gate if (*objp) 140*0Sstevel@tonic-gate return (*proc)(xdrs, objp); 141*0Sstevel@tonic-gate return TRUE; 142*0Sstevel@tonic-gate } 143*0Sstevel@tonic-gate 144*0Sstevel@tonic-gate return FALSE; 145*0Sstevel@tonic-gate } 146*0Sstevel@tonic-gate 147*0Sstevel@tonic-gate bool_t 148*0Sstevel@tonic-gate xdr_krb5_timestamp(XDR *xdrs, krb5_timestamp *objp) 149*0Sstevel@tonic-gate { 150*0Sstevel@tonic-gate /* This assumes that int32 and krb5_timestamp are the same size. 151*0Sstevel@tonic-gate This shouldn't be a problem, since we've got a unit test which 152*0Sstevel@tonic-gate checks for this. */ 153*0Sstevel@tonic-gate if (!xdr_int(xdrs, (rpc_int32 *) objp)) { 154*0Sstevel@tonic-gate return (FALSE); 155*0Sstevel@tonic-gate } 156*0Sstevel@tonic-gate return (TRUE); 157*0Sstevel@tonic-gate } 158*0Sstevel@tonic-gate 159*0Sstevel@tonic-gate bool_t 160*0Sstevel@tonic-gate xdr_krb5_kvno(XDR *xdrs, krb5_kvno *objp) 161*0Sstevel@tonic-gate { 162*0Sstevel@tonic-gate unsigned char tmp; 163*0Sstevel@tonic-gate 164*0Sstevel@tonic-gate tmp = '\0'; /* for purify, else xdr_u_char performs a umr */ 165*0Sstevel@tonic-gate 166*0Sstevel@tonic-gate if (xdrs->x_op == XDR_ENCODE) 167*0Sstevel@tonic-gate tmp = (unsigned char) *objp; 168*0Sstevel@tonic-gate 169*0Sstevel@tonic-gate if (!xdr_u_char(xdrs, &tmp)) 170*0Sstevel@tonic-gate return (FALSE); 171*0Sstevel@tonic-gate 172*0Sstevel@tonic-gate if (xdrs->x_op == XDR_DECODE) 173*0Sstevel@tonic-gate *objp = (krb5_kvno) tmp; 174*0Sstevel@tonic-gate 175*0Sstevel@tonic-gate return (TRUE); 176*0Sstevel@tonic-gate } 177*0Sstevel@tonic-gate 178*0Sstevel@tonic-gate bool_t 179*0Sstevel@tonic-gate xdr_krb5_deltat(XDR *xdrs, krb5_deltat *objp) 180*0Sstevel@tonic-gate { 181*0Sstevel@tonic-gate /* This assumes that int32 and krb5_deltat are the same size. 182*0Sstevel@tonic-gate This shouldn't be a problem, since we've got a unit test which 183*0Sstevel@tonic-gate checks for this. */ 184*0Sstevel@tonic-gate if (!xdr_int(xdrs, (rpc_int32 *) objp)) { 185*0Sstevel@tonic-gate return (FALSE); 186*0Sstevel@tonic-gate } 187*0Sstevel@tonic-gate return (TRUE); 188*0Sstevel@tonic-gate } 189*0Sstevel@tonic-gate 190*0Sstevel@tonic-gate bool_t 191*0Sstevel@tonic-gate xdr_krb5_flags(XDR *xdrs, krb5_flags *objp) 192*0Sstevel@tonic-gate { 193*0Sstevel@tonic-gate /* This assumes that int32 and krb5_flags are the same size. 194*0Sstevel@tonic-gate This shouldn't be a problem, since we've got a unit test which 195*0Sstevel@tonic-gate checks for this. */ 196*0Sstevel@tonic-gate if (!xdr_int(xdrs, (rpc_int32 *) objp)) { 197*0Sstevel@tonic-gate return (FALSE); 198*0Sstevel@tonic-gate } 199*0Sstevel@tonic-gate return (TRUE); 200*0Sstevel@tonic-gate } 201*0Sstevel@tonic-gate 202*0Sstevel@tonic-gate bool_t 203*0Sstevel@tonic-gate xdr_krb5_ui_4(XDR *xdrs, krb5_ui_4 *objp) 204*0Sstevel@tonic-gate { 205*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, (rpc_u_int32 *) objp)) { 206*0Sstevel@tonic-gate return (FALSE); 207*0Sstevel@tonic-gate } 208*0Sstevel@tonic-gate return (TRUE); 209*0Sstevel@tonic-gate } 210*0Sstevel@tonic-gate 211*0Sstevel@tonic-gate bool_t 212*0Sstevel@tonic-gate xdr_krb5_int16(XDR *xdrs, krb5_int16 *objp) 213*0Sstevel@tonic-gate { 214*0Sstevel@tonic-gate int tmp; 215*0Sstevel@tonic-gate 216*0Sstevel@tonic-gate tmp = (int) *objp; 217*0Sstevel@tonic-gate 218*0Sstevel@tonic-gate if (!xdr_int(xdrs, &tmp)) 219*0Sstevel@tonic-gate return(FALSE); 220*0Sstevel@tonic-gate 221*0Sstevel@tonic-gate *objp = (krb5_int16) tmp; 222*0Sstevel@tonic-gate 223*0Sstevel@tonic-gate return(TRUE); 224*0Sstevel@tonic-gate } 225*0Sstevel@tonic-gate 226*0Sstevel@tonic-gate bool_t xdr_krb5_key_data_nocontents(XDR *xdrs, krb5_key_data *objp) 227*0Sstevel@tonic-gate { 228*0Sstevel@tonic-gate /* 229*0Sstevel@tonic-gate * Note that this function intentionally DOES NOT tranfer key 230*0Sstevel@tonic-gate * length or contents! xdr_krb5_key_data in adb_xdr.c does, but 231*0Sstevel@tonic-gate * that is only for use within the server-side library. 232*0Sstevel@tonic-gate */ 233*0Sstevel@tonic-gate unsigned int tmp; 234*0Sstevel@tonic-gate 235*0Sstevel@tonic-gate if (xdrs->x_op == XDR_DECODE) 236*0Sstevel@tonic-gate memset((char *) objp, 0, sizeof(krb5_key_data)); 237*0Sstevel@tonic-gate 238*0Sstevel@tonic-gate if (!xdr_krb5_int16(xdrs, &objp->key_data_ver)) { 239*0Sstevel@tonic-gate return (FALSE); 240*0Sstevel@tonic-gate } 241*0Sstevel@tonic-gate if (!xdr_krb5_int16(xdrs, &objp->key_data_kvno)) { 242*0Sstevel@tonic-gate return (FALSE); 243*0Sstevel@tonic-gate } 244*0Sstevel@tonic-gate if (!xdr_krb5_int16(xdrs, &objp->key_data_type[0])) { 245*0Sstevel@tonic-gate return (FALSE); 246*0Sstevel@tonic-gate } 247*0Sstevel@tonic-gate if (objp->key_data_ver > 1) { 248*0Sstevel@tonic-gate if (!xdr_krb5_int16(xdrs, &objp->key_data_type[1])) { 249*0Sstevel@tonic-gate return (FALSE); 250*0Sstevel@tonic-gate } 251*0Sstevel@tonic-gate } 252*0Sstevel@tonic-gate /* 253*0Sstevel@tonic-gate * kadm5_get_principal on the server side allocates and returns 254*0Sstevel@tonic-gate * key contents when asked. Even though this function refuses to 255*0Sstevel@tonic-gate * transmit that data, it still has to *free* the data at the 256*0Sstevel@tonic-gate * appropriate time to avoid a memory leak. 257*0Sstevel@tonic-gate */ 258*0Sstevel@tonic-gate if (xdrs->x_op == XDR_FREE) { 259*0Sstevel@tonic-gate tmp = (unsigned int) objp->key_data_length[0]; 260*0Sstevel@tonic-gate if (!xdr_bytes(xdrs, (char **) &objp->key_data_contents[0], 261*0Sstevel@tonic-gate &tmp, ~0)) 262*0Sstevel@tonic-gate return FALSE; 263*0Sstevel@tonic-gate 264*0Sstevel@tonic-gate tmp = (unsigned int) objp->key_data_length[1]; 265*0Sstevel@tonic-gate if (!xdr_bytes(xdrs, (char **) &objp->key_data_contents[1], 266*0Sstevel@tonic-gate &tmp, ~0)) 267*0Sstevel@tonic-gate return FALSE; 268*0Sstevel@tonic-gate } 269*0Sstevel@tonic-gate 270*0Sstevel@tonic-gate return (TRUE); 271*0Sstevel@tonic-gate } 272*0Sstevel@tonic-gate 273*0Sstevel@tonic-gate 274*0Sstevel@tonic-gate bool_t 275*0Sstevel@tonic-gate xdr_krb5_key_salt_tuple(XDR *xdrs, krb5_key_salt_tuple *objp) 276*0Sstevel@tonic-gate { 277*0Sstevel@tonic-gate if (!xdr_krb5_enctype(xdrs, &objp->ks_enctype)) 278*0Sstevel@tonic-gate return FALSE; 279*0Sstevel@tonic-gate if (!xdr_krb5_salttype(xdrs, &objp->ks_salttype)) 280*0Sstevel@tonic-gate return FALSE; 281*0Sstevel@tonic-gate return TRUE; 282*0Sstevel@tonic-gate } 283*0Sstevel@tonic-gate 284*0Sstevel@tonic-gate bool_t xdr_krb5_tl_data(XDR *xdrs, krb5_tl_data **tl_data_head) 285*0Sstevel@tonic-gate { 286*0Sstevel@tonic-gate krb5_tl_data *tl, *tl2; 287*0Sstevel@tonic-gate bool_t more; 288*0Sstevel@tonic-gate uint len; 289*0Sstevel@tonic-gate 290*0Sstevel@tonic-gate switch (xdrs->x_op) { 291*0Sstevel@tonic-gate case XDR_FREE: 292*0Sstevel@tonic-gate tl = tl2 = *tl_data_head; 293*0Sstevel@tonic-gate while (tl) { 294*0Sstevel@tonic-gate tl2 = tl->tl_data_next; 295*0Sstevel@tonic-gate free(tl->tl_data_contents); 296*0Sstevel@tonic-gate free(tl); 297*0Sstevel@tonic-gate tl = tl2; 298*0Sstevel@tonic-gate } 299*0Sstevel@tonic-gate break; 300*0Sstevel@tonic-gate 301*0Sstevel@tonic-gate case XDR_ENCODE: 302*0Sstevel@tonic-gate tl = *tl_data_head; 303*0Sstevel@tonic-gate while (1) { 304*0Sstevel@tonic-gate more = (tl != NULL); 305*0Sstevel@tonic-gate if (!xdr_bool(xdrs, &more)) 306*0Sstevel@tonic-gate return FALSE; 307*0Sstevel@tonic-gate if (tl == NULL) 308*0Sstevel@tonic-gate break; 309*0Sstevel@tonic-gate if (!xdr_krb5_int16(xdrs, &tl->tl_data_type)) 310*0Sstevel@tonic-gate return FALSE; 311*0Sstevel@tonic-gate len = tl->tl_data_length; 312*0Sstevel@tonic-gate if (!xdr_bytes(xdrs, (char **) &tl->tl_data_contents, &len, ~0)) 313*0Sstevel@tonic-gate return FALSE; 314*0Sstevel@tonic-gate tl = tl->tl_data_next; 315*0Sstevel@tonic-gate } 316*0Sstevel@tonic-gate break; 317*0Sstevel@tonic-gate 318*0Sstevel@tonic-gate case XDR_DECODE: 319*0Sstevel@tonic-gate tl = NULL; 320*0Sstevel@tonic-gate while (1) { 321*0Sstevel@tonic-gate if (!xdr_bool(xdrs, &more)) 322*0Sstevel@tonic-gate return FALSE; 323*0Sstevel@tonic-gate if (more == FALSE) 324*0Sstevel@tonic-gate break; 325*0Sstevel@tonic-gate tl2 = (krb5_tl_data *) malloc(sizeof(krb5_tl_data)); 326*0Sstevel@tonic-gate if (tl2 == NULL) 327*0Sstevel@tonic-gate return FALSE; 328*0Sstevel@tonic-gate memset((char *) tl2, 0, sizeof(krb5_tl_data)); 329*0Sstevel@tonic-gate if (!xdr_krb5_int16(xdrs, &tl2->tl_data_type)) 330*0Sstevel@tonic-gate return FALSE; 331*0Sstevel@tonic-gate if (!xdr_bytes(xdrs, (char **)&tl2->tl_data_contents, &len, ~0)) 332*0Sstevel@tonic-gate return FALSE; 333*0Sstevel@tonic-gate tl2->tl_data_length = len; 334*0Sstevel@tonic-gate 335*0Sstevel@tonic-gate tl2->tl_data_next = tl; 336*0Sstevel@tonic-gate tl = tl2; 337*0Sstevel@tonic-gate } 338*0Sstevel@tonic-gate 339*0Sstevel@tonic-gate *tl_data_head = tl; 340*0Sstevel@tonic-gate break; 341*0Sstevel@tonic-gate } 342*0Sstevel@tonic-gate 343*0Sstevel@tonic-gate return TRUE; 344*0Sstevel@tonic-gate } 345*0Sstevel@tonic-gate 346*0Sstevel@tonic-gate bool_t 347*0Sstevel@tonic-gate xdr_kadm5_ret_t(XDR *xdrs, kadm5_ret_t *objp) 348*0Sstevel@tonic-gate { 349*0Sstevel@tonic-gate rpc_u_int32 tmp; 350*0Sstevel@tonic-gate 351*0Sstevel@tonic-gate if (xdrs->x_op == XDR_ENCODE) 352*0Sstevel@tonic-gate tmp = (rpc_u_int32) *objp; 353*0Sstevel@tonic-gate 354*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, &tmp)) 355*0Sstevel@tonic-gate return (FALSE); 356*0Sstevel@tonic-gate 357*0Sstevel@tonic-gate if (xdrs->x_op == XDR_DECODE) 358*0Sstevel@tonic-gate *objp = (kadm5_ret_t) tmp; 359*0Sstevel@tonic-gate 360*0Sstevel@tonic-gate return (TRUE); 361*0Sstevel@tonic-gate } 362*0Sstevel@tonic-gate 363*0Sstevel@tonic-gate bool_t xdr_kadm5_principal_ent_rec_v1(XDR *xdrs, 364*0Sstevel@tonic-gate kadm5_principal_ent_rec *objp) 365*0Sstevel@tonic-gate { 366*0Sstevel@tonic-gate return _xdr_kadm5_principal_ent_rec(xdrs, objp, KADM5_API_VERSION_1); 367*0Sstevel@tonic-gate } 368*0Sstevel@tonic-gate 369*0Sstevel@tonic-gate bool_t xdr_kadm5_principal_ent_rec(XDR *xdrs, 370*0Sstevel@tonic-gate kadm5_principal_ent_rec *objp) 371*0Sstevel@tonic-gate { 372*0Sstevel@tonic-gate return _xdr_kadm5_principal_ent_rec(xdrs, objp, KADM5_API_VERSION_2); 373*0Sstevel@tonic-gate } 374*0Sstevel@tonic-gate 375*0Sstevel@tonic-gate static bool_t 376*0Sstevel@tonic-gate _xdr_kadm5_principal_ent_rec(XDR *xdrs, kadm5_principal_ent_rec *objp, 377*0Sstevel@tonic-gate int v) 378*0Sstevel@tonic-gate { 379*0Sstevel@tonic-gate unsigned int n; 380*0Sstevel@tonic-gate 381*0Sstevel@tonic-gate if (!xdr_krb5_principal(xdrs, &objp->principal)) { 382*0Sstevel@tonic-gate return (FALSE); 383*0Sstevel@tonic-gate } 384*0Sstevel@tonic-gate if (!xdr_krb5_timestamp(xdrs, &objp->princ_expire_time)) { 385*0Sstevel@tonic-gate return (FALSE); 386*0Sstevel@tonic-gate } 387*0Sstevel@tonic-gate if (!xdr_krb5_timestamp(xdrs, &objp->last_pwd_change)) { 388*0Sstevel@tonic-gate return (FALSE); 389*0Sstevel@tonic-gate } 390*0Sstevel@tonic-gate if (!xdr_krb5_timestamp(xdrs, &objp->pw_expiration)) { 391*0Sstevel@tonic-gate return (FALSE); 392*0Sstevel@tonic-gate } 393*0Sstevel@tonic-gate if (!xdr_krb5_deltat(xdrs, &objp->max_life)) { 394*0Sstevel@tonic-gate return (FALSE); 395*0Sstevel@tonic-gate } 396*0Sstevel@tonic-gate if (v == KADM5_API_VERSION_1) { 397*0Sstevel@tonic-gate if (!xdr_krb5_principal(xdrs, &objp->mod_name)) { 398*0Sstevel@tonic-gate return (FALSE); 399*0Sstevel@tonic-gate } 400*0Sstevel@tonic-gate } else { 401*0Sstevel@tonic-gate if (!xdr_nulltype(xdrs, (void **) &objp->mod_name, 402*0Sstevel@tonic-gate xdr_krb5_principal)) { 403*0Sstevel@tonic-gate return (FALSE); 404*0Sstevel@tonic-gate } 405*0Sstevel@tonic-gate } 406*0Sstevel@tonic-gate if (!xdr_krb5_timestamp(xdrs, &objp->mod_date)) { 407*0Sstevel@tonic-gate return (FALSE); 408*0Sstevel@tonic-gate } 409*0Sstevel@tonic-gate if (!xdr_krb5_flags(xdrs, &objp->attributes)) { 410*0Sstevel@tonic-gate return (FALSE); 411*0Sstevel@tonic-gate } 412*0Sstevel@tonic-gate if (!xdr_krb5_kvno(xdrs, &objp->kvno)) { 413*0Sstevel@tonic-gate return (FALSE); 414*0Sstevel@tonic-gate } 415*0Sstevel@tonic-gate if (!xdr_krb5_kvno(xdrs, &objp->mkvno)) { 416*0Sstevel@tonic-gate return (FALSE); 417*0Sstevel@tonic-gate } 418*0Sstevel@tonic-gate if (!xdr_nullstring(xdrs, &objp->policy)) { 419*0Sstevel@tonic-gate return (FALSE); 420*0Sstevel@tonic-gate } 421*0Sstevel@tonic-gate if (!xdr_long(xdrs, &objp->aux_attributes)) { 422*0Sstevel@tonic-gate return (FALSE); 423*0Sstevel@tonic-gate } 424*0Sstevel@tonic-gate if (v != KADM5_API_VERSION_1) { 425*0Sstevel@tonic-gate if (!xdr_krb5_deltat(xdrs, &objp->max_renewable_life)) { 426*0Sstevel@tonic-gate return (FALSE); 427*0Sstevel@tonic-gate } 428*0Sstevel@tonic-gate if (!xdr_krb5_timestamp(xdrs, &objp->last_success)) { 429*0Sstevel@tonic-gate return (FALSE); 430*0Sstevel@tonic-gate } 431*0Sstevel@tonic-gate if (!xdr_krb5_timestamp(xdrs, &objp->last_failed)) { 432*0Sstevel@tonic-gate return (FALSE); 433*0Sstevel@tonic-gate } 434*0Sstevel@tonic-gate if (!xdr_krb5_kvno(xdrs, &objp->fail_auth_count)) { 435*0Sstevel@tonic-gate return (FALSE); 436*0Sstevel@tonic-gate } 437*0Sstevel@tonic-gate if (!xdr_krb5_int16(xdrs, &objp->n_key_data)) { 438*0Sstevel@tonic-gate return (FALSE); 439*0Sstevel@tonic-gate } 440*0Sstevel@tonic-gate if (!xdr_krb5_int16(xdrs, &objp->n_tl_data)) { 441*0Sstevel@tonic-gate return (FALSE); 442*0Sstevel@tonic-gate } 443*0Sstevel@tonic-gate if (!xdr_nulltype(xdrs, (void **) &objp->tl_data, 444*0Sstevel@tonic-gate xdr_krb5_tl_data)) { 445*0Sstevel@tonic-gate return FALSE; 446*0Sstevel@tonic-gate } 447*0Sstevel@tonic-gate n = objp->n_key_data; 448*0Sstevel@tonic-gate if (!xdr_array(xdrs, (caddr_t *) &objp->key_data, 449*0Sstevel@tonic-gate &n, ~0, sizeof(krb5_key_data), 450*0Sstevel@tonic-gate xdr_krb5_key_data_nocontents)) { 451*0Sstevel@tonic-gate return (FALSE); 452*0Sstevel@tonic-gate } 453*0Sstevel@tonic-gate } 454*0Sstevel@tonic-gate return (TRUE); 455*0Sstevel@tonic-gate } 456*0Sstevel@tonic-gate 457*0Sstevel@tonic-gate bool_t 458*0Sstevel@tonic-gate xdr_kadm5_policy_ent_rec(XDR *xdrs, kadm5_policy_ent_rec *objp) 459*0Sstevel@tonic-gate { 460*0Sstevel@tonic-gate if (!xdr_nullstring(xdrs, &objp->policy)) { 461*0Sstevel@tonic-gate return (FALSE); 462*0Sstevel@tonic-gate } 463*0Sstevel@tonic-gate /* these all used to be u_int32, but it's stupid for sized types 464*0Sstevel@tonic-gate to be exposed at the api, and they're the same as longs on the 465*0Sstevel@tonic-gate wire. */ 466*0Sstevel@tonic-gate if (!xdr_long(xdrs, &objp->pw_min_life)) { 467*0Sstevel@tonic-gate return (FALSE); 468*0Sstevel@tonic-gate } 469*0Sstevel@tonic-gate if (!xdr_long(xdrs, &objp->pw_max_life)) { 470*0Sstevel@tonic-gate return (FALSE); 471*0Sstevel@tonic-gate } 472*0Sstevel@tonic-gate if (!xdr_long(xdrs, &objp->pw_min_length)) { 473*0Sstevel@tonic-gate return (FALSE); 474*0Sstevel@tonic-gate } 475*0Sstevel@tonic-gate if (!xdr_long(xdrs, &objp->pw_min_classes)) { 476*0Sstevel@tonic-gate return (FALSE); 477*0Sstevel@tonic-gate } 478*0Sstevel@tonic-gate if (!xdr_long(xdrs, &objp->pw_history_num)) { 479*0Sstevel@tonic-gate return (FALSE); 480*0Sstevel@tonic-gate } 481*0Sstevel@tonic-gate if (!xdr_long(xdrs, &objp->policy_refcnt)) { 482*0Sstevel@tonic-gate return (FALSE); 483*0Sstevel@tonic-gate } 484*0Sstevel@tonic-gate return (TRUE); 485*0Sstevel@tonic-gate } 486*0Sstevel@tonic-gate 487*0Sstevel@tonic-gate bool_t 488*0Sstevel@tonic-gate xdr_cprinc_arg(XDR *xdrs, cprinc_arg *objp) 489*0Sstevel@tonic-gate { 490*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 491*0Sstevel@tonic-gate return (FALSE); 492*0Sstevel@tonic-gate } 493*0Sstevel@tonic-gate if (objp->api_version == KADM5_API_VERSION_1) { 494*0Sstevel@tonic-gate if (!xdr_kadm5_principal_ent_rec_v1(xdrs, &objp->rec)) { 495*0Sstevel@tonic-gate return (FALSE); 496*0Sstevel@tonic-gate } 497*0Sstevel@tonic-gate } else { 498*0Sstevel@tonic-gate if (!xdr_kadm5_principal_ent_rec(xdrs, &objp->rec)) { 499*0Sstevel@tonic-gate return (FALSE); 500*0Sstevel@tonic-gate } 501*0Sstevel@tonic-gate } 502*0Sstevel@tonic-gate if (!xdr_long(xdrs, &objp->mask)) { 503*0Sstevel@tonic-gate return (FALSE); 504*0Sstevel@tonic-gate } 505*0Sstevel@tonic-gate if (!xdr_nullstring(xdrs, &objp->passwd)) { 506*0Sstevel@tonic-gate return (FALSE); 507*0Sstevel@tonic-gate } 508*0Sstevel@tonic-gate return (TRUE); 509*0Sstevel@tonic-gate } 510*0Sstevel@tonic-gate 511*0Sstevel@tonic-gate bool_t 512*0Sstevel@tonic-gate xdr_cprinc3_arg(XDR *xdrs, cprinc3_arg *objp) 513*0Sstevel@tonic-gate { 514*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 515*0Sstevel@tonic-gate return (FALSE); 516*0Sstevel@tonic-gate } 517*0Sstevel@tonic-gate if (objp->api_version == KADM5_API_VERSION_1) { 518*0Sstevel@tonic-gate if (!xdr_kadm5_principal_ent_rec_v1(xdrs, &objp->rec)) { 519*0Sstevel@tonic-gate return (FALSE); 520*0Sstevel@tonic-gate } 521*0Sstevel@tonic-gate } else { 522*0Sstevel@tonic-gate if (!xdr_kadm5_principal_ent_rec(xdrs, &objp->rec)) { 523*0Sstevel@tonic-gate return (FALSE); 524*0Sstevel@tonic-gate } 525*0Sstevel@tonic-gate } 526*0Sstevel@tonic-gate if (!xdr_long(xdrs, &objp->mask)) { 527*0Sstevel@tonic-gate return (FALSE); 528*0Sstevel@tonic-gate } 529*0Sstevel@tonic-gate if (!xdr_array(xdrs, (caddr_t *)&objp->ks_tuple, 530*0Sstevel@tonic-gate (unsigned int *)&objp->n_ks_tuple, ~0, 531*0Sstevel@tonic-gate sizeof(krb5_key_salt_tuple), 532*0Sstevel@tonic-gate xdr_krb5_key_salt_tuple)) { 533*0Sstevel@tonic-gate return (FALSE); 534*0Sstevel@tonic-gate } 535*0Sstevel@tonic-gate if (!xdr_nullstring(xdrs, &objp->passwd)) { 536*0Sstevel@tonic-gate return (FALSE); 537*0Sstevel@tonic-gate } 538*0Sstevel@tonic-gate return (TRUE); 539*0Sstevel@tonic-gate } 540*0Sstevel@tonic-gate 541*0Sstevel@tonic-gate bool_t 542*0Sstevel@tonic-gate xdr_generic_ret(XDR *xdrs, generic_ret *objp) 543*0Sstevel@tonic-gate { 544*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 545*0Sstevel@tonic-gate return (FALSE); 546*0Sstevel@tonic-gate } 547*0Sstevel@tonic-gate if (!xdr_kadm5_ret_t(xdrs, &objp->code)) { 548*0Sstevel@tonic-gate return (FALSE); 549*0Sstevel@tonic-gate } 550*0Sstevel@tonic-gate return(TRUE); 551*0Sstevel@tonic-gate } 552*0Sstevel@tonic-gate 553*0Sstevel@tonic-gate bool_t 554*0Sstevel@tonic-gate xdr_dprinc_arg(XDR *xdrs, dprinc_arg *objp) 555*0Sstevel@tonic-gate { 556*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 557*0Sstevel@tonic-gate return (FALSE); 558*0Sstevel@tonic-gate } 559*0Sstevel@tonic-gate if (!xdr_krb5_principal(xdrs, &objp->princ)) { 560*0Sstevel@tonic-gate return (FALSE); 561*0Sstevel@tonic-gate } 562*0Sstevel@tonic-gate return (TRUE); 563*0Sstevel@tonic-gate } 564*0Sstevel@tonic-gate 565*0Sstevel@tonic-gate bool_t 566*0Sstevel@tonic-gate xdr_mprinc_arg(XDR *xdrs, mprinc_arg *objp) 567*0Sstevel@tonic-gate { 568*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 569*0Sstevel@tonic-gate return (FALSE); 570*0Sstevel@tonic-gate } 571*0Sstevel@tonic-gate if (objp->api_version == KADM5_API_VERSION_1) { 572*0Sstevel@tonic-gate if (!xdr_kadm5_principal_ent_rec_v1(xdrs, &objp->rec)) { 573*0Sstevel@tonic-gate return (FALSE); 574*0Sstevel@tonic-gate } 575*0Sstevel@tonic-gate } else { 576*0Sstevel@tonic-gate if (!xdr_kadm5_principal_ent_rec(xdrs, &objp->rec)) { 577*0Sstevel@tonic-gate return (FALSE); 578*0Sstevel@tonic-gate } 579*0Sstevel@tonic-gate } 580*0Sstevel@tonic-gate if (!xdr_long(xdrs, &objp->mask)) { 581*0Sstevel@tonic-gate return (FALSE); 582*0Sstevel@tonic-gate } 583*0Sstevel@tonic-gate return (TRUE); 584*0Sstevel@tonic-gate } 585*0Sstevel@tonic-gate 586*0Sstevel@tonic-gate bool_t 587*0Sstevel@tonic-gate xdr_rprinc_arg(XDR *xdrs, rprinc_arg *objp) 588*0Sstevel@tonic-gate { 589*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 590*0Sstevel@tonic-gate return (FALSE); 591*0Sstevel@tonic-gate } 592*0Sstevel@tonic-gate if (!xdr_krb5_principal(xdrs, &objp->src)) { 593*0Sstevel@tonic-gate return (FALSE); 594*0Sstevel@tonic-gate } 595*0Sstevel@tonic-gate if (!xdr_krb5_principal(xdrs, &objp->dest)) { 596*0Sstevel@tonic-gate return (FALSE); 597*0Sstevel@tonic-gate } 598*0Sstevel@tonic-gate return (TRUE); 599*0Sstevel@tonic-gate } 600*0Sstevel@tonic-gate 601*0Sstevel@tonic-gate bool_t 602*0Sstevel@tonic-gate xdr_gprincs_arg(XDR *xdrs, gprincs_arg *objp) 603*0Sstevel@tonic-gate { 604*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 605*0Sstevel@tonic-gate return (FALSE); 606*0Sstevel@tonic-gate } 607*0Sstevel@tonic-gate if (!xdr_nullstring(xdrs, &objp->exp)) { 608*0Sstevel@tonic-gate return (FALSE); 609*0Sstevel@tonic-gate } 610*0Sstevel@tonic-gate return (TRUE); 611*0Sstevel@tonic-gate } 612*0Sstevel@tonic-gate 613*0Sstevel@tonic-gate bool_t 614*0Sstevel@tonic-gate xdr_gprincs_ret(XDR *xdrs, gprincs_ret *objp) 615*0Sstevel@tonic-gate { 616*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 617*0Sstevel@tonic-gate return (FALSE); 618*0Sstevel@tonic-gate } 619*0Sstevel@tonic-gate if (!xdr_kadm5_ret_t(xdrs, &objp->code)) { 620*0Sstevel@tonic-gate return (FALSE); 621*0Sstevel@tonic-gate } 622*0Sstevel@tonic-gate if (objp->code == KADM5_OK) { 623*0Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->count)) { 624*0Sstevel@tonic-gate return (FALSE); 625*0Sstevel@tonic-gate } 626*0Sstevel@tonic-gate if (!xdr_array(xdrs, (caddr_t *) &objp->princs, 627*0Sstevel@tonic-gate (unsigned int *) &objp->count, ~0, 628*0Sstevel@tonic-gate sizeof(char *), xdr_nullstring)) { 629*0Sstevel@tonic-gate return (FALSE); 630*0Sstevel@tonic-gate } 631*0Sstevel@tonic-gate } 632*0Sstevel@tonic-gate return (TRUE); 633*0Sstevel@tonic-gate } 634*0Sstevel@tonic-gate 635*0Sstevel@tonic-gate bool_t 636*0Sstevel@tonic-gate xdr_chpass_arg(XDR *xdrs, chpass_arg *objp) 637*0Sstevel@tonic-gate { 638*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 639*0Sstevel@tonic-gate return (FALSE); 640*0Sstevel@tonic-gate } 641*0Sstevel@tonic-gate if (!xdr_krb5_principal(xdrs, &objp->princ)) { 642*0Sstevel@tonic-gate return (FALSE); 643*0Sstevel@tonic-gate } 644*0Sstevel@tonic-gate if (!xdr_nullstring(xdrs, &objp->pass)) { 645*0Sstevel@tonic-gate return (FALSE); 646*0Sstevel@tonic-gate } 647*0Sstevel@tonic-gate return (TRUE); 648*0Sstevel@tonic-gate } 649*0Sstevel@tonic-gate 650*0Sstevel@tonic-gate bool_t 651*0Sstevel@tonic-gate xdr_chpass3_arg(XDR *xdrs, chpass3_arg *objp) 652*0Sstevel@tonic-gate { 653*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 654*0Sstevel@tonic-gate return (FALSE); 655*0Sstevel@tonic-gate } 656*0Sstevel@tonic-gate if (!xdr_krb5_principal(xdrs, &objp->princ)) { 657*0Sstevel@tonic-gate return (FALSE); 658*0Sstevel@tonic-gate } 659*0Sstevel@tonic-gate if (!xdr_bool(xdrs, (bool_t *) &objp->keepold)) { /* SUNWresync121 XXX */ 660*0Sstevel@tonic-gate return (FALSE); 661*0Sstevel@tonic-gate } 662*0Sstevel@tonic-gate if (!xdr_array(xdrs, (caddr_t *)&objp->ks_tuple, 663*0Sstevel@tonic-gate (unsigned int*)&objp->n_ks_tuple, ~0, 664*0Sstevel@tonic-gate sizeof(krb5_key_salt_tuple), 665*0Sstevel@tonic-gate xdr_krb5_key_salt_tuple)) { 666*0Sstevel@tonic-gate return (FALSE); 667*0Sstevel@tonic-gate } 668*0Sstevel@tonic-gate if (!xdr_nullstring(xdrs, &objp->pass)) { 669*0Sstevel@tonic-gate return (FALSE); 670*0Sstevel@tonic-gate } 671*0Sstevel@tonic-gate return (TRUE); 672*0Sstevel@tonic-gate } 673*0Sstevel@tonic-gate 674*0Sstevel@tonic-gate bool_t 675*0Sstevel@tonic-gate xdr_setv4key_arg(XDR *xdrs, setv4key_arg *objp) 676*0Sstevel@tonic-gate { 677*0Sstevel@tonic-gate unsigned int n_keys = 1; 678*0Sstevel@tonic-gate 679*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 680*0Sstevel@tonic-gate return (FALSE); 681*0Sstevel@tonic-gate } 682*0Sstevel@tonic-gate if (!xdr_krb5_principal(xdrs, &objp->princ)) { 683*0Sstevel@tonic-gate return (FALSE); 684*0Sstevel@tonic-gate } 685*0Sstevel@tonic-gate if (!xdr_array(xdrs, (caddr_t *) &objp->keyblock, 686*0Sstevel@tonic-gate &n_keys, ~0, 687*0Sstevel@tonic-gate sizeof(krb5_keyblock), xdr_krb5_keyblock)) { 688*0Sstevel@tonic-gate return (FALSE); 689*0Sstevel@tonic-gate } 690*0Sstevel@tonic-gate return (TRUE); 691*0Sstevel@tonic-gate } 692*0Sstevel@tonic-gate 693*0Sstevel@tonic-gate bool_t 694*0Sstevel@tonic-gate xdr_setkey_arg(XDR *xdrs, setkey_arg *objp) 695*0Sstevel@tonic-gate { 696*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 697*0Sstevel@tonic-gate return (FALSE); 698*0Sstevel@tonic-gate } 699*0Sstevel@tonic-gate if (!xdr_krb5_principal(xdrs, &objp->princ)) { 700*0Sstevel@tonic-gate return (FALSE); 701*0Sstevel@tonic-gate } 702*0Sstevel@tonic-gate if (!xdr_array(xdrs, (caddr_t *) &objp->keyblocks, 703*0Sstevel@tonic-gate (unsigned int *) &objp->n_keys, ~0, 704*0Sstevel@tonic-gate sizeof(krb5_keyblock), xdr_krb5_keyblock)) { 705*0Sstevel@tonic-gate return (FALSE); 706*0Sstevel@tonic-gate } 707*0Sstevel@tonic-gate return (TRUE); 708*0Sstevel@tonic-gate } 709*0Sstevel@tonic-gate 710*0Sstevel@tonic-gate bool_t 711*0Sstevel@tonic-gate xdr_setkey3_arg(XDR *xdrs, setkey3_arg *objp) 712*0Sstevel@tonic-gate { 713*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 714*0Sstevel@tonic-gate return (FALSE); 715*0Sstevel@tonic-gate } 716*0Sstevel@tonic-gate if (!xdr_krb5_principal(xdrs, &objp->princ)) { 717*0Sstevel@tonic-gate return (FALSE); 718*0Sstevel@tonic-gate } 719*0Sstevel@tonic-gate if (!xdr_bool(xdrs, (bool_t *) &objp->keepold)) { /* SUNWresync121 XXX */ 720*0Sstevel@tonic-gate return (FALSE); 721*0Sstevel@tonic-gate } 722*0Sstevel@tonic-gate if (!xdr_array(xdrs, (caddr_t *) &objp->ks_tuple, 723*0Sstevel@tonic-gate (unsigned int *) &objp->n_ks_tuple, ~0, 724*0Sstevel@tonic-gate sizeof(krb5_key_salt_tuple), xdr_krb5_key_salt_tuple)) { 725*0Sstevel@tonic-gate return (FALSE); 726*0Sstevel@tonic-gate } 727*0Sstevel@tonic-gate if (!xdr_array(xdrs, (caddr_t *) &objp->keyblocks, 728*0Sstevel@tonic-gate (unsigned int *) &objp->n_keys, ~0, 729*0Sstevel@tonic-gate sizeof(krb5_keyblock), xdr_krb5_keyblock)) { 730*0Sstevel@tonic-gate return (FALSE); 731*0Sstevel@tonic-gate } 732*0Sstevel@tonic-gate return (TRUE); 733*0Sstevel@tonic-gate } 734*0Sstevel@tonic-gate 735*0Sstevel@tonic-gate bool_t 736*0Sstevel@tonic-gate xdr_chrand_arg(XDR *xdrs, chrand_arg *objp) 737*0Sstevel@tonic-gate { 738*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 739*0Sstevel@tonic-gate return (FALSE); 740*0Sstevel@tonic-gate } 741*0Sstevel@tonic-gate if (!xdr_krb5_principal(xdrs, &objp->princ)) { 742*0Sstevel@tonic-gate return (FALSE); 743*0Sstevel@tonic-gate } 744*0Sstevel@tonic-gate return (TRUE); 745*0Sstevel@tonic-gate } 746*0Sstevel@tonic-gate 747*0Sstevel@tonic-gate bool_t 748*0Sstevel@tonic-gate xdr_chrand3_arg(XDR *xdrs, chrand3_arg *objp) 749*0Sstevel@tonic-gate { 750*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 751*0Sstevel@tonic-gate return (FALSE); 752*0Sstevel@tonic-gate } 753*0Sstevel@tonic-gate if (!xdr_krb5_principal(xdrs, &objp->princ)) { 754*0Sstevel@tonic-gate return (FALSE); 755*0Sstevel@tonic-gate } 756*0Sstevel@tonic-gate if (!xdr_bool(xdrs, (bool_t *) &objp->keepold)) { /* SUNWresync121 XXX */ 757*0Sstevel@tonic-gate return (FALSE); 758*0Sstevel@tonic-gate } 759*0Sstevel@tonic-gate if (!xdr_array(xdrs, (caddr_t *)&objp->ks_tuple, 760*0Sstevel@tonic-gate (unsigned int*)&objp->n_ks_tuple, ~0, 761*0Sstevel@tonic-gate sizeof(krb5_key_salt_tuple), 762*0Sstevel@tonic-gate xdr_krb5_key_salt_tuple)) { 763*0Sstevel@tonic-gate return (FALSE); 764*0Sstevel@tonic-gate } 765*0Sstevel@tonic-gate return (TRUE); 766*0Sstevel@tonic-gate } 767*0Sstevel@tonic-gate 768*0Sstevel@tonic-gate bool_t 769*0Sstevel@tonic-gate xdr_chrand_ret(XDR *xdrs, chrand_ret *objp) 770*0Sstevel@tonic-gate { 771*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 772*0Sstevel@tonic-gate return (FALSE); 773*0Sstevel@tonic-gate } 774*0Sstevel@tonic-gate if (!xdr_kadm5_ret_t(xdrs, &objp->code)) { 775*0Sstevel@tonic-gate return (FALSE); 776*0Sstevel@tonic-gate } 777*0Sstevel@tonic-gate if (objp->api_version == KADM5_API_VERSION_1) { 778*0Sstevel@tonic-gate if(objp->code == KADM5_OK) { 779*0Sstevel@tonic-gate if (!xdr_krb5_keyblock(xdrs, &objp->key)) { 780*0Sstevel@tonic-gate return (FALSE); 781*0Sstevel@tonic-gate } 782*0Sstevel@tonic-gate } 783*0Sstevel@tonic-gate } else { 784*0Sstevel@tonic-gate if (objp->code == KADM5_OK) { 785*0Sstevel@tonic-gate if (!xdr_array(xdrs, (char **)&objp->keys, (unsigned int *)&objp->n_keys, ~0, 786*0Sstevel@tonic-gate sizeof(krb5_keyblock), 787*0Sstevel@tonic-gate xdr_krb5_keyblock)) 788*0Sstevel@tonic-gate return FALSE; 789*0Sstevel@tonic-gate } 790*0Sstevel@tonic-gate } 791*0Sstevel@tonic-gate 792*0Sstevel@tonic-gate return (TRUE); 793*0Sstevel@tonic-gate } 794*0Sstevel@tonic-gate 795*0Sstevel@tonic-gate bool_t 796*0Sstevel@tonic-gate xdr_gprinc_arg(XDR *xdrs, gprinc_arg *objp) 797*0Sstevel@tonic-gate { 798*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 799*0Sstevel@tonic-gate return (FALSE); 800*0Sstevel@tonic-gate } 801*0Sstevel@tonic-gate if (!xdr_krb5_principal(xdrs, &objp->princ)) { 802*0Sstevel@tonic-gate return (FALSE); 803*0Sstevel@tonic-gate } 804*0Sstevel@tonic-gate if ((objp->api_version > KADM5_API_VERSION_1) && 805*0Sstevel@tonic-gate !xdr_long(xdrs, &objp->mask)) { 806*0Sstevel@tonic-gate return FALSE; 807*0Sstevel@tonic-gate } 808*0Sstevel@tonic-gate 809*0Sstevel@tonic-gate return (TRUE); 810*0Sstevel@tonic-gate } 811*0Sstevel@tonic-gate 812*0Sstevel@tonic-gate bool_t 813*0Sstevel@tonic-gate xdr_gprinc_ret(XDR *xdrs, gprinc_ret *objp) 814*0Sstevel@tonic-gate { 815*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 816*0Sstevel@tonic-gate return (FALSE); 817*0Sstevel@tonic-gate } 818*0Sstevel@tonic-gate if (!xdr_kadm5_ret_t(xdrs, &objp->code)) { 819*0Sstevel@tonic-gate return (FALSE); 820*0Sstevel@tonic-gate } 821*0Sstevel@tonic-gate if(objp->code == KADM5_OK) { 822*0Sstevel@tonic-gate if (objp->api_version == KADM5_API_VERSION_1) { 823*0Sstevel@tonic-gate if (!xdr_kadm5_principal_ent_rec_v1(xdrs, &objp->rec)) { 824*0Sstevel@tonic-gate return (FALSE); 825*0Sstevel@tonic-gate } 826*0Sstevel@tonic-gate } else { 827*0Sstevel@tonic-gate if (!xdr_kadm5_principal_ent_rec(xdrs, &objp->rec)) { 828*0Sstevel@tonic-gate return (FALSE); 829*0Sstevel@tonic-gate } 830*0Sstevel@tonic-gate } 831*0Sstevel@tonic-gate } 832*0Sstevel@tonic-gate return (TRUE); 833*0Sstevel@tonic-gate } 834*0Sstevel@tonic-gate 835*0Sstevel@tonic-gate bool_t 836*0Sstevel@tonic-gate xdr_cpol_arg(XDR *xdrs, cpol_arg *objp) 837*0Sstevel@tonic-gate { 838*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 839*0Sstevel@tonic-gate return (FALSE); 840*0Sstevel@tonic-gate } 841*0Sstevel@tonic-gate if (!xdr_kadm5_policy_ent_rec(xdrs, &objp->rec)) { 842*0Sstevel@tonic-gate return (FALSE); 843*0Sstevel@tonic-gate } 844*0Sstevel@tonic-gate if (!xdr_long(xdrs, &objp->mask)) { 845*0Sstevel@tonic-gate return (FALSE); 846*0Sstevel@tonic-gate } 847*0Sstevel@tonic-gate return (TRUE); 848*0Sstevel@tonic-gate } 849*0Sstevel@tonic-gate 850*0Sstevel@tonic-gate bool_t 851*0Sstevel@tonic-gate xdr_dpol_arg(XDR *xdrs, dpol_arg *objp) 852*0Sstevel@tonic-gate { 853*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 854*0Sstevel@tonic-gate return (FALSE); 855*0Sstevel@tonic-gate } 856*0Sstevel@tonic-gate if (!xdr_nullstring(xdrs, &objp->name)) { 857*0Sstevel@tonic-gate return (FALSE); 858*0Sstevel@tonic-gate } 859*0Sstevel@tonic-gate return (TRUE); 860*0Sstevel@tonic-gate } 861*0Sstevel@tonic-gate 862*0Sstevel@tonic-gate bool_t 863*0Sstevel@tonic-gate xdr_mpol_arg(XDR *xdrs, mpol_arg *objp) 864*0Sstevel@tonic-gate { 865*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 866*0Sstevel@tonic-gate return (FALSE); 867*0Sstevel@tonic-gate } 868*0Sstevel@tonic-gate if (!xdr_kadm5_policy_ent_rec(xdrs, &objp->rec)) { 869*0Sstevel@tonic-gate return (FALSE); 870*0Sstevel@tonic-gate } 871*0Sstevel@tonic-gate if (!xdr_long(xdrs, &objp->mask)) { 872*0Sstevel@tonic-gate return (FALSE); 873*0Sstevel@tonic-gate } 874*0Sstevel@tonic-gate return (TRUE); 875*0Sstevel@tonic-gate } 876*0Sstevel@tonic-gate 877*0Sstevel@tonic-gate bool_t 878*0Sstevel@tonic-gate xdr_gpol_arg(XDR *xdrs, gpol_arg *objp) 879*0Sstevel@tonic-gate { 880*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 881*0Sstevel@tonic-gate return (FALSE); 882*0Sstevel@tonic-gate } 883*0Sstevel@tonic-gate if (!xdr_nullstring(xdrs, &objp->name)) { 884*0Sstevel@tonic-gate return (FALSE); 885*0Sstevel@tonic-gate } 886*0Sstevel@tonic-gate return (TRUE); 887*0Sstevel@tonic-gate } 888*0Sstevel@tonic-gate 889*0Sstevel@tonic-gate bool_t 890*0Sstevel@tonic-gate xdr_gpol_ret(XDR *xdrs, gpol_ret *objp) 891*0Sstevel@tonic-gate { 892*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 893*0Sstevel@tonic-gate return (FALSE); 894*0Sstevel@tonic-gate } 895*0Sstevel@tonic-gate if (!xdr_kadm5_ret_t(xdrs, &objp->code)) { 896*0Sstevel@tonic-gate return (FALSE); 897*0Sstevel@tonic-gate } 898*0Sstevel@tonic-gate if(objp->code == KADM5_OK) { 899*0Sstevel@tonic-gate if (!xdr_kadm5_policy_ent_rec(xdrs, &objp->rec)) 900*0Sstevel@tonic-gate return (FALSE); 901*0Sstevel@tonic-gate } 902*0Sstevel@tonic-gate return (TRUE); 903*0Sstevel@tonic-gate } 904*0Sstevel@tonic-gate 905*0Sstevel@tonic-gate bool_t 906*0Sstevel@tonic-gate xdr_gpols_arg(XDR *xdrs, gpols_arg *objp) 907*0Sstevel@tonic-gate { 908*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 909*0Sstevel@tonic-gate return (FALSE); 910*0Sstevel@tonic-gate } 911*0Sstevel@tonic-gate if (!xdr_nullstring(xdrs, &objp->exp)) { 912*0Sstevel@tonic-gate return (FALSE); 913*0Sstevel@tonic-gate } 914*0Sstevel@tonic-gate return (TRUE); 915*0Sstevel@tonic-gate } 916*0Sstevel@tonic-gate 917*0Sstevel@tonic-gate bool_t 918*0Sstevel@tonic-gate xdr_gpols_ret(XDR *xdrs, gpols_ret *objp) 919*0Sstevel@tonic-gate { 920*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 921*0Sstevel@tonic-gate return (FALSE); 922*0Sstevel@tonic-gate } 923*0Sstevel@tonic-gate if (!xdr_kadm5_ret_t(xdrs, &objp->code)) { 924*0Sstevel@tonic-gate return (FALSE); 925*0Sstevel@tonic-gate } 926*0Sstevel@tonic-gate if (objp->code == KADM5_OK) { 927*0Sstevel@tonic-gate if (!xdr_int(xdrs, &objp->count)) { 928*0Sstevel@tonic-gate return (FALSE); 929*0Sstevel@tonic-gate } 930*0Sstevel@tonic-gate if (!xdr_array(xdrs, (caddr_t *) &objp->pols, 931*0Sstevel@tonic-gate (unsigned int *) &objp->count, ~0, 932*0Sstevel@tonic-gate sizeof(char *), xdr_nullstring)) { 933*0Sstevel@tonic-gate return (FALSE); 934*0Sstevel@tonic-gate } 935*0Sstevel@tonic-gate } 936*0Sstevel@tonic-gate return (TRUE); 937*0Sstevel@tonic-gate } 938*0Sstevel@tonic-gate 939*0Sstevel@tonic-gate bool_t xdr_getprivs_ret(XDR *xdrs, getprivs_ret *objp) 940*0Sstevel@tonic-gate { 941*0Sstevel@tonic-gate if (!xdr_ui_4(xdrs, &objp->api_version)) { 942*0Sstevel@tonic-gate return (FALSE); 943*0Sstevel@tonic-gate } 944*0Sstevel@tonic-gate if (! xdr_kadm5_ret_t(xdrs, &objp->code) || 945*0Sstevel@tonic-gate ! xdr_long(xdrs, &objp->privs)) 946*0Sstevel@tonic-gate return FALSE; 947*0Sstevel@tonic-gate return TRUE; 948*0Sstevel@tonic-gate } 949*0Sstevel@tonic-gate 950*0Sstevel@tonic-gate bool_t 951*0Sstevel@tonic-gate xdr_krb5_principal(XDR *xdrs, krb5_principal *objp) 952*0Sstevel@tonic-gate { 953*0Sstevel@tonic-gate int ret; 954*0Sstevel@tonic-gate char *p = NULL; 955*0Sstevel@tonic-gate krb5_principal pr = NULL; 956*0Sstevel@tonic-gate static krb5_context context = NULL; 957*0Sstevel@tonic-gate 958*0Sstevel@tonic-gate /* using a static context here is ugly, but should work 959*0Sstevel@tonic-gate ok, and the other solutions are even uglier */ 960*0Sstevel@tonic-gate 961*0Sstevel@tonic-gate if (!context && 962*0Sstevel@tonic-gate krb5_init_context(&context)) 963*0Sstevel@tonic-gate return(FALSE); 964*0Sstevel@tonic-gate 965*0Sstevel@tonic-gate switch(xdrs->x_op) { 966*0Sstevel@tonic-gate case XDR_ENCODE: 967*0Sstevel@tonic-gate if (*objp) { 968*0Sstevel@tonic-gate if((ret = krb5_unparse_name(context, *objp, &p)) != 0) 969*0Sstevel@tonic-gate return FALSE; 970*0Sstevel@tonic-gate } 971*0Sstevel@tonic-gate if(!xdr_nullstring(xdrs, &p)) 972*0Sstevel@tonic-gate return FALSE; 973*0Sstevel@tonic-gate if (p) free(p); 974*0Sstevel@tonic-gate break; 975*0Sstevel@tonic-gate case XDR_DECODE: 976*0Sstevel@tonic-gate if(!xdr_nullstring(xdrs, &p)) 977*0Sstevel@tonic-gate return FALSE; 978*0Sstevel@tonic-gate if (p) { 979*0Sstevel@tonic-gate ret = krb5_parse_name(context, p, &pr); 980*0Sstevel@tonic-gate if(ret != 0) 981*0Sstevel@tonic-gate return FALSE; 982*0Sstevel@tonic-gate *objp = pr; 983*0Sstevel@tonic-gate free(p); 984*0Sstevel@tonic-gate } else 985*0Sstevel@tonic-gate *objp = NULL; 986*0Sstevel@tonic-gate break; 987*0Sstevel@tonic-gate case XDR_FREE: 988*0Sstevel@tonic-gate if(*objp != NULL) 989*0Sstevel@tonic-gate krb5_free_principal(context, *objp); 990*0Sstevel@tonic-gate break; 991*0Sstevel@tonic-gate } 992*0Sstevel@tonic-gate return TRUE; 993*0Sstevel@tonic-gate } 994*0Sstevel@tonic-gate 995*0Sstevel@tonic-gate bool_t 996*0Sstevel@tonic-gate xdr_krb5_octet(XDR *xdrs, krb5_octet *objp) 997*0Sstevel@tonic-gate { 998*0Sstevel@tonic-gate if (!xdr_u_char(xdrs, objp)) 999*0Sstevel@tonic-gate return (FALSE); 1000*0Sstevel@tonic-gate return (TRUE); 1001*0Sstevel@tonic-gate } 1002*0Sstevel@tonic-gate 1003*0Sstevel@tonic-gate bool_t 1004*0Sstevel@tonic-gate xdr_krb5_enctype(XDR *xdrs, krb5_enctype *objp) 1005*0Sstevel@tonic-gate { 1006*0Sstevel@tonic-gate /* 1007*0Sstevel@tonic-gate * This used to be xdr_krb5_keytype, but keytypes and enctypes have 1008*0Sstevel@tonic-gate * been merged into only enctypes. However, randkey_principal 1009*0Sstevel@tonic-gate * already ensures that only a key of ENCTYPE_DES_CBC_CRC will be 1010*0Sstevel@tonic-gate * returned to v1 clients, and ENCTYPE_DES_CBC_CRC has the same 1011*0Sstevel@tonic-gate * value as KEYTYPE_DES used too, which is what all v1 clients 1012*0Sstevel@tonic-gate * expect. Therefore, IMHO, just encoding whatever enctype we get 1013*0Sstevel@tonic-gate * is safe. 1014*0Sstevel@tonic-gate */ 1015*0Sstevel@tonic-gate 1016*0Sstevel@tonic-gate if (!xdr_u_int(xdrs, (unsigned int *) objp)) 1017*0Sstevel@tonic-gate return (FALSE); 1018*0Sstevel@tonic-gate return (TRUE); 1019*0Sstevel@tonic-gate } 1020*0Sstevel@tonic-gate 1021*0Sstevel@tonic-gate bool_t 1022*0Sstevel@tonic-gate xdr_krb5_salttype(XDR *xdrs, krb5_int32 *objp) 1023*0Sstevel@tonic-gate { 1024*0Sstevel@tonic-gate if (!xdr_int(xdrs, (rpc_int32 *) objp)) /* SUNWresync121 XXX */ 1025*0Sstevel@tonic-gate return FALSE; 1026*0Sstevel@tonic-gate return TRUE; 1027*0Sstevel@tonic-gate } 1028*0Sstevel@tonic-gate 1029*0Sstevel@tonic-gate bool_t 1030*0Sstevel@tonic-gate xdr_krb5_keyblock(XDR *xdrs, krb5_keyblock *objp) 1031*0Sstevel@tonic-gate { 1032*0Sstevel@tonic-gate /* XXX This only works because free_keyblock assumes ->contents 1033*0Sstevel@tonic-gate is allocated by malloc() */ 1034*0Sstevel@tonic-gate 1035*0Sstevel@tonic-gate if(!xdr_krb5_enctype(xdrs, &objp->enctype)) 1036*0Sstevel@tonic-gate return FALSE; 1037*0Sstevel@tonic-gate if(!xdr_bytes(xdrs, (char **) &objp->contents, (unsigned int *) 1038*0Sstevel@tonic-gate &objp->length, ~0)) 1039*0Sstevel@tonic-gate return FALSE; 1040*0Sstevel@tonic-gate return TRUE; 1041*0Sstevel@tonic-gate } 1042