/* vals_to_stream recieves : kadm_vals *, u_char * returns : a realloced and filled in u_char * this function creates a byte-stream representation of the kadm_vals structure */ int vals_to_stream(Kadm_vals *dt_in, u_char **dt_out) { int vsloop, stsize; /* loop counter, stream size */ stsize = build_field_header(dt_in->fields, dt_out); for (vsloop = 31; vsloop >= 0; vsloop--) if (IS_FIELD(vsloop, dt_in->fields)) { switch (vsloop) { case KADM_NAME: stsize += vts_string(dt_in->name, dt_out, stsize); break; case KADM_INST: stsize += vts_string(dt_in->instance, dt_out, stsize); break; case KADM_EXPDATE: stsize += vts_long((KRB_UINT32)dt_in->exp_date, dt_out, stsize); break; case KADM_ATTR: stsize += vts_short(dt_in->attributes, dt_out, stsize); break; case KADM_MAXLIFE: stsize += vts_char(dt_in->max_life, dt_out, stsize); break; case KADM_DESKEY: stsize += vts_long(dt_in->key_high, dt_out, stsize); stsize += vts_long(dt_in->key_low, dt_out, stsize); break; default: break; } } return stsize; }
/* * kadm_change_pw2 * recieves : key, pw_string, ret_string * * Replaces the password (i.e. des key) of the caller with that specified in * key. Returns no actual data from the master server, since this is called * by a user */ long kadm_change_pw2(des_cblock newkey, char *pwstring, u_char **retstring) { /* The DES form of the users key */ int stsize; long retc; /* stream size and return code */ u_char *send_st; /* send stream */ u_char *ret_st; int ret_sz; u_long keytmp; if ((retc = kadm_cli_conn()) != KADM_SUCCESS) return(retc); /* possible problem with vts_long on a non-multiple of four boundary */ stsize = 0; /* start of our output packet */ send_st = (u_char *) malloc(1);/* to make it reallocable */ send_st[stsize++] = (u_char) CHANGE_PW; /* change key to stream */ bcopy((char *) (((long *) newkey) + 1), (char *) &keytmp, 4); keytmp = htonl(keytmp); stsize += vts_long(keytmp, &send_st, stsize); bcopy((char *) newkey, (char *) &keytmp, 4); keytmp = htonl(keytmp); stsize += vts_long(keytmp, &send_st, stsize); if (pwstring) { stsize += vts_string(pwstring, &send_st, stsize); } ret_sz = 0; retc = kadm_cli_send(send_st, stsize, &ret_st, &ret_sz); free((char *)send_st); if (ret_sz) *retstring = ret_st; else { *retstring = 0; free(ret_st); } kadm_cli_disconn(); return(retc); }