nis_object.x revision 302408
1202375Srdivacky%/*-
2202375Srdivacky% * Copyright (c) 2010, Oracle America, Inc.
3202375Srdivacky% *
4202375Srdivacky% * Redistribution and use in source and binary forms, with or without
5202375Srdivacky% * modification, are permitted provided that the following conditions are
6202375Srdivacky% * met:
7202375Srdivacky% *
8202375Srdivacky% *     * Redistributions of source code must retain the above copyright
9202375Srdivacky% *       notice, this list of conditions and the following disclaimer.
10202375Srdivacky% *     * Redistributions in binary form must reproduce the above
11202375Srdivacky% *       copyright notice, this list of conditions and the following
12202375Srdivacky% *       disclaimer in the documentation and/or other materials
13202375Srdivacky% *       provided with the distribution.
14202375Srdivacky% *     * Neither the name of the "Oracle America, Inc." nor the names of its
15202375Srdivacky% *       contributors may be used to endorse or promote products derived
16202375Srdivacky% *       from this software without specific prior written permission.
17202375Srdivacky% *
18202375Srdivacky% *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19202375Srdivacky% *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20202375Srdivacky% *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21202375Srdivacky% *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22202375Srdivacky% *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23202375Srdivacky% *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24202375Srdivacky% *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
25202375Srdivacky% *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26202375Srdivacky% *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27202375Srdivacky% *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28202375Srdivacky% *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29202375Srdivacky% *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30202375Srdivacky% */
31202375Srdivacky
32202375Srdivacky/*
33202375Srdivacky *	nis_object.x
34202375Srdivacky *
35202375Srdivacky *	Copyright (c) 1988-1992 Sun Microsystems Inc
36202375Srdivacky *	All Rights Reserved.
37202375Srdivacky */
38202375Srdivacky
39202375Srdivacky/* $FreeBSD: stable/11/include/rpcsvc/nis_object.x 259117 2013-12-09 04:26:50Z hrs $ */
40202375Srdivacky/* From: %#pragma ident	"@(#)nis_object.x	1.10	94/05/03 SMI" */
41202375Srdivacky
42202375Srdivacky#if RPC_HDR
43202375Srdivacky%
44202375Srdivacky%#ifndef __nis_object_h
45202375Srdivacky%#define __nis_object_h
46202375Srdivacky%
47202375Srdivacky#endif
48202375Srdivacky/*
49202375Srdivacky * 	This file defines the format for a NIS object in RPC language.
50202375Srdivacky * It is included by the main .x file and the database access protocol
51202375Srdivacky * file. It is common because both of them need to deal with the same
52202375Srdivacky * type of object. Generating the actual code though is a bit messy because
53202375Srdivacky * the nis.x file and the nis_dba.x file will generate xdr routines to
54202375Srdivacky * encode/decode objects when only one set is needed. Such is life when
55202375Srdivacky * one is using rpcgen.
56202375Srdivacky *
57202375Srdivacky * Note, the protocol doesn't specify any limits on such things as
58202375Srdivacky * maximum name length, number of attributes, etc. These are enforced
59202375Srdivacky * by the database backend. When you hit them you will no. Also see
60202375Srdivacky * the db_getlimits() function for fetching the limit values.
61202375Srdivacky *
62202375Srdivacky */
63202375Srdivacky
64202375Srdivacky/* Some manifest constants, chosen to maximize flexibility without
65202375Srdivacky * plugging the wire full of data.
66202375Srdivacky */
67202375Srdivackyconst NIS_MAXSTRINGLEN = 255;
68202375Srdivackyconst NIS_MAXNAMELEN   = 1024;
69202375Srdivackyconst NIS_MAXATTRNAME  = 32;
70202375Srdivackyconst NIS_MAXATTRVAL   = 2048;
71202375Srdivackyconst NIS_MAXCOLUMNS   = 64;
72202375Srdivackyconst NIS_MAXATTR      = 16;
73202375Srdivackyconst NIS_MAXPATH      = 1024;
74202375Srdivackyconst NIS_MAXREPLICAS  = 128;
75202375Srdivackyconst NIS_MAXLINKS     = 16;
76202375Srdivacky
77202375Srdivackyconst NIS_PK_NONE      = 0;	/* no public key (unix/sys auth) */
78202375Srdivackyconst NIS_PK_DH	       = 1;	/* Public key is Diffie-Hellman type */
79202375Srdivackyconst NIS_PK_RSA       = 2;	/* Public key if RSA type */
80202375Srdivackyconst NIS_PK_KERB      = 3;	/* Use kerberos style authentication */
81202375Srdivacky
82202375Srdivacky/*
83202375Srdivacky * The fundamental name type of NIS. The name may consist of two parts,
84202375Srdivacky * the first being the fully qualified name, and the second being an
85202375Srdivacky * optional set of attribute/value pairs.
86202375Srdivacky */
87202375Srdivackystruct nis_attr {
88202375Srdivacky	string	zattr_ndx<>;	/* name of the index 		*/
89202375Srdivacky	opaque	zattr_val<>;	/* Value for the attribute. 	*/
90202375Srdivacky};
91202375Srdivacky
92202375Srdivackytypedef string nis_name<>;	/* The NIS name itself. */
93202375Srdivacky
94202375Srdivacky/* NIS object types are defined by the following enumeration. The numbers
95202375Srdivacky * they use are based on the following scheme :
96202375Srdivacky *		     0 - 1023 are reserved for Sun,
97202375Srdivacky * 		1024 - 2047 are defined to be private to a particular tree.
98202375Srdivacky *		2048 - 4095 are defined to be user defined.
99202375Srdivacky *		4096 - ...  are reserved for future use.
100202375Srdivacky */
101202375Srdivacky
102202375Srdivackyenum zotypes {
103202375Srdivacky	BOGUS_OBJ  	= 0,	/* Uninitialized object structure 	*/
104202375Srdivacky	NO_OBJ   	= 1,	/* NULL object (no data)	 	*/
105202375Srdivacky	DIRECTORY_OBJ 	= 2,	/* Directory object describing domain 	*/
106202375Srdivacky	GROUP_OBJ  	= 3,	/* Group object (a list of names) 	*/
107202375Srdivacky	TABLE_OBJ  	= 4,	/* Table object (a database schema) 	*/
108202375Srdivacky	ENTRY_OBJ  	= 5,	/* Entry object (a database record) 	*/
109202375Srdivacky	LINK_OBJ   	= 6, 	/* A name link.				*/
110202375Srdivacky	PRIVATE_OBJ   	= 7 	/* Private object (all opaque data) 	*/
111202375Srdivacky};
112202375Srdivacky
113202375Srdivacky/*
114202375Srdivacky * The types of Name services NIS knows about. They are enumerated
115202375Srdivacky * here. The Binder code will use this type to determine if it has
116202375Srdivacky * a set of library routines that will access the indicated name service.
117202375Srdivacky */
118202375Srdivackyenum nstype {
119202375Srdivacky	UNKNOWN = 0,
120202375Srdivacky	NIS = 1,	/* Nis Plus Service		*/
121202375Srdivacky	SUNYP = 2,	/* Old NIS Service		*/
122202375Srdivacky	IVY = 3,	/* Nis Plus Plus Service	*/
123202375Srdivacky	DNS = 4,	/* Domain Name Service		*/
124202375Srdivacky	X500 = 5,	/* ISO/CCCIT X.500 Service	*/
125202375Srdivacky	DNANS = 6,	/* Digital DECNet Name Service	*/
126202375Srdivacky	XCHS = 7,	/* Xerox ClearingHouse Service	*/
127202375Srdivacky	CDS= 8
128202375Srdivacky};
129202375Srdivacky
130202375Srdivacky/*
131202375Srdivacky * DIRECTORY - The name service object. These objects identify other name
132202375Srdivacky * servers that are serving some portion of the name space. Each has a
133202375Srdivacky * type associated with it. The resolver library will note whether or not
134202375Srdivacky * is has the needed routines to access that type of service.
135202375Srdivacky * The oarmask structure defines an access rights mask on a per object
136202375Srdivacky * type basis for the name spaces. The only bits currently used are
137202375Srdivacky * create and destroy. By enabling or disabling these access rights for
138202375Srdivacky * a specific object type for a one of the accessor entities (owner,
139202375Srdivacky * group, world) the administrator can control what types of objects
140202375Srdivacky * may be freely added to the name space and which require the
141202375Srdivacky * administrator's approval.
142202375Srdivacky */
143202375Srdivackystruct oar_mask {
144202375Srdivacky	u_long	oa_rights;	/* Access rights mask 	*/
145202375Srdivacky	zotypes	oa_otype;	/* Object type 		*/
146202375Srdivacky};
147202375Srdivacky
148202375Srdivackystruct endpoint {
149202375Srdivacky	string		uaddr<>;
150202375Srdivacky	string		family<>;   /* Transport family (INET, OSI, etc) */
151202375Srdivacky	string		proto<>;    /* Protocol (TCP, UDP, CLNP,  etc)   */
152202375Srdivacky};
153202375Srdivacky
154202375Srdivacky/*
155202375Srdivacky * Note: pkey is a netobj which is limited to 1024 bytes which limits the
156202375Srdivacky * keysize to 8192 bits. This is consider to be a reasonable limit for
157202375Srdivacky * the expected lifetime of this service.
158202375Srdivacky */
159202375Srdivackystruct nis_server {
160202375Srdivacky	nis_name	name; 	 	/* Principal name of the server  */
161202375Srdivacky	endpoint	ep<>;  		/* Universal addr(s) for server  */
162202375Srdivacky	u_long		key_type;	/* Public key type		 */
163202375Srdivacky	netobj		pkey;		/* server's public key  	 */
164202375Srdivacky};
165202375Srdivacky
166202375Srdivackystruct directory_obj {
167202375Srdivacky	nis_name   do_name;	 /* Name of the directory being served   */
168202375Srdivacky	nstype	   do_type;	 /* one of NIS, DNS, IVY, YP, or X.500 	 */
169202375Srdivacky	nis_server do_servers<>; /* <0> == Primary name server     	 */
170202375Srdivacky	u_long	   do_ttl;	 /* Time To Live (for caches) 		 */
171202375Srdivacky	oar_mask   do_armask<>;  /* Create/Destroy rights by object type */
172202375Srdivacky};
173202375Srdivacky
174202375Srdivacky/*
175202375Srdivacky * ENTRY - This is one row of data from an information base.
176202375Srdivacky * The type value is used by the client library to convert the entry to
177202375Srdivacky * it's internal structure representation. The Table name is a back pointer
178202375Srdivacky * to the table where the entry is stored. This allows the client library
179202375Srdivacky * to determine where to send a request if the client wishes to change this
180202375Srdivacky * entry but got to it through a LINK rather than directly.
181202375Srdivacky * If the entry is a "standalone" entry then this field is void.
182202375Srdivacky */
183202375Srdivackyconst EN_BINARY   = 1;	/* Indicates value is binary data 	*/
184202375Srdivackyconst EN_CRYPT    = 2;	/* Indicates the value is encrypted	*/
185202375Srdivackyconst EN_XDR      = 4;	/* Indicates the value is XDR encoded	*/
186202375Srdivackyconst EN_MODIFIED = 8;	/* Indicates entry is modified. 	*/
187202375Srdivackyconst EN_ASN1     = 64;	/* Means contents use ASN.1 encoding    */
188202375Srdivacky
189202375Srdivackystruct entry_col {
190202375Srdivacky	u_long	ec_flags;	/* Flags for this value */
191202375Srdivacky	opaque	ec_value<>;	/* It's textual value	*/
192202375Srdivacky};
193202375Srdivacky
194202375Srdivackystruct entry_obj {
195202375Srdivacky	string 	en_type<>;	/* Type of entry such as "passwd" */
196202375Srdivacky	entry_col en_cols<>;	/* Value for the entry		  */
197202375Srdivacky};
198202375Srdivacky
199202375Srdivacky/*
200202375Srdivacky * GROUP - The group object contains a list of NIS principal names. Groups
201202375Srdivacky * are used to authorize principals. Each object has a set of access rights
202202375Srdivacky * for members of its group. Principal names in groups are in the form
203202375Srdivacky * name.directory and recursive groups are expressed as @groupname.directory
204202375Srdivacky */
205202375Srdivackystruct group_obj {
206202375Srdivacky	u_long		gr_flags;	/* Flags controlling group	*/
207202375Srdivacky	nis_name	gr_members<>;  	/* List of names in group 	*/
208202375Srdivacky};
209202375Srdivacky
210202375Srdivacky/*
211202375Srdivacky * LINK - This is the LINK object. It is quite similar to a symbolic link
212202375Srdivacky * in the UNIX filesystem. The attributes in the main object structure are
213202375Srdivacky * relative to the LINK data and not what it points to (like the file system)
214202375Srdivacky * "modify" privleges here indicate the right to modify what the link points
215202375Srdivacky * at and not to modify that actual object pointed to by the link.
216202375Srdivacky */
217202375Srdivackystruct link_obj {
218202375Srdivacky	zotypes	 li_rtype;	/* Real type of the object	*/
219202375Srdivacky	nis_attr li_attrs<>;	/* Attribute/Values for tables	*/
220202375Srdivacky	nis_name li_name; 	/* The object's real NIS name	*/
221202375Srdivacky};
222202375Srdivacky
223202375Srdivacky/*
224202375Srdivacky * TABLE - This is the table object. It implements a simple
225202375Srdivacky * data base that applications and use for configuration or
226202375Srdivacky * administration purposes. The role of the table is to group together
227202375Srdivacky * a set of related entries. Tables are the simple database component
228202375Srdivacky * of NIS. Like many databases, tables are logically divided into columns
229202375Srdivacky * and rows. The columns are labeled with indexes and each ENTRY makes
230202375Srdivacky * up a row. Rows may be addressed within the table by selecting one
231202375Srdivacky * or more indexes, and values for those indexes. Each row which has
232202375Srdivacky * a value for the given index that matches the desired value is returned.
233202375Srdivacky * Within the definition of each column there is a flags variable, this
234202375Srdivacky * variable contains flags which determine whether or not the column is
235202375Srdivacky * searchable, contains binary data, and access rights for the entry objects
236202375Srdivacky * column value.
237202375Srdivacky */
238202375Srdivacky
239202375Srdivackyconst TA_BINARY     = 1;	/* Means table data is binary 		*/
240202375Srdivackyconst TA_CRYPT      = 2;	/* Means value should be encrypted 	*/
241202375Srdivackyconst TA_XDR        = 4;	/* Means value is XDR encoded		*/
242202375Srdivackyconst TA_SEARCHABLE = 8;	/* Means this column is searchable	*/
243202375Srdivackyconst TA_CASE       = 16;	/* Means this column is Case Sensitive	*/
244202375Srdivackyconst TA_MODIFIED   = 32;	/* Means this columns attrs are modified*/
245202375Srdivackyconst TA_ASN1       = 64;	/* Means contents use ASN.1 encoding     */
246202375Srdivacky
247202375Srdivackystruct table_col {
248202375Srdivacky	string	tc_name<64>;	/* Column Name 	 	   */
249202375Srdivacky	u_long	tc_flags;	/* control flags	   */
250202375Srdivacky	u_long	tc_rights;	/* Access rights mask	   */
251202375Srdivacky};
252202375Srdivacky
253202375Srdivackystruct table_obj {
254202375Srdivacky	string 	  ta_type<64>;	 /* Table type such as "passwd"	*/
255202375Srdivacky	int	  ta_maxcol;	 /* Total number of columns	*/
256202375Srdivacky	u_char	  ta_sep;	 /* Separator character 	*/
257202375Srdivacky	table_col ta_cols<>; 	 /* The number of table indexes */
258202375Srdivacky	string	  ta_path<>;	 /* A search path for this table */
259202375Srdivacky};
260202375Srdivacky
261202375Srdivacky/*
262202375Srdivacky * This union joins together all of the currently known objects.
263202375Srdivacky */
264202375Srdivackyunion objdata switch (zotypes zo_type) {
265202375Srdivacky        case DIRECTORY_OBJ :
266202375Srdivacky                struct directory_obj di_data;
267202375Srdivacky        case GROUP_OBJ :
268202375Srdivacky                struct group_obj gr_data;
269202375Srdivacky        case TABLE_OBJ :
270202375Srdivacky                struct table_obj ta_data;
271202375Srdivacky        case ENTRY_OBJ:
272202375Srdivacky                struct entry_obj en_data;
273202375Srdivacky        case LINK_OBJ :
274202375Srdivacky                struct link_obj li_data;
275202375Srdivacky        case PRIVATE_OBJ :
276202375Srdivacky                opaque	po_data<>;
277202375Srdivacky	case NO_OBJ :
278202375Srdivacky		void;
279202375Srdivacky        case BOGUS_OBJ :
280202375Srdivacky		void;
281202375Srdivacky        default :
282202375Srdivacky                void;
283202375Srdivacky};
284202375Srdivacky
285202375Srdivacky/*
286202375Srdivacky * This is the basic NIS object data type. It consists of a generic part
287202375Srdivacky * which all objects contain, and a specialized part which varies depending
288202375Srdivacky * on the type of the object. All of the specialized sections have been
289202375Srdivacky * described above. You might have wondered why they all start with an
290202375Srdivacky * integer size, followed by the useful data. The answer is, when the
291202375Srdivacky * server doesn't recognize the type returned it treats it as opaque data.
292202375Srdivacky * And the definition for opaque data is {int size; char *data;}. In this
293202375Srdivacky * way, servers and utility routines that do not understand a given type
294202375Srdivacky * may still pass it around. One has to be careful in setting
295202375Srdivacky * this variable accurately, it must take into account such things as
296202375Srdivacky * XDR padding of structures etc. The best way to set it is to note one's
297202375Srdivacky * position in the XDR encoding stream, encode the structure, look at the
298202375Srdivacky * new position and calculate the size.
299202375Srdivacky */
300202375Srdivackystruct nis_oid {
301202375Srdivacky	u_long	ctime;		/* Time of objects creation 	*/
302202375Srdivacky	u_long	mtime;		/* Time of objects modification */
303202375Srdivacky};
304202375Srdivacky
305202375Srdivackystruct nis_object {
306202375Srdivacky	nis_oid	 zo_oid;	/* object identity verifier.		*/
307202375Srdivacky	nis_name zo_name;	/* The NIS name for this object		*/
308202375Srdivacky	nis_name zo_owner;	/* NIS name of object owner.		*/
309202375Srdivacky	nis_name zo_group;	/* NIS name of access group.		*/
310202375Srdivacky	nis_name zo_domain;	/* The administrator for the object	*/
311202375Srdivacky	u_long	 zo_access;	/* Access rights (owner, group, world)	*/
312202375Srdivacky	u_long	 zo_ttl;	/* Object's time to live in seconds.	*/
313202375Srdivacky	objdata	 zo_data;	/* Data structure for this type 	*/
314202375Srdivacky};
315202375Srdivacky#if RPC_HDR
316202375Srdivacky%
317202375Srdivacky%#endif /* if __nis_object_h */
318202375Srdivacky%
319202375Srdivacky#endif
320202375Srdivacky