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