xref: /onnv-gate/usr/src/head/rpcsvc/nis_object.x (revision 11262:b7ebfbf2359e)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*11262SRajagopal.Andra@Sun.COM  * Common Development and Distribution License (the "License").
6*11262SRajagopal.Andra@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
220Sstevel@tonic-gate  *	nis_object.x
230Sstevel@tonic-gate  *
24*11262SRajagopal.Andra@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25*11262SRajagopal.Andra@Sun.COM  * Use is subject to license terms.
260Sstevel@tonic-gate  */
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #if RPC_HDR
290Sstevel@tonic-gate %
300Sstevel@tonic-gate %#ifndef __nis_object_h
310Sstevel@tonic-gate %#define __nis_object_h
320Sstevel@tonic-gate %
330Sstevel@tonic-gate #endif
340Sstevel@tonic-gate /*
350Sstevel@tonic-gate  * 	This file defines the format for a NIS object in RPC language.
360Sstevel@tonic-gate  * It is included by the main .x file and the database access protocol
370Sstevel@tonic-gate  * file. It is common because both of them need to deal with the same
380Sstevel@tonic-gate  * type of object. Generating the actual code though is a bit messy because
390Sstevel@tonic-gate  * the nis.x file and the nis_dba.x file will generate xdr routines to
400Sstevel@tonic-gate  * encode/decode objects when only one set is needed. Such is life when
410Sstevel@tonic-gate  * one is using rpcgen.
420Sstevel@tonic-gate  *
430Sstevel@tonic-gate  * Note, the protocol doesn't specify any limits on such things as
440Sstevel@tonic-gate  * maximum name length, number of attributes, etc. These are enforced
450Sstevel@tonic-gate  * by the database backend. When you hit them you will no. Also see
460Sstevel@tonic-gate  * the db_getlimits() function for fetching the limit values.
470Sstevel@tonic-gate  *
480Sstevel@tonic-gate  */
490Sstevel@tonic-gate 
500Sstevel@tonic-gate #if defined(RPC_XDR) || defined(RPC_SVC) || defined(RPC_CLNT)
510Sstevel@tonic-gate %#ifndef xdr_uint32_t
520Sstevel@tonic-gate %#define xdr_uint32_t xdr_u_int
530Sstevel@tonic-gate %#endif
540Sstevel@tonic-gate %#ifndef xdr_uint_t
550Sstevel@tonic-gate %#define xdr_uint_t xdr_u_int
560Sstevel@tonic-gate %#endif
570Sstevel@tonic-gate #endif
580Sstevel@tonic-gate 
590Sstevel@tonic-gate /* Some manifest constants, chosen to maximize flexibility without
600Sstevel@tonic-gate  * plugging the wire full of data.
610Sstevel@tonic-gate  */
620Sstevel@tonic-gate const NIS_MAXSTRINGLEN = 255;
630Sstevel@tonic-gate const NIS_MAXNAMELEN   = 1024;
640Sstevel@tonic-gate const NIS_MAXATTRNAME  = 32;
650Sstevel@tonic-gate const NIS_MAXATTRVAL   = 2048;
660Sstevel@tonic-gate const NIS_MAXCOLUMNS   = 64;
670Sstevel@tonic-gate const NIS_MAXATTR      = 16;
680Sstevel@tonic-gate const NIS_MAXPATH      = 1024;
690Sstevel@tonic-gate const NIS_MAXREPLICAS  = 128;
700Sstevel@tonic-gate const NIS_MAXLINKS     = 16;
710Sstevel@tonic-gate 
720Sstevel@tonic-gate const NIS_PK_NONE      = 0;	/* no public key (unix/sys auth) */
730Sstevel@tonic-gate const NIS_PK_DH	       = 1;	/* Public key is Diffie-Hellman type */
740Sstevel@tonic-gate const NIS_PK_RSA       = 2;	/* Public key if RSA type */
750Sstevel@tonic-gate const NIS_PK_KERB      = 3;	/* Use kerberos style authentication */
760Sstevel@tonic-gate const NIS_PK_DHEXT     = 4;	/* Extended Diffie-Hellman for RPC-GSS */
770Sstevel@tonic-gate 
780Sstevel@tonic-gate /*
790Sstevel@tonic-gate  * The fundamental name type of NIS. The name may consist of two parts,
800Sstevel@tonic-gate  * the first being the fully qualified name, and the second being an
810Sstevel@tonic-gate  * optional set of attribute/value pairs.
820Sstevel@tonic-gate  */
830Sstevel@tonic-gate struct nis_attr {
840Sstevel@tonic-gate 	string	zattr_ndx<>;	/* name of the index 		*/
850Sstevel@tonic-gate 	opaque	zattr_val<>;	/* Value for the attribute. 	*/
860Sstevel@tonic-gate };
870Sstevel@tonic-gate 
880Sstevel@tonic-gate typedef string nis_name<>;	/* The NIS name itself. */
890Sstevel@tonic-gate 
900Sstevel@tonic-gate /* NIS object types are defined by the following enumeration. The numbers
910Sstevel@tonic-gate  * they use are based on the following scheme :
920Sstevel@tonic-gate  *		     0 - 1023 are reserved for Sun,
930Sstevel@tonic-gate  * 		1024 - 2047 are defined to be private to a particular tree.
940Sstevel@tonic-gate  *		2048 - 4095 are defined to be user defined.
950Sstevel@tonic-gate  *		4096 - ...  are reserved for future use.
960Sstevel@tonic-gate  *
970Sstevel@tonic-gate  * EOL Alert - The non-prefixed names are present for backward
980Sstevel@tonic-gate  * compatability only, and will not exist in future releases. Use
990Sstevel@tonic-gate  * the NIS_* names for future compatability.
1000Sstevel@tonic-gate  */
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate enum zotypes {
1030Sstevel@tonic-gate 
1040Sstevel@tonic-gate 	BOGUS_OBJ  	= 0,	/* Uninitialized object structure 	*/
1050Sstevel@tonic-gate 	NO_OBJ   	= 1,	/* NULL object (no data)	 	*/
1060Sstevel@tonic-gate 	DIRECTORY_OBJ 	= 2,	/* Directory object describing domain 	*/
1070Sstevel@tonic-gate 	GROUP_OBJ  	= 3,	/* Group object (a list of names) 	*/
1080Sstevel@tonic-gate 	TABLE_OBJ  	= 4,	/* Table object (a database schema) 	*/
1090Sstevel@tonic-gate 	ENTRY_OBJ  	= 5,	/* Entry object (a database record) 	*/
1100Sstevel@tonic-gate 	LINK_OBJ   	= 6, 	/* A name link.				*/
1110Sstevel@tonic-gate 	PRIVATE_OBJ  	= 7, 	/* Private object (all opaque data) 	*/
1120Sstevel@tonic-gate 
1130Sstevel@tonic-gate 	NIS_BOGUS_OBJ  	= 0,	/* Uninitialized object structure 	*/
1140Sstevel@tonic-gate 	NIS_NO_OBJ   	= 1,	/* NULL object (no data)	 	*/
1150Sstevel@tonic-gate 	NIS_DIRECTORY_OBJ = 2, /* Directory object describing domain 	*/
1160Sstevel@tonic-gate 	NIS_GROUP_OBJ  	= 3,	/* Group object (a list of names) 	*/
1170Sstevel@tonic-gate 	NIS_TABLE_OBJ  	= 4,	/* Table object (a database schema) 	*/
1180Sstevel@tonic-gate 	NIS_ENTRY_OBJ  	= 5,	/* Entry object (a database record) 	*/
1190Sstevel@tonic-gate 	NIS_LINK_OBJ	= 6, 	/* A name link.				*/
1200Sstevel@tonic-gate 	NIS_PRIVATE_OBJ  = 7 /* Private object (all opaque data) */
1210Sstevel@tonic-gate };
1220Sstevel@tonic-gate 
1230Sstevel@tonic-gate /*
1240Sstevel@tonic-gate  * The types of Name services NIS knows about. They are enumerated
1250Sstevel@tonic-gate  * here. The Binder code will use this type to determine if it has
1260Sstevel@tonic-gate  * a set of library routines that will access the indicated name service.
1270Sstevel@tonic-gate  */
1280Sstevel@tonic-gate enum nstype {
1290Sstevel@tonic-gate 	UNKNOWN = 0,
1300Sstevel@tonic-gate 	NIS = 1,	/* Nis Plus Service		*/
1310Sstevel@tonic-gate 	SUNYP = 2,	/* Old NIS Service		*/
1320Sstevel@tonic-gate 	IVY = 3,	/* Nis Plus Plus Service	*/
1330Sstevel@tonic-gate 	DNS = 4,	/* Domain Name Service		*/
1340Sstevel@tonic-gate 	X500 = 5,	/* ISO/CCCIT X.500 Service	*/
1350Sstevel@tonic-gate 	DNANS = 6,	/* Digital DECNet Name Service	*/
1360Sstevel@tonic-gate 	XCHS = 7,	/* Xerox ClearingHouse Service	*/
1370Sstevel@tonic-gate 	CDS= 8
1380Sstevel@tonic-gate };
1390Sstevel@tonic-gate 
1400Sstevel@tonic-gate /*
1410Sstevel@tonic-gate  * DIRECTORY - The name service object. These objects identify other name
1420Sstevel@tonic-gate  * servers that are serving some portion of the name space. Each has a
1430Sstevel@tonic-gate  * type associated with it. The resolver library will note whether or not
1440Sstevel@tonic-gate  * is has the needed routines to access that type of service.
1450Sstevel@tonic-gate  * The oarmask structure defines an access rights mask on a per object
1460Sstevel@tonic-gate  * type basis for the name spaces. The only bits currently used are
1470Sstevel@tonic-gate  * create and destroy. By enabling or disabling these access rights for
1480Sstevel@tonic-gate  * a specific object type for a one of the accessor entities (owner,
1490Sstevel@tonic-gate  * group, world) the administrator can control what types of objects
1500Sstevel@tonic-gate  * may be freely added to the name space and which require the
1510Sstevel@tonic-gate  * administrator's approval.
1520Sstevel@tonic-gate  */
1530Sstevel@tonic-gate struct oar_mask {
1540Sstevel@tonic-gate 	uint_t	oa_rights;	/* Access rights mask 	*/
1550Sstevel@tonic-gate 	zotypes	oa_otype;	/* Object type 		*/
1560Sstevel@tonic-gate };
1570Sstevel@tonic-gate 
1580Sstevel@tonic-gate struct endpoint {
1590Sstevel@tonic-gate 	string		uaddr<>;
1600Sstevel@tonic-gate 	string		family<>;   /* Transport family (INET, OSI, etc) */
1610Sstevel@tonic-gate 	string		proto<>;    /* Protocol (TCP, UDP, CLNP,  etc)   */
1620Sstevel@tonic-gate };
1630Sstevel@tonic-gate 
1640Sstevel@tonic-gate /*
1650Sstevel@tonic-gate  * Note: pkey is a netobj which is limited to 1024 bytes which limits the
1660Sstevel@tonic-gate  * keysize to 8192 bits. This is consider to be a reasonable limit for
1670Sstevel@tonic-gate  * the expected lifetime of this service.
1680Sstevel@tonic-gate  */
1690Sstevel@tonic-gate struct nis_server {
1700Sstevel@tonic-gate 	nis_name	name; 	 	/* Principal name of the server  */
1710Sstevel@tonic-gate 	endpoint	ep<>;  		/* Universal addr(s) for server  */
1720Sstevel@tonic-gate 	uint_t		key_type;	/* Public key type		 */
1730Sstevel@tonic-gate 	netobj		pkey;		/* server's public key  	 */
1740Sstevel@tonic-gate };
1750Sstevel@tonic-gate 
1760Sstevel@tonic-gate struct directory_obj {
1770Sstevel@tonic-gate 	nis_name   do_name;	 /* Name of the directory being served   */
1780Sstevel@tonic-gate 	nstype	   do_type;	 /* one of NIS, DNS, IVY, YP, or X.500 	 */
1790Sstevel@tonic-gate 	nis_server do_servers<>; /* <0> == Primary name server     	 */
1800Sstevel@tonic-gate 	uint32_t   do_ttl;	 /* Time To Live (for caches) 		 */
1810Sstevel@tonic-gate 	oar_mask   do_armask<>;  /* Create/Destroy rights by object type */
1820Sstevel@tonic-gate };
1830Sstevel@tonic-gate 
1840Sstevel@tonic-gate /*
1850Sstevel@tonic-gate  * ENTRY - This is one row of data from an information base.
1860Sstevel@tonic-gate  * The type value is used by the client library to convert the entry to
1870Sstevel@tonic-gate  * it's internal structure representation. The Table name is a back pointer
1880Sstevel@tonic-gate  * to the table where the entry is stored. This allows the client library
1890Sstevel@tonic-gate  * to determine where to send a request if the client wishes to change this
1900Sstevel@tonic-gate  * entry but got to it through a LINK rather than directly.
1910Sstevel@tonic-gate  * If the entry is a "standalone" entry then this field is void.
1920Sstevel@tonic-gate  */
1930Sstevel@tonic-gate const EN_BINARY   = 1;	/* Indicates value is binary data 	*/
1940Sstevel@tonic-gate const EN_CRYPT    = 2;	/* Indicates the value is encrypted	*/
1950Sstevel@tonic-gate const EN_XDR      = 4;	/* Indicates the value is XDR encoded	*/
1960Sstevel@tonic-gate const EN_MODIFIED = 8;	/* Indicates entry is modified. 	*/
1970Sstevel@tonic-gate const EN_ASN1     = 64;	/* Means contents use ASN.1 encoding    */
1980Sstevel@tonic-gate 
1990Sstevel@tonic-gate struct entry_col {
2000Sstevel@tonic-gate 	uint_t	ec_flags;	/* Flags for this value */
2010Sstevel@tonic-gate 	opaque	ec_value<>;	/* It's textual value	*/
2020Sstevel@tonic-gate };
2030Sstevel@tonic-gate 
2040Sstevel@tonic-gate struct entry_obj {
2050Sstevel@tonic-gate 	string 	en_type<>;	/* Type of entry such as "passwd" */
2060Sstevel@tonic-gate 	entry_col en_cols<>;	/* Value for the entry		  */
2070Sstevel@tonic-gate };
2080Sstevel@tonic-gate 
2090Sstevel@tonic-gate /*
2100Sstevel@tonic-gate  * GROUP - The group object contains a list of NIS principal names. Groups
2110Sstevel@tonic-gate  * are used to authorize principals. Each object has a set of access rights
2120Sstevel@tonic-gate  * for members of its group. Principal names in groups are in the form
2130Sstevel@tonic-gate  * name.directory and recursive groups are expressed as @groupname.directory
2140Sstevel@tonic-gate  */
2150Sstevel@tonic-gate struct group_obj {
2160Sstevel@tonic-gate 	uint_t		gr_flags;	/* Flags controlling group	*/
2170Sstevel@tonic-gate 	nis_name	gr_members<>;  	/* List of names in group 	*/
2180Sstevel@tonic-gate };
2190Sstevel@tonic-gate 
2200Sstevel@tonic-gate /*
2210Sstevel@tonic-gate  * LINK - This is the LINK object. It is quite similar to a symbolic link
2220Sstevel@tonic-gate  * in the UNIX filesystem. The attributes in the main object structure are
2230Sstevel@tonic-gate  * relative to the LINK data and not what it points to (like the file system)
2240Sstevel@tonic-gate  * "modify" privleges here indicate the right to modify what the link points
2250Sstevel@tonic-gate  * at and not to modify that actual object pointed to by the link.
2260Sstevel@tonic-gate  */
2270Sstevel@tonic-gate struct link_obj {
2280Sstevel@tonic-gate 	zotypes	 li_rtype;	/* Real type of the object	*/
2290Sstevel@tonic-gate 	nis_attr li_attrs<>;	/* Attribute/Values for tables	*/
2300Sstevel@tonic-gate 	nis_name li_name; 	/* The object's real NIS name	*/
2310Sstevel@tonic-gate };
2320Sstevel@tonic-gate 
2330Sstevel@tonic-gate /*
2340Sstevel@tonic-gate  * TABLE - This is the table object. It implements a simple
2350Sstevel@tonic-gate  * data base that applications and use for configuration or
2360Sstevel@tonic-gate  * administration purposes. The role of the table is to group together
2370Sstevel@tonic-gate  * a set of related entries. Tables are the simple database component
2380Sstevel@tonic-gate  * of NIS. Like many databases, tables are logically divided into columns
2390Sstevel@tonic-gate  * and rows. The columns are labeled with indexes and each ENTRY makes
2400Sstevel@tonic-gate  * up a row. Rows may be addressed within the table by selecting one
2410Sstevel@tonic-gate  * or more indexes, and values for those indexes. Each row which has
2420Sstevel@tonic-gate  * a value for the given index that matches the desired value is returned.
2430Sstevel@tonic-gate  * Within the definition of each column there is a flags variable, this
2440Sstevel@tonic-gate  * variable contains flags which determine whether or not the column is
2450Sstevel@tonic-gate  * searchable, contains binary data, and access rights for the entry objects
2460Sstevel@tonic-gate  * column value.
2470Sstevel@tonic-gate  */
2480Sstevel@tonic-gate 
2490Sstevel@tonic-gate const TA_BINARY     = 1;	/* Means table data is binary 		*/
2500Sstevel@tonic-gate const TA_CRYPT      = 2;	/* Means value should be encrypted 	*/
2510Sstevel@tonic-gate const TA_XDR        = 4;	/* Means value is XDR encoded		*/
2520Sstevel@tonic-gate const TA_SEARCHABLE = 8;	/* Means this column is searchable	*/
2530Sstevel@tonic-gate const TA_CASE       = 16;	/* Means this column is Case Sensitive	*/
2540Sstevel@tonic-gate const TA_MODIFIED   = 32;	/* Means this columns attrs are modified*/
2550Sstevel@tonic-gate const TA_ASN1       = 64;	/* Means contents use ASN.1 encoding     */
2560Sstevel@tonic-gate 
2570Sstevel@tonic-gate struct table_col {
2580Sstevel@tonic-gate 	string	tc_name<64>;	/* Column Name 	 	   */
2590Sstevel@tonic-gate 	uint_t	tc_flags;	/* control flags	   */
2600Sstevel@tonic-gate 	uint_t	tc_rights;	/* Access rights mask	   */
2610Sstevel@tonic-gate };
2620Sstevel@tonic-gate 
2630Sstevel@tonic-gate struct table_obj {
2640Sstevel@tonic-gate 	string 	  ta_type<64>;	 /* Table type such as "passwd"	*/
2650Sstevel@tonic-gate 	int	  ta_maxcol;	 /* Total number of columns	*/
2660Sstevel@tonic-gate 	u_char	  ta_sep;	 /* Separator character 	*/
2670Sstevel@tonic-gate 	table_col ta_cols<>; 	 /* The number of table indexes */
2680Sstevel@tonic-gate 	string	  ta_path<>;	 /* A search path for this table */
2690Sstevel@tonic-gate };
2700Sstevel@tonic-gate 
2710Sstevel@tonic-gate /*
2720Sstevel@tonic-gate  * This union joins together all of the currently known objects.
2730Sstevel@tonic-gate  */
2740Sstevel@tonic-gate union objdata switch (zotypes zo_type) {
2750Sstevel@tonic-gate         case NIS_DIRECTORY_OBJ :
2760Sstevel@tonic-gate                 struct directory_obj di_data;
2770Sstevel@tonic-gate         case NIS_GROUP_OBJ :
2780Sstevel@tonic-gate                 struct group_obj gr_data;
2790Sstevel@tonic-gate         case NIS_TABLE_OBJ :
2800Sstevel@tonic-gate                 struct table_obj ta_data;
2810Sstevel@tonic-gate         case NIS_ENTRY_OBJ:
2820Sstevel@tonic-gate                 struct entry_obj en_data;
2830Sstevel@tonic-gate         case NIS_LINK_OBJ :
2840Sstevel@tonic-gate                 struct link_obj li_data;
2850Sstevel@tonic-gate         case NIS_PRIVATE_OBJ :
2860Sstevel@tonic-gate                 opaque	po_data<>;
2870Sstevel@tonic-gate 	case NIS_NO_OBJ :
2880Sstevel@tonic-gate 		void;
2890Sstevel@tonic-gate         case NIS_BOGUS_OBJ :
2900Sstevel@tonic-gate 		void;
2910Sstevel@tonic-gate         default :
2920Sstevel@tonic-gate                 void;
2930Sstevel@tonic-gate };
2940Sstevel@tonic-gate 
2950Sstevel@tonic-gate /*
2960Sstevel@tonic-gate  * This is the basic NIS object data type. It consists of a generic part
2970Sstevel@tonic-gate  * which all objects contain, and a specialized part which varies depending
2980Sstevel@tonic-gate  * on the type of the object. All of the specialized sections have been
2990Sstevel@tonic-gate  * described above. You might have wondered why they all start with an
3000Sstevel@tonic-gate  * integer size, followed by the useful data. The answer is, when the
3010Sstevel@tonic-gate  * server doesn't recognize the type returned it treats it as opaque data.
3020Sstevel@tonic-gate  * And the definition for opaque data is {int size; char *data;}. In this
3030Sstevel@tonic-gate  * way, servers and utility routines that do not understand a given type
3040Sstevel@tonic-gate  * may still pass it around. One has to be careful in setting
3050Sstevel@tonic-gate  * this variable accurately, it must take into account such things as
3060Sstevel@tonic-gate  * XDR padding of structures etc. The best way to set it is to note one's
3070Sstevel@tonic-gate  * position in the XDR encoding stream, encode the structure, look at the
3080Sstevel@tonic-gate  * new position and calculate the size.
3090Sstevel@tonic-gate  */
3100Sstevel@tonic-gate struct nis_oid {
3110Sstevel@tonic-gate 	uint32_t ctime;		/* Time of objects creation 	*/
3120Sstevel@tonic-gate 	uint32_t mtime;		/* Time of objects modification */
3130Sstevel@tonic-gate };
3140Sstevel@tonic-gate 
3150Sstevel@tonic-gate struct nis_object {
3160Sstevel@tonic-gate 	nis_oid	 zo_oid;	/* object identity verifier.		*/
3170Sstevel@tonic-gate 	nis_name zo_name;	/* The NIS name for this object		*/
3180Sstevel@tonic-gate 	nis_name zo_owner;	/* NIS name of object owner.		*/
3190Sstevel@tonic-gate 	nis_name zo_group;	/* NIS name of access group.		*/
3200Sstevel@tonic-gate 	nis_name zo_domain;	/* The administrator for the object	*/
3210Sstevel@tonic-gate 	uint_t	 zo_access;	/* Access rights (owner, group, world)	*/
3220Sstevel@tonic-gate 	uint32_t zo_ttl;	/* Object's time to live in seconds.	*/
3230Sstevel@tonic-gate 	objdata	 zo_data;	/* Data structure for this type 	*/
3240Sstevel@tonic-gate };
3250Sstevel@tonic-gate #if RPC_HDR
3260Sstevel@tonic-gate %
3270Sstevel@tonic-gate %#endif /* if __nis_object_h */
3280Sstevel@tonic-gate %
3290Sstevel@tonic-gate #endif
330