"Fossies" - the Fresh Open Source Software Archive

Member "krb5-1.18/src/lib/kadm5/srv/adb_xdr.c" (12 Feb 2020, 2549 Bytes) of package /linux/misc/krb5-1.18.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "adb_xdr.c" see the Fossies "Dox" file reference documentation.

    1 /* -*- mode: c; c-file-style: "bsd"; indent-tabs-mode: t -*- */
    2 /*
    3  * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved
    4  *
    5  * $Header$
    6  */
    7 
    8 #include <sys/types.h>
    9 #include <krb5.h>
   10 #include <gssrpc/rpc.h>
   11 #include    "server_internal.h"
   12 #include "admin_xdr.h"
   13 #ifdef HAVE_MEMORY_H
   14 #include <memory.h>
   15 #endif
   16 
   17 bool_t
   18 xdr_krb5_key_data(XDR *xdrs, krb5_key_data *objp)
   19 {
   20     unsigned int tmp;
   21 
   22     if (!xdr_krb5_int16(xdrs, &objp->key_data_ver))
   23     return(FALSE);
   24     if (!xdr_krb5_ui_2(xdrs, &objp->key_data_kvno))
   25     return(FALSE);
   26     if (!xdr_krb5_int16(xdrs, &objp->key_data_type[0]))
   27     return(FALSE);
   28     if (!xdr_krb5_int16(xdrs, &objp->key_data_type[1]))
   29     return(FALSE);
   30     if (!xdr_krb5_ui_2(xdrs, &objp->key_data_length[0]))
   31     return(FALSE);
   32     if (!xdr_krb5_ui_2(xdrs, &objp->key_data_length[1]))
   33     return(FALSE);
   34 
   35     tmp = (unsigned int) objp->key_data_length[0];
   36     if (!xdr_bytes(xdrs, (char **) &objp->key_data_contents[0],
   37            &tmp, ~0))
   38     return FALSE;
   39 
   40     tmp = (unsigned int) objp->key_data_length[1];
   41     if (!xdr_bytes(xdrs, (char **) &objp->key_data_contents[1],
   42            &tmp, ~0))
   43     return FALSE;
   44 
   45     /* don't need to copy tmp out, since key_data_length will be set
   46        by the above encoding. */
   47 
   48     return(TRUE);
   49 }
   50 
   51 bool_t
   52 xdr_osa_pw_hist_ent(XDR *xdrs, osa_pw_hist_ent *objp)
   53 {
   54     if (!xdr_array(xdrs, (caddr_t *) &objp->key_data,
   55            (u_int *) &objp->n_key_data, ~0,
   56            sizeof(krb5_key_data),
   57            xdr_krb5_key_data))
   58     return (FALSE);
   59     return (TRUE);
   60 }
   61 
   62 bool_t
   63 xdr_osa_princ_ent_rec(XDR *xdrs, osa_princ_ent_t objp)
   64 {
   65     switch (xdrs->x_op) {
   66     case XDR_ENCODE:
   67      objp->version = OSA_ADB_PRINC_VERSION_1;
   68      /* fall through */
   69     case XDR_FREE:
   70      if (!xdr_int(xdrs, &objp->version))
   71           return FALSE;
   72      break;
   73     case XDR_DECODE:
   74      if (!xdr_int(xdrs, &objp->version))
   75           return FALSE;
   76      if (objp->version != OSA_ADB_PRINC_VERSION_1)
   77           return FALSE;
   78      break;
   79     }
   80 
   81     if (!xdr_nullstring(xdrs, &objp->policy))
   82     return (FALSE);
   83     if (!xdr_long(xdrs, &objp->aux_attributes))
   84     return (FALSE);
   85     if (!xdr_u_int(xdrs, &objp->old_key_next))
   86     return (FALSE);
   87     if (!xdr_krb5_kvno(xdrs, &objp->admin_history_kvno))
   88     return (FALSE);
   89     if (!xdr_array(xdrs, (caddr_t *) &objp->old_keys,
   90            (unsigned int *) &objp->old_key_len, ~0,
   91            sizeof(osa_pw_hist_ent),
   92            xdr_osa_pw_hist_ent))
   93     return (FALSE);
   94     return (TRUE);
   95 }
   96 
   97 void
   98 osa_free_princ_ent(osa_princ_ent_t val)
   99 {
  100     XDR xdrs;
  101 
  102     xdrmem_create(&xdrs, NULL, 0, XDR_FREE);
  103 
  104     xdr_osa_princ_ent_rec(&xdrs, val);
  105     free(val);
  106 }