Dr Andrew Scott G7VAV

My photo
 
June 2025
Mo Tu We Th Fr Sa Su
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 1 2 3 4 5 6


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


for client (none)
© Andrew Scott 2006 - 2025,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/