Home | History | Annotate | Download | only in rpcsvc
      1 /*
      2  *	nis_object.x
      3  *
      4  *	Copyright (c) 1988-1992 Sun Microsystems Inc
      5  *	All Rights Reserved.
      6  */
      7 
      8 %#pragma ident	"@(#)nis_object.x	1.12	97/11/19 SMI"
      9 
     10 #if RPC_HDR
     11 %
     12 %#ifndef __nis_object_h
     13 %#define __nis_object_h
     14 %
     15 #endif
     16 /*
     17  * 	This file defines the format for a NIS object in RPC language.
     18  * It is included by the main .x file and the database access protocol
     19  * file. It is common because both of them need to deal with the same
     20  * type of object. Generating the actual code though is a bit messy because
     21  * the nis.x file and the nis_dba.x file will generate xdr routines to
     22  * encode/decode objects when only one set is needed. Such is life when
     23  * one is using rpcgen.
     24  *
     25  * Note, the protocol doesn't specify any limits on such things as
     26  * maximum name length, number of attributes, etc. These are enforced
     27  * by the database backend. When you hit them you will no. Also see
     28  * the db_getlimits() function for fetching the limit values.
     29  *
     30  */
     31 
     32 /* Some manifest constants, chosen to maximize flexibility without
     33  * plugging the wire full of data.
     34  */
     35 const NIS_MAXSTRINGLEN = 255;
     36 const NIS_MAXNAMELEN   = 1024;
     37 const NIS_MAXATTRNAME  = 32;
     38 const NIS_MAXATTRVAL   = 2048;
     39 const NIS_MAXCOLUMNS   = 64;
     40 const NIS_MAXATTR      = 16;
     41 const NIS_MAXPATH      = 1024;
     42 const NIS_MAXREPLICAS  = 128;
     43 const NIS_MAXLINKS     = 16;
     44 
     45 const NIS_PK_NONE      = 0;	/* no public key (unix/sys auth) */
     46 const NIS_PK_DH	       = 1;	/* Public key is Diffie-Hellman type */
     47 const NIS_PK_RSA       = 2;	/* Public key if RSA type */
     48 const NIS_PK_KERB      = 3;	/* Use kerberos style authentication */
     49 const NIS_PK_DHEXT     = 4;	/* Extended Diffie-Hellman for RPC-GSS */
     50 
     51 /*
     52  * The fundamental name type of NIS. The name may consist of two parts,
     53  * the first being the fully qualified name, and the second being an
     54  * optional set of attribute/value pairs.
     55  */
     56 struct nis_attr {
     57 	string	zattr_ndx<>;	/* name of the index 		*/
     58 	opaque	zattr_val<>;	/* Value for the attribute. 	*/
     59 };
     60 
     61 typedef string nis_name<>;	/* The NIS name itself. */
     62 
     63 /* NIS object types are defined by the following enumeration. The numbers
     64  * they use are based on the following scheme :
     65  *		     0 - 1023 are reserved for Sun,
     66  * 		1024 - 2047 are defined to be private to a particular tree.
     67  *		2048 - 4095 are defined to be user defined.
     68  *		4096 - ...  are reserved for future use.
     69  *
     70  * EOL Alert - The non-prefixed names are present for backward
     71  * compatability only, and will not exist in future releases. Use
     72  * the NIS_* names for future compatability.
     73  */
     74 
     75 enum zotypes {
     76 
     77 	BOGUS_OBJ  	= 0,	/* Uninitialized object structure 	*/
     78 	NO_OBJ   	= 1,	/* NULL object (no data)	 	*/
     79 	DIRECTORY_OBJ 	= 2,	/* Directory object describing domain 	*/
     80 	GROUP_OBJ  	= 3,	/* Group object (a list of names) 	*/
     81 	TABLE_OBJ  	= 4,	/* Table object (a database schema) 	*/
     82 	ENTRY_OBJ  	= 5,	/* Entry object (a database record) 	*/
     83 	LINK_OBJ   	= 6, 	/* A name link.				*/
     84 	PRIVATE_OBJ  	= 7, 	/* Private object (all opaque data) 	*/
     85 
     86 	NIS_BOGUS_OBJ  	= 0,	/* Uninitialized object structure 	*/
     87 	NIS_NO_OBJ   	= 1,	/* NULL object (no data)	 	*/
     88 	NIS_DIRECTORY_OBJ = 2, /* Directory object describing domain 	*/
     89 	NIS_GROUP_OBJ  	= 3,	/* Group object (a list of names) 	*/
     90 	NIS_TABLE_OBJ  	= 4,	/* Table object (a database schema) 	*/
     91 	NIS_ENTRY_OBJ  	= 5,	/* Entry object (a database record) 	*/
     92 	NIS_LINK_OBJ	= 6, 	/* A name link.				*/
     93 	NIS_PRIVATE_OBJ  = 7 /* Private object (all opaque data) */
     94 };
     95 
     96 /*
     97  * The types of Name services NIS knows about. They are enumerated
     98  * here. The Binder code will use this type to determine if it has
     99  * a set of library routines that will access the indicated name service.
    100  */
    101 enum nstype {
    102 	UNKNOWN = 0,
    103 	NIS = 1,	/* Nis Plus Service		*/
    104 	SUNYP = 2,	/* Old NIS Service		*/
    105 	IVY = 3,	/* Nis Plus Plus Service	*/
    106 	DNS = 4,	/* Domain Name Service		*/
    107 	X500 = 5,	/* ISO/CCCIT X.500 Service	*/
    108 	DNANS = 6,	/* Digital DECNet Name Service	*/
    109 	XCHS = 7,	/* Xerox ClearingHouse Service	*/
    110 	CDS= 8
    111 };
    112 
    113 /*
    114  * DIRECTORY - The name service object. These objects identify other name
    115  * servers that are serving some portion of the name space. Each has a
    116  * type associated with it. The resolver library will note whether or not
    117  * is has the needed routines to access that type of service.
    118  * The oarmask structure defines an access rights mask on a per object
    119  * type basis for the name spaces. The only bits currently used are
    120  * create and destroy. By enabling or disabling these access rights for
    121  * a specific object type for a one of the accessor entities (owner,
    122  * group, world) the administrator can control what types of objects
    123  * may be freely added to the name space and which require the
    124  * administrator's approval.
    125  */
    126 struct oar_mask {
    127 	uint32_t	oa_rights;	/* Access rights mask 	*/
    128 	zotypes		oa_otype;	/* Object type 		*/
    129 };
    130 
    131 struct endpoint {
    132 	string		uaddr<>;
    133 	string		family<>;   /* Transport family (INET, OSI, etc) */
    134 	string		proto<>;    /* Protocol (TCP, UDP, CLNP,  etc)   */
    135 };
    136 
    137 /*
    138  * Note: pkey is a netobj which is limited to 1024 bytes which limits the
    139  * keysize to 8192 bits. This is consider to be a reasonable limit for
    140  * the expected lifetime of this service.
    141  */
    142 struct nis_server {
    143 	nis_name	name; 	 	/* Principal name of the server  */
    144 	endpoint	ep<>;  		/* Universal addr(s) for server  */
    145 	uint32_t	key_type;	/* Public key type		 */
    146 	netobj		pkey;		/* server's public key  	 */
    147 };
    148 
    149 struct directory_obj {
    150 	nis_name   do_name;	 /* Name of the directory being served   */
    151 	nstype	   do_type;	 /* one of NIS, DNS, IVY, YP, or X.500 	 */
    152 	nis_server do_servers<>; /* <0> == Primary name server     	 */
    153 	uint32_t   do_ttl;	 /* Time To Live (for caches) 		 */
    154 	oar_mask   do_armask<>;  /* Create/Destroy rights by object type */
    155 };
    156 
    157 /*
    158  * ENTRY - This is one row of data from an information base.
    159  * The type value is used by the client library to convert the entry to
    160  * it's internal structure representation. The Table name is a back pointer
    161  * to the table where the entry is stored. This allows the client library
    162  * to determine where to send a request if the client wishes to change this
    163  * entry but got to it through a LINK rather than directly.
    164  * If the entry is a "standalone" entry then this field is void.
    165  */
    166 const EN_BINARY   = 1;	/* Indicates value is binary data 	*/
    167 const EN_CRYPT    = 2;	/* Indicates the value is encrypted	*/
    168 const EN_XDR      = 4;	/* Indicates the value is XDR encoded	*/
    169 const EN_MODIFIED = 8;	/* Indicates entry is modified. 	*/
    170 const EN_ASN1     = 64;	/* Means contents use ASN.1 encoding    */
    171 
    172 struct entry_col {
    173 	uint32_t	ec_flags;	/* Flags for this value */
    174 	opaque		ec_value<>;	/* It's textual value	*/
    175 };
    176 
    177 struct entry_obj {
    178 	string 	en_type<>;	/* Type of entry such as "passwd" */
    179 	entry_col en_cols<>;	/* Value for the entry		  */
    180 };
    181 
    182 /*
    183  * GROUP - The group object contains a list of NIS principal names. Groups
    184  * are used to authorize principals. Each object has a set of access rights
    185  * for members of its group. Principal names in groups are in the form
    186  * name.directory and recursive groups are expressed as @groupname.directory
    187  */
    188 struct group_obj {
    189 	uint32_t	gr_flags;	/* Flags controlling group	*/
    190 	nis_name	gr_members<>;  	/* List of names in group 	*/
    191 };
    192 
    193 /*
    194  * LINK - This is the LINK object. It is quite similar to a symbolic link
    195  * in the UNIX filesystem. The attributes in the main object structure are
    196  * relative to the LINK data and not what it points to (like the file system)
    197  * "modify" privleges here indicate the right to modify what the link points
    198  * at and not to modify that actual object pointed to by the link.
    199  */
    200 struct link_obj {
    201 	zotypes	 li_rtype;	/* Real type of the object	*/
    202 	nis_attr li_attrs<>;	/* Attribute/Values for tables	*/
    203 	nis_name li_name; 	/* The object's real NIS name	*/
    204 };
    205 
    206 /*
    207  * TABLE - This is the table object. It implements a simple
    208  * data base that applications and use for configuration or
    209  * administration purposes. The role of the table is to group together
    210  * a set of related entries. Tables are the simple database component
    211  * of NIS. Like many databases, tables are logically divided into columns
    212  * and rows. The columns are labeled with indexes and each ENTRY makes
    213  * up a row. Rows may be addressed within the table by selecting one
    214  * or more indexes, and values for those indexes. Each row which has
    215  * a value for the given index that matches the desired value is returned.
    216  * Within the definition of each column there is a flags variable, this
    217  * variable contains flags which determine whether or not the column is
    218  * searchable, contains binary data, and access rights for the entry objects
    219  * column value.
    220  */
    221 
    222 const TA_BINARY     = 1;	/* Means table data is binary 		*/
    223 const TA_CRYPT      = 2;	/* Means value should be encrypted 	*/
    224 const TA_XDR        = 4;	/* Means value is XDR encoded		*/
    225 const TA_SEARCHABLE = 8;	/* Means this column is searchable	*/
    226 const TA_CASE       = 16;	/* Means this column is Case Sensitive	*/
    227 const TA_MODIFIED   = 32;	/* Means this columns attrs are modified*/
    228 const TA_ASN1       = 64;	/* Means contents use ASN.1 encoding     */
    229 
    230 struct table_col {
    231 	string		tc_name<64>;	/* Column Name 	 	   */
    232 	uint32_t	tc_flags;	/* control flags	   */
    233 	uint32_t	tc_rights;	/* Access rights mask	   */
    234 };
    235 
    236 struct table_obj {
    237 	string 	  ta_type<64>;	 /* Table type such as "passwd"	*/
    238 	int	  ta_maxcol;	 /* Total number of columns	*/
    239 	u_char	  ta_sep;	 /* Separator character 	*/
    240 	table_col ta_cols<>; 	 /* The number of table indexes */
    241 	string	  ta_path<>;	 /* A search path for this table */
    242 };
    243 
    244 /*
    245  * This union joins together all of the currently known objects.
    246  */
    247 union objdata switch (zotypes zo_type) {
    248         case NIS_DIRECTORY_OBJ :
    249                 struct directory_obj di_data;
    250         case NIS_GROUP_OBJ :
    251                 struct group_obj gr_data;
    252         case NIS_TABLE_OBJ :
    253                 struct table_obj ta_data;
    254         case NIS_ENTRY_OBJ:
    255                 struct entry_obj en_data;
    256         case NIS_LINK_OBJ :
    257                 struct link_obj li_data;
    258         case NIS_PRIVATE_OBJ :
    259                 opaque	po_data<>;
    260 	case NIS_NO_OBJ :
    261 		void;
    262         case NIS_BOGUS_OBJ :
    263 		void;
    264         default :
    265                 void;
    266 };
    267 
    268 /*
    269  * This is the basic NIS object data type. It consists of a generic part
    270  * which all objects contain, and a specialized part which varies depending
    271  * on the type of the object. All of the specialized sections have been
    272  * described above. You might have wondered why they all start with an
    273  * integer size, followed by the useful data. The answer is, when the
    274  * server doesn't recognize the type returned it treats it as opaque data.
    275  * And the definition for opaque data is {int size; char *data;}. In this
    276  * way, servers and utility routines that do not understand a given type
    277  * may still pass it around. One has to be careful in setting
    278  * this variable accurately, it must take into account such things as
    279  * XDR padding of structures etc. The best way to set it is to note one's
    280  * position in the XDR encoding stream, encode the structure, look at the
    281  * new position and calculate the size.
    282  */
    283 struct nis_oid {
    284 	uint32_t ctime;		/* Time of objects creation 	*/
    285 	uint32_t mtime;		/* Time of objects modification */
    286 };
    287 
    288 struct nis_object {
    289 	nis_oid	 zo_oid;	/* object identity verifier.		*/
    290 	nis_name zo_name;	/* The NIS name for this object		*/
    291 	nis_name zo_owner;	/* NIS name of object owner.		*/
    292 	nis_name zo_group;	/* NIS name of access group.		*/
    293 	nis_name zo_domain;	/* The administrator for the object	*/
    294 	uint32_t zo_access;	/* Access rights (owner, group, world)	*/
    295 	uint32_t zo_ttl;	/* Object's time to live in seconds.	*/
    296 	objdata	 zo_data;	/* Data structure for this type 	*/
    297 };
    298 #if RPC_HDR
    299 %
    300 %#endif /* if __nis_object_h */
    301 %
    302 #endif
    303