bool_t _xdr_nis_object (XDR *xdrs, nis_object *objp) { bool_t res = xdr_nis_oid (xdrs, &objp->zo_oid); if (__builtin_expect (res, TRUE)) { res = xdr_nis_name (xdrs, &objp->zo_name); if (__builtin_expect (res, TRUE)) { res = xdr_nis_name (xdrs, &objp->zo_owner); if (__builtin_expect (res, TRUE)) { res = xdr_nis_name (xdrs, &objp->zo_group); if (__builtin_expect (res, TRUE)) { res = xdr_nis_name (xdrs, &objp->zo_domain); if (__builtin_expect (res, TRUE)) { res = xdr_u_int (xdrs, &objp->zo_access); if (__builtin_expect (res, TRUE)) { res = xdr_uint32_t (xdrs, &objp->zo_ttl); if (__builtin_expect (res, TRUE)) res = xdr_objdata (xdrs, &objp->zo_data); } } } } } } return res; }
bool_t xdr_nis_object(XDR *xdrs, nis_object *objp) { if (!xdr_nis_oid(xdrs, &objp->zo_oid)) return (FALSE); if (!xdr_nis_name(xdrs, &objp->zo_name)) return (FALSE); if (!xdr_nis_name(xdrs, &objp->zo_owner)) return (FALSE); if (!xdr_nis_name(xdrs, &objp->zo_group)) return (FALSE); if (!xdr_nis_name(xdrs, &objp->zo_domain)) return (FALSE); if (!xdr_u_int(xdrs, &objp->zo_access)) return (FALSE); if (!xdr_uint32_t(xdrs, &objp->zo_ttl)) return (FALSE); return (xdr_objdata(xdrs, &objp->zo_data)); }
/* * Imported from rpc.nisd/nis_db.c * * special XDR for fetus object. We create the actual object from the * "forming" object plus the table object. We create this special object to * save the following components of the nis_object: * zo_name and zo_domain: replaced by just the length field of 0. We had * to keep the length field for backward compatibility. If we * ever change the object format, we should fix this. * zo_owner and zo_group: we condensed it by abbreviating the common part * shared between the table object and the entry object * en_type: Avoided altogether * zo_type and other en_data: Avoided altogether. * * XXX: If the definition of nis_object ever changes, this should be changed. */ bool_t xdr_nis_fetus_object( XDR *xdrs, nis_object *objp, /* Entry object */ nis_object *tobj) /* Table object */ { uint_t size; if (xdrs->x_op == XDR_FREE) return (xdr_nis_object(xdrs, objp)); if (!xdr_nis_oid(xdrs, &objp->zo_oid)) return (FALSE); /* * While encoding of zo_name, we put 0 in the length field, while for * decoding, we get the name from the table object. */ if (xdrs->x_op == XDR_ENCODE) { size = 0; if (!xdr_u_int(xdrs, &size)) return (FALSE); } else { if (!xdr_u_int(xdrs, &size)) return (FALSE); if (size == 0) { /* shrinked format */ /* get the name from the table object */ if ((objp->zo_name = strdup(tobj->zo_name)) == NULL) return (FALSE); } else { /* * We are opening up the xdr_string implementation here * because we called xdr_u_int() earlier. */ if ((objp->zo_name = (char *)malloc(size + 1)) == NULL) return (FALSE); if (!xdr_opaque(xdrs, objp->zo_name, size)) return (FALSE); } } /* * We use the xdr_nis_name_abbrev() function for both owner * and group which constructs the name from the domain name. */ if (!xdr_nis_name_abbrev(xdrs, &objp->zo_owner, tobj->zo_domain)) return (FALSE); if (!xdr_nis_name_abbrev(xdrs, &objp->zo_group, tobj->zo_domain)) return (FALSE); /* * While encoding of zo_domain, we put 0 in the length field, while for * decoding, we get the name from the table object. Same as above for * the name. Could have used a function instead. */ if (xdrs->x_op == XDR_ENCODE) { size = 0; if (!xdr_u_int(xdrs, &size)) return (FALSE); } else { if (!xdr_u_int(xdrs, &size)) return (FALSE); if (size == 0) { /* shrinked format */ /* get the name from the table object */ if ((objp->zo_domain = strdup(tobj->zo_domain)) == NULL) return (FALSE); } else { /* * We are opening up the xdr_string implementation here * because we called xdr_u_int() earlier. */ if ((objp->zo_domain = (char *)malloc(size + 1)) == NULL) return (FALSE); if (!xdr_opaque(xdrs, objp->zo_domain, size)) return (FALSE); } } if (!xdr_u_int(xdrs, &objp->zo_access)) return (FALSE); if (!xdr_u_int(xdrs, &objp->zo_ttl)) return (FALSE); /* * We know that this is an entry object, so we'll save all the entry_obj * space because we can recreate it later. */ if (xdrs->x_op == XDR_ENCODE) return (TRUE); /* Now for the DECODE case, just handcraft the entries and ignore XDR */ objp->zo_data.zo_type = NIS_ENTRY_OBJ; if ((objp->zo_data.objdata_u.en_data.en_type = strdup(tobj->zo_data.objdata_u.ta_data.ta_type)) == NULL) return (FALSE); objp->zo_data.objdata_u.en_data.en_cols.en_cols_val = NULL; objp->zo_data.objdata_u.en_data.en_cols.en_cols_len = 0; return (TRUE); }