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