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