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