/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#include <string.h>
#include "db_mindex_c.h"
#include "ldap_xdr.h"
#include "ldap_util.h"
extern bool_t xdr_nis_object();
/*
* In order not to change the on-disk NIS+ DB format, we need make sure
* that XDR does nothing for the new structures added to various C++
* classes.
*/
return (TRUE);
}
return (TRUE);
}
return (TRUE);
}
return (TRUE);
}
return (TRUE);
}
/*
*
* Special abbreviated XDR string which knows that the namep parameter (mainly
* owner and group) has a trailing end which matches the last 'n' characters
* in the domainname part. It makes use of those common characters to
* name to be encoded which denotes the place in the domainname from where the
* common string starts. For example, if the name was "foo.my.domain." and the
* domainname was "my.domain.", the name would be encoded as "foo.10" because
* the length of the common part "my.domain." is 10.
*/
{
char *name;
int i;
case XDR_ENCODE:
/* Get the start of the common part */
if (name_len == 0)
for (i = 1; i <= min_len; i++) {
break;
}
i--;
case XDR_DECODE:
return (FALSE);
/* It is either a FQN or a NULL string */
if (*namep) {
return (TRUE);
} else {
return (FALSE);
else
return (TRUE);
}
}
/* Now concoct the new name */
/* something went wrong here */
"xdr_nis_name_abbrev: no dot found in %s", buf);
return (FALSE);
}
if (*namep) {
} else {
return (FALSE);
}
return (TRUE);
default:
}
}
/*
*
* 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.
*/
{
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.
*/
size = 0;
return (FALSE);
} else {
return (FALSE);
if (size == 0) { /* shrinked format */
/* get the name from the table object */
return (FALSE);
} else {
/*
* We are opening up the xdr_string implementation here
* because we called xdr_u_int() earlier.
*/
return (FALSE);
return (FALSE);
}
}
/*
* We use the xdr_nis_name_abbrev() function for both owner
* and group which constructs the name from the domain name.
*/
return (FALSE);
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.
*/
size = 0;
return (FALSE);
} else {
return (FALSE);
if (size == 0) { /* shrinked format */
/* get the name from the table object */
return (FALSE);
} else {
/*
* We are opening up the xdr_string implementation here
* because we called xdr_u_int() earlier.
*/
== NULL)
return (FALSE);
return (FALSE);
}
}
return (FALSE);
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.
*/
return (TRUE);
/* Now for the DECODE case, just handcraft the entries and ignore XDR */
return (FALSE);
return (TRUE);
}
/*
* Given an input NIS+ object, create the kind
* of pseudo-entry_obj (with an XDR-encoded nis_object in the
* first column) that's stored in the DB. Note that:
*
* If the input object is an entry, it's assumed to have the
* columns moved up one step (col 0 in en_cols.en_cols_val[1],
* etc.). en_cols.en_cols_val[0] will be overwritten. The
* input object will be changed (some pointers set to zero,
* etc.) on exit.
*
* 'eo' is assumed to be a pointer to an empty entry_obj (or,
* at least, one that can be overwritten). It must not be a
* pointer to the entry_obj in 'obj'. If the input object is
* of a type other than entry, the 'eo' pointer must have
* en_cols.en_cols_val appropriately initialized to an array of
* (at least) length one.
*
* 'tobj' is a pointer to the table object for the table for
* which the entry_obj is destined. It's needed for entry objects,
* but unused for other object types.
*/
int bufsize;
char *buf;
return (0);
/*
* To prevent the XDR function from making a copy of
* the entry columns, we set the columns structure to
* 0 (ie no column data)
*/
} else {
}
if (buf == 0) {
}
return (0);
}
} else {
}
/* Restore the 'obj' */
}
if (!xret) {
"%s: XDR encode failure", myself);
return (0);
}
return (eo);
}
nis_object *o;
if (e == 0 || e->en_cols.en_cols_val == 0 ||
e->en_cols.en_cols_len == 0)
return (0);
if (o == 0)
return (0);
} else {
}
if (!stat) {
sfree(o);
o = 0;
}
/*
* If it's an entry object, construct the column information.
* We make this a copy, so that 'o' can be freed using
* nis_destroy_object().
*/
if (ec == 0) {
return (0);
}
if (len == 0)
len++;
return (0);
}
} else {
}
*ocl += 1;
}
}
/*
* If it's an entry, and we have the table object, make sure
* zo_name and en_type either already are set, or get them
* from the table.
*/
if (o->zo_name == 0)
}
return (o);
}
/*
* Input: A (nis_object *), and (optionally) an (entry_obj *) array.
* Output: Pointer to an XDR:ed version of an (xdr_nis_object_t).
*/
void *
void *buf;
int xdrLen;
if (obj == 0)
return (0);
/*
* The version tells us what the XDR:ed buffer contains.
* Should be incremented whenever xdr_nis_object_t changes
* incompatibly.
*/
int i;
/*
* The ea[] array is expected to contain the kind of
* pseudo-entry object stored in the nisdb incarnation
* of a NIS+ directory. Column zero contains the XDR:ed
* directory entry object (which we ignore), while column
* one contains the name of said entry. It's the latter
* that we borrow for use in the dirEntry[] list of the
* xdr_nis_object_t.
*/
return (0);
for (i = 0; i < numEa; i++) {
ec_value.ec_value_len == 0)
continue;
/*
* Yes, there's a NUL at the end of the dir entry
* name.
*/
}
} else {
/* No directory entries */
}
if (buf == 0)
return (0);
if (!xret) {
return (0);
}
if (xdrLenP != 0)
return (buf);
}
/*
* Input: Pointer to an XDR:ed version of an (xdr_nis_object_t).
* Output: Pointer to a (nis_object *) and (if the object is a
* directory) a pointer to an array of (entry_obj *).
*/
int numEa;
nis_object *o;
return (0);
if (xno == 0)
return (0);
if (!xret) {
return (0);
}
case 1:
break;
default:
"%s: Unknown xdr_nis_object_t version %d",
return (0);
}
if (ea == 0) {
return (0);
}
}
int i;
for (i = 0; i < numEa; i++) {
}
return (0);
}
/* Leave column 0 (XDR:ed object) empty */
ec_value.ec_value_len = 0;
ec_value.ec_value_val = 0;
/*
* Fill in name of dir entry. The DB counts the NUL
* as part of the dir entry name; hence, add one
* to the string length.
*/
}
/*
* The xno->dirEntry.dirEntry_val[] pointers are duplicated
* in 'ea'. Set the xno pointers to zero, so that the xdr_free
* doesn't free the 'ea' data.
*/
if (numEa > 0) {
int i;
for (i = 0; i < numEa; i++) {
}
}
} else {
if (eaP != 0)
*eaP = 0;
if (numEaP != 0)
*numEaP = 0;
}
return (o);
}
void
int i;
if (ea == 0)
return;
for (i = 0; i < numEa; i++) {
int j;
}
}
}
/*
* Return TRUE if 'o1' and 'o2' are the same, FALSE otherwise.
* We perform the comparison by XDR encoding the objects, and then
* checking the XDR buffers for equality. However, we don't want to
* include the zo_oid (i.e., ctime and mtime) in the comparison.
*/
return (TRUE);
return (FALSE);
/*
* We want to exclude the zo_oid from the comparison. In order
* not to modify the objects (even very briefly), we do this by
* making copies (nis_object itself only, not the underlying
* structures accessed through pointers), and setting the zo_oid
* to zero in the copies.
*/
return (FALSE);
return (FALSE);
}
} else {
"%s: xdr_nis_object() error",
myself);
}
return (ret);
}
/*
* A wrapper/convenience function for sameNisPlusObj() that extracts
* the object in column zero of 'e2'.
*/
return (TRUE);
else if (e2 == 0)
return (FALSE);
if (o2 == 0)
return (res);
}