xref: /freebsd/include/rpcsvc/nis_object.x (revision 5a1d1441)
18785398fSHiroki Sato %/*-
28785398fSHiroki Sato % * Copyright (c) 2010, Oracle America, Inc.
33b0f7467SBill Paul % *
48785398fSHiroki Sato % * Redistribution and use in source and binary forms, with or without
58785398fSHiroki Sato % * modification, are permitted provided that the following conditions are
68785398fSHiroki Sato % * met:
73b0f7467SBill Paul % *
88785398fSHiroki Sato % *     * Redistributions of source code must retain the above copyright
98785398fSHiroki Sato % *       notice, this list of conditions and the following disclaimer.
108785398fSHiroki Sato % *     * Redistributions in binary form must reproduce the above
118785398fSHiroki Sato % *       copyright notice, this list of conditions and the following
128785398fSHiroki Sato % *       disclaimer in the documentation and/or other materials
138785398fSHiroki Sato % *       provided with the distribution.
148785398fSHiroki Sato % *     * Neither the name of the "Oracle America, Inc." nor the names of its
158785398fSHiroki Sato % *       contributors may be used to endorse or promote products derived
168785398fSHiroki Sato % *       from this software without specific prior written permission.
173b0f7467SBill Paul % *
188785398fSHiroki Sato % *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
198785398fSHiroki Sato % *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
208785398fSHiroki Sato % *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
218785398fSHiroki Sato % *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
228785398fSHiroki Sato % *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
238785398fSHiroki Sato % *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
248785398fSHiroki Sato % *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
258785398fSHiroki Sato % *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
268785398fSHiroki Sato % *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
278785398fSHiroki Sato % *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
288785398fSHiroki Sato % *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
298785398fSHiroki Sato % *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
303b0f7467SBill Paul % */
313b0f7467SBill Paul 
323b0f7467SBill Paul /*
333b0f7467SBill Paul  *	nis_object.x
343b0f7467SBill Paul  *
353b0f7467SBill Paul  *	Copyright (c) 1988-1992 Sun Microsystems Inc
363b0f7467SBill Paul  *	All Rights Reserved.
373b0f7467SBill Paul  */
383b0f7467SBill Paul 
393b0f7467SBill Paul #if RPC_HDR
403b0f7467SBill Paul %
413b0f7467SBill Paul %#ifndef __nis_object_h
423b0f7467SBill Paul %#define __nis_object_h
433b0f7467SBill Paul %
443b0f7467SBill Paul #endif
453b0f7467SBill Paul /*
463b0f7467SBill Paul  * 	This file defines the format for a NIS object in RPC language.
473b0f7467SBill Paul  * It is included by the main .x file and the database access protocol
483b0f7467SBill Paul  * file. It is common because both of them need to deal with the same
493b0f7467SBill Paul  * type of object. Generating the actual code though is a bit messy because
503b0f7467SBill Paul  * the nis.x file and the nis_dba.x file will generate xdr routines to
513b0f7467SBill Paul  * encode/decode objects when only one set is needed. Such is life when
523b0f7467SBill Paul  * one is using rpcgen.
533b0f7467SBill Paul  *
543b0f7467SBill Paul  * Note, the protocol doesn't specify any limits on such things as
553b0f7467SBill Paul  * maximum name length, number of attributes, etc. These are enforced
563b0f7467SBill Paul  * by the database backend. When you hit them you will no. Also see
573b0f7467SBill Paul  * the db_getlimits() function for fetching the limit values.
583b0f7467SBill Paul  *
593b0f7467SBill Paul  */
603b0f7467SBill Paul 
613b0f7467SBill Paul /* Some manifest constants, chosen to maximize flexibility without
623b0f7467SBill Paul  * plugging the wire full of data.
633b0f7467SBill Paul  */
643b0f7467SBill Paul const NIS_MAXSTRINGLEN = 255;
653b0f7467SBill Paul const NIS_MAXNAMELEN   = 1024;
663b0f7467SBill Paul const NIS_MAXATTRNAME  = 32;
673b0f7467SBill Paul const NIS_MAXATTRVAL   = 2048;
683b0f7467SBill Paul const NIS_MAXCOLUMNS   = 64;
693b0f7467SBill Paul const NIS_MAXATTR      = 16;
703b0f7467SBill Paul const NIS_MAXPATH      = 1024;
713b0f7467SBill Paul const NIS_MAXREPLICAS  = 128;
723b0f7467SBill Paul const NIS_MAXLINKS     = 16;
733b0f7467SBill Paul 
743b0f7467SBill Paul const NIS_PK_NONE      = 0;	/* no public key (unix/sys auth) */
753b0f7467SBill Paul const NIS_PK_DH	       = 1;	/* Public key is Diffie-Hellman type */
763b0f7467SBill Paul const NIS_PK_RSA       = 2;	/* Public key if RSA type */
773b0f7467SBill Paul const NIS_PK_KERB      = 3;	/* Use kerberos style authentication */
783b0f7467SBill Paul 
793b0f7467SBill Paul /*
803b0f7467SBill Paul  * The fundamental name type of NIS. The name may consist of two parts,
813b0f7467SBill Paul  * the first being the fully qualified name, and the second being an
823b0f7467SBill Paul  * optional set of attribute/value pairs.
833b0f7467SBill Paul  */
843b0f7467SBill Paul struct nis_attr {
853b0f7467SBill Paul 	string	zattr_ndx<>;	/* name of the index 		*/
863b0f7467SBill Paul 	opaque	zattr_val<>;	/* Value for the attribute. 	*/
873b0f7467SBill Paul };
883b0f7467SBill Paul 
893b0f7467SBill Paul typedef string nis_name<>;	/* The NIS name itself. */
903b0f7467SBill Paul 
913b0f7467SBill Paul /* NIS object types are defined by the following enumeration. The numbers
923b0f7467SBill Paul  * they use are based on the following scheme :
933b0f7467SBill Paul  *		     0 - 1023 are reserved for Sun,
943b0f7467SBill Paul  * 		1024 - 2047 are defined to be private to a particular tree.
953b0f7467SBill Paul  *		2048 - 4095 are defined to be user defined.
963b0f7467SBill Paul  *		4096 - ...  are reserved for future use.
973b0f7467SBill Paul  */
983b0f7467SBill Paul 
993b0f7467SBill Paul enum zotypes {
1003b0f7467SBill Paul 	BOGUS_OBJ  	= 0,	/* Uninitialized object structure 	*/
1013b0f7467SBill Paul 	NO_OBJ   	= 1,	/* NULL object (no data)	 	*/
1023b0f7467SBill Paul 	DIRECTORY_OBJ 	= 2,	/* Directory object describing domain 	*/
1033b0f7467SBill Paul 	GROUP_OBJ  	= 3,	/* Group object (a list of names) 	*/
1043b0f7467SBill Paul 	TABLE_OBJ  	= 4,	/* Table object (a database schema) 	*/
1053b0f7467SBill Paul 	ENTRY_OBJ  	= 5,	/* Entry object (a database record) 	*/
1063b0f7467SBill Paul 	LINK_OBJ   	= 6, 	/* A name link.				*/
1073b0f7467SBill Paul 	PRIVATE_OBJ   	= 7 	/* Private object (all opaque data) 	*/
1083b0f7467SBill Paul };
1093b0f7467SBill Paul 
1103b0f7467SBill Paul /*
1113b0f7467SBill Paul  * The types of Name services NIS knows about. They are enumerated
1123b0f7467SBill Paul  * here. The Binder code will use this type to determine if it has
1133b0f7467SBill Paul  * a set of library routines that will access the indicated name service.
1143b0f7467SBill Paul  */
1153b0f7467SBill Paul enum nstype {
1163b0f7467SBill Paul 	UNKNOWN = 0,
1173b0f7467SBill Paul 	NIS = 1,	/* Nis Plus Service		*/
1183b0f7467SBill Paul 	SUNYP = 2,	/* Old NIS Service		*/
1193b0f7467SBill Paul 	IVY = 3,	/* Nis Plus Plus Service	*/
1203b0f7467SBill Paul 	DNS = 4,	/* Domain Name Service		*/
1213b0f7467SBill Paul 	X500 = 5,	/* ISO/CCCIT X.500 Service	*/
1223b0f7467SBill Paul 	DNANS = 6,	/* Digital DECNet Name Service	*/
1233b0f7467SBill Paul 	XCHS = 7,	/* Xerox ClearingHouse Service	*/
1243b0f7467SBill Paul 	CDS= 8
1253b0f7467SBill Paul };
1263b0f7467SBill Paul 
1273b0f7467SBill Paul /*
1283b0f7467SBill Paul  * DIRECTORY - The name service object. These objects identify other name
1293b0f7467SBill Paul  * servers that are serving some portion of the name space. Each has a
1303b0f7467SBill Paul  * type associated with it. The resolver library will note whether or not
1313b0f7467SBill Paul  * is has the needed routines to access that type of service.
1323b0f7467SBill Paul  * The oarmask structure defines an access rights mask on a per object
1333b0f7467SBill Paul  * type basis for the name spaces. The only bits currently used are
1343b0f7467SBill Paul  * create and destroy. By enabling or disabling these access rights for
1353b0f7467SBill Paul  * a specific object type for a one of the accessor entities (owner,
1363b0f7467SBill Paul  * group, world) the administrator can control what types of objects
1373b0f7467SBill Paul  * may be freely added to the name space and which require the
1383b0f7467SBill Paul  * administrator's approval.
1393b0f7467SBill Paul  */
1403b0f7467SBill Paul struct oar_mask {
1413b0f7467SBill Paul 	u_long	oa_rights;	/* Access rights mask 	*/
1423b0f7467SBill Paul 	zotypes	oa_otype;	/* Object type 		*/
1433b0f7467SBill Paul };
1443b0f7467SBill Paul 
1453b0f7467SBill Paul struct endpoint {
1463b0f7467SBill Paul 	string		uaddr<>;
1473b0f7467SBill Paul 	string		family<>;   /* Transport family (INET, OSI, etc) */
1483b0f7467SBill Paul 	string		proto<>;    /* Protocol (TCP, UDP, CLNP,  etc)   */
1493b0f7467SBill Paul };
1503b0f7467SBill Paul 
1513b0f7467SBill Paul /*
1523b0f7467SBill Paul  * Note: pkey is a netobj which is limited to 1024 bytes which limits the
1533b0f7467SBill Paul  * keysize to 8192 bits. This is consider to be a reasonable limit for
1543b0f7467SBill Paul  * the expected lifetime of this service.
1553b0f7467SBill Paul  */
1563b0f7467SBill Paul struct nis_server {
1573b0f7467SBill Paul 	nis_name	name; 	 	/* Principal name of the server  */
1583b0f7467SBill Paul 	endpoint	ep<>;  		/* Universal addr(s) for server  */
1593b0f7467SBill Paul 	u_long		key_type;	/* Public key type		 */
1603b0f7467SBill Paul 	netobj		pkey;		/* server's public key  	 */
1613b0f7467SBill Paul };
1623b0f7467SBill Paul 
1633b0f7467SBill Paul struct directory_obj {
1643b0f7467SBill Paul 	nis_name   do_name;	 /* Name of the directory being served   */
1653b0f7467SBill Paul 	nstype	   do_type;	 /* one of NIS, DNS, IVY, YP, or X.500 	 */
1663b0f7467SBill Paul 	nis_server do_servers<>; /* <0> == Primary name server     	 */
1673b0f7467SBill Paul 	u_long	   do_ttl;	 /* Time To Live (for caches) 		 */
1683b0f7467SBill Paul 	oar_mask   do_armask<>;  /* Create/Destroy rights by object type */
1693b0f7467SBill Paul };
1703b0f7467SBill Paul 
1713b0f7467SBill Paul /*
1723b0f7467SBill Paul  * ENTRY - This is one row of data from an information base.
1733b0f7467SBill Paul  * The type value is used by the client library to convert the entry to
1743b0f7467SBill Paul  * it's internal structure representation. The Table name is a back pointer
1753b0f7467SBill Paul  * to the table where the entry is stored. This allows the client library
1763b0f7467SBill Paul  * to determine where to send a request if the client wishes to change this
1773b0f7467SBill Paul  * entry but got to it through a LINK rather than directly.
1783b0f7467SBill Paul  * If the entry is a "standalone" entry then this field is void.
1793b0f7467SBill Paul  */
1803b0f7467SBill Paul const EN_BINARY   = 1;	/* Indicates value is binary data 	*/
1813b0f7467SBill Paul const EN_CRYPT    = 2;	/* Indicates the value is encrypted	*/
1823b0f7467SBill Paul const EN_XDR      = 4;	/* Indicates the value is XDR encoded	*/
1833b0f7467SBill Paul const EN_MODIFIED = 8;	/* Indicates entry is modified. 	*/
1843b0f7467SBill Paul const EN_ASN1     = 64;	/* Means contents use ASN.1 encoding    */
1853b0f7467SBill Paul 
1863b0f7467SBill Paul struct entry_col {
1873b0f7467SBill Paul 	u_long	ec_flags;	/* Flags for this value */
1883b0f7467SBill Paul 	opaque	ec_value<>;	/* It's textual value	*/
1893b0f7467SBill Paul };
1903b0f7467SBill Paul 
1913b0f7467SBill Paul struct entry_obj {
1923b0f7467SBill Paul 	string 	en_type<>;	/* Type of entry such as "passwd" */
1933b0f7467SBill Paul 	entry_col en_cols<>;	/* Value for the entry		  */
1943b0f7467SBill Paul };
1953b0f7467SBill Paul 
1963b0f7467SBill Paul /*
1973b0f7467SBill Paul  * GROUP - The group object contains a list of NIS principal names. Groups
1983b0f7467SBill Paul  * are used to authorize principals. Each object has a set of access rights
1993b0f7467SBill Paul  * for members of its group. Principal names in groups are in the form
2003b0f7467SBill Paul  * name.directory and recursive groups are expressed as @groupname.directory
2013b0f7467SBill Paul  */
2023b0f7467SBill Paul struct group_obj {
2033b0f7467SBill Paul 	u_long		gr_flags;	/* Flags controlling group	*/
2043b0f7467SBill Paul 	nis_name	gr_members<>;  	/* List of names in group 	*/
2053b0f7467SBill Paul };
2063b0f7467SBill Paul 
2073b0f7467SBill Paul /*
2083b0f7467SBill Paul  * LINK - This is the LINK object. It is quite similar to a symbolic link
2093b0f7467SBill Paul  * in the UNIX filesystem. The attributes in the main object structure are
2103b0f7467SBill Paul  * relative to the LINK data and not what it points to (like the file system)
2113b0f7467SBill Paul  * "modify" privleges here indicate the right to modify what the link points
2123b0f7467SBill Paul  * at and not to modify that actual object pointed to by the link.
2133b0f7467SBill Paul  */
2143b0f7467SBill Paul struct link_obj {
2153b0f7467SBill Paul 	zotypes	 li_rtype;	/* Real type of the object	*/
2163b0f7467SBill Paul 	nis_attr li_attrs<>;	/* Attribute/Values for tables	*/
2173b0f7467SBill Paul 	nis_name li_name; 	/* The object's real NIS name	*/
2183b0f7467SBill Paul };
2193b0f7467SBill Paul 
2203b0f7467SBill Paul /*
2213b0f7467SBill Paul  * TABLE - This is the table object. It implements a simple
2223b0f7467SBill Paul  * data base that applications and use for configuration or
2233b0f7467SBill Paul  * administration purposes. The role of the table is to group together
2243b0f7467SBill Paul  * a set of related entries. Tables are the simple database component
2253b0f7467SBill Paul  * of NIS. Like many databases, tables are logically divided into columns
2263b0f7467SBill Paul  * and rows. The columns are labeled with indexes and each ENTRY makes
2273b0f7467SBill Paul  * up a row. Rows may be addressed within the table by selecting one
2283b0f7467SBill Paul  * or more indexes, and values for those indexes. Each row which has
2293b0f7467SBill Paul  * a value for the given index that matches the desired value is returned.
2303b0f7467SBill Paul  * Within the definition of each column there is a flags variable, this
2313b0f7467SBill Paul  * variable contains flags which determine whether or not the column is
2323b0f7467SBill Paul  * searchable, contains binary data, and access rights for the entry objects
2333b0f7467SBill Paul  * column value.
2343b0f7467SBill Paul  */
2353b0f7467SBill Paul 
2363b0f7467SBill Paul const TA_BINARY     = 1;	/* Means table data is binary 		*/
2373b0f7467SBill Paul const TA_CRYPT      = 2;	/* Means value should be encrypted 	*/
2383b0f7467SBill Paul const TA_XDR        = 4;	/* Means value is XDR encoded		*/
2393b0f7467SBill Paul const TA_SEARCHABLE = 8;	/* Means this column is searchable	*/
2403b0f7467SBill Paul const TA_CASE       = 16;	/* Means this column is Case Sensitive	*/
2413b0f7467SBill Paul const TA_MODIFIED   = 32;	/* Means this columns attrs are modified*/
2423b0f7467SBill Paul const TA_ASN1       = 64;	/* Means contents use ASN.1 encoding     */
2433b0f7467SBill Paul 
2443b0f7467SBill Paul struct table_col {
2453b0f7467SBill Paul 	string	tc_name<64>;	/* Column Name 	 	   */
2463b0f7467SBill Paul 	u_long	tc_flags;	/* control flags	   */
2473b0f7467SBill Paul 	u_long	tc_rights;	/* Access rights mask	   */
2483b0f7467SBill Paul };
2493b0f7467SBill Paul 
2503b0f7467SBill Paul struct table_obj {
2513b0f7467SBill Paul 	string 	  ta_type<64>;	 /* Table type such as "passwd"	*/
2523b0f7467SBill Paul 	int	  ta_maxcol;	 /* Total number of columns	*/
2533b0f7467SBill Paul 	u_char	  ta_sep;	 /* Separator character 	*/
2543b0f7467SBill Paul 	table_col ta_cols<>; 	 /* The number of table indexes */
2553b0f7467SBill Paul 	string	  ta_path<>;	 /* A search path for this table */
2563b0f7467SBill Paul };
2573b0f7467SBill Paul 
2583b0f7467SBill Paul /*
2593b0f7467SBill Paul  * This union joins together all of the currently known objects.
2603b0f7467SBill Paul  */
2613b0f7467SBill Paul union objdata switch (zotypes zo_type) {
2623b0f7467SBill Paul         case DIRECTORY_OBJ :
2633b0f7467SBill Paul                 struct directory_obj di_data;
2643b0f7467SBill Paul         case GROUP_OBJ :
2653b0f7467SBill Paul                 struct group_obj gr_data;
2663b0f7467SBill Paul         case TABLE_OBJ :
2673b0f7467SBill Paul                 struct table_obj ta_data;
2683b0f7467SBill Paul         case ENTRY_OBJ:
2693b0f7467SBill Paul                 struct entry_obj en_data;
2703b0f7467SBill Paul         case LINK_OBJ :
2713b0f7467SBill Paul                 struct link_obj li_data;
2723b0f7467SBill Paul         case PRIVATE_OBJ :
2733b0f7467SBill Paul                 opaque	po_data<>;
2743b0f7467SBill Paul 	case NO_OBJ :
2753b0f7467SBill Paul 		void;
2763b0f7467SBill Paul         case BOGUS_OBJ :
2773b0f7467SBill Paul 		void;
2783b0f7467SBill Paul         default :
2793b0f7467SBill Paul                 void;
2803b0f7467SBill Paul };
2813b0f7467SBill Paul 
2823b0f7467SBill Paul /*
2833b0f7467SBill Paul  * This is the basic NIS object data type. It consists of a generic part
2843b0f7467SBill Paul  * which all objects contain, and a specialized part which varies depending
2853b0f7467SBill Paul  * on the type of the object. All of the specialized sections have been
2863b0f7467SBill Paul  * described above. You might have wondered why they all start with an
2873b0f7467SBill Paul  * integer size, followed by the useful data. The answer is, when the
2883b0f7467SBill Paul  * server doesn't recognize the type returned it treats it as opaque data.
2893b0f7467SBill Paul  * And the definition for opaque data is {int size; char *data;}. In this
2903b0f7467SBill Paul  * way, servers and utility routines that do not understand a given type
2913b0f7467SBill Paul  * may still pass it around. One has to be careful in setting
2923b0f7467SBill Paul  * this variable accurately, it must take into account such things as
2933b0f7467SBill Paul  * XDR padding of structures etc. The best way to set it is to note one's
2943b0f7467SBill Paul  * position in the XDR encoding stream, encode the structure, look at the
2953b0f7467SBill Paul  * new position and calculate the size.
2963b0f7467SBill Paul  */
2973b0f7467SBill Paul struct nis_oid {
2983b0f7467SBill Paul 	u_long	ctime;		/* Time of objects creation 	*/
2993b0f7467SBill Paul 	u_long	mtime;		/* Time of objects modification */
3003b0f7467SBill Paul };
3013b0f7467SBill Paul 
3023b0f7467SBill Paul struct nis_object {
3033b0f7467SBill Paul 	nis_oid	 zo_oid;	/* object identity verifier.		*/
3043b0f7467SBill Paul 	nis_name zo_name;	/* The NIS name for this object		*/
3053b0f7467SBill Paul 	nis_name zo_owner;	/* NIS name of object owner.		*/
3063b0f7467SBill Paul 	nis_name zo_group;	/* NIS name of access group.		*/
3073b0f7467SBill Paul 	nis_name zo_domain;	/* The administrator for the object	*/
3083b0f7467SBill Paul 	u_long	 zo_access;	/* Access rights (owner, group, world)	*/
3093b0f7467SBill Paul 	u_long	 zo_ttl;	/* Object's time to live in seconds.	*/
3103b0f7467SBill Paul 	objdata	 zo_data;	/* Data structure for this type 	*/
3113b0f7467SBill Paul };
3123b0f7467SBill Paul #if RPC_HDR
3133b0f7467SBill Paul %
3143b0f7467SBill Paul %#endif /* if __nis_object_h */
3153b0f7467SBill Paul %
3163b0f7467SBill Paul #endif
317