1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * nis_object.x 24 * 25 * Copyright (c) 1988-1992 Sun Microsystems Inc 26 * All Rights Reserved. 27 */ 28 29 %#pragma ident "%Z%%M% %I% %E% SMI" 30 31 #if RPC_HDR 32 % 33 %#ifndef __nis_object_h 34 %#define __nis_object_h 35 % 36 #endif 37 /* 38 * This file defines the format for a NIS object in RPC language. 39 * It is included by the main .x file and the database access protocol 40 * file. It is common because both of them need to deal with the same 41 * type of object. Generating the actual code though is a bit messy because 42 * the nis.x file and the nis_dba.x file will generate xdr routines to 43 * encode/decode objects when only one set is needed. Such is life when 44 * one is using rpcgen. 45 * 46 * Note, the protocol doesn't specify any limits on such things as 47 * maximum name length, number of attributes, etc. These are enforced 48 * by the database backend. When you hit them you will no. Also see 49 * the db_getlimits() function for fetching the limit values. 50 * 51 */ 52 53 #if defined(RPC_XDR) || defined(RPC_SVC) || defined(RPC_CLNT) 54 %#ifndef xdr_uint32_t 55 %#define xdr_uint32_t xdr_u_int 56 %#endif 57 %#ifndef xdr_uint_t 58 %#define xdr_uint_t xdr_u_int 59 %#endif 60 #endif 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 const NIS_PK_DHEXT = 4; /* Extended Diffie-Hellman for RPC-GSS */ 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 * EOL Alert - The non-prefixed names are present for backward 101 * compatability only, and will not exist in future releases. Use 102 * the NIS_* names for future compatability. 103 */ 104 105 enum zotypes { 106 107 BOGUS_OBJ = 0, /* Uninitialized object structure */ 108 NO_OBJ = 1, /* NULL object (no data) */ 109 DIRECTORY_OBJ = 2, /* Directory object describing domain */ 110 GROUP_OBJ = 3, /* Group object (a list of names) */ 111 TABLE_OBJ = 4, /* Table object (a database schema) */ 112 ENTRY_OBJ = 5, /* Entry object (a database record) */ 113 LINK_OBJ = 6, /* A name link. */ 114 PRIVATE_OBJ = 7, /* Private object (all opaque data) */ 115 116 NIS_BOGUS_OBJ = 0, /* Uninitialized object structure */ 117 NIS_NO_OBJ = 1, /* NULL object (no data) */ 118 NIS_DIRECTORY_OBJ = 2, /* Directory object describing domain */ 119 NIS_GROUP_OBJ = 3, /* Group object (a list of names) */ 120 NIS_TABLE_OBJ = 4, /* Table object (a database schema) */ 121 NIS_ENTRY_OBJ = 5, /* Entry object (a database record) */ 122 NIS_LINK_OBJ = 6, /* A name link. */ 123 NIS_PRIVATE_OBJ = 7 /* Private object (all opaque data) */ 124 }; 125 126 /* 127 * The types of Name services NIS knows about. They are enumerated 128 * here. The Binder code will use this type to determine if it has 129 * a set of library routines that will access the indicated name service. 130 */ 131 enum nstype { 132 UNKNOWN = 0, 133 NIS = 1, /* Nis Plus Service */ 134 SUNYP = 2, /* Old NIS Service */ 135 IVY = 3, /* Nis Plus Plus Service */ 136 DNS = 4, /* Domain Name Service */ 137 X500 = 5, /* ISO/CCCIT X.500 Service */ 138 DNANS = 6, /* Digital DECNet Name Service */ 139 XCHS = 7, /* Xerox ClearingHouse Service */ 140 CDS= 8 141 }; 142 143 /* 144 * DIRECTORY - The name service object. These objects identify other name 145 * servers that are serving some portion of the name space. Each has a 146 * type associated with it. The resolver library will note whether or not 147 * is has the needed routines to access that type of service. 148 * The oarmask structure defines an access rights mask on a per object 149 * type basis for the name spaces. The only bits currently used are 150 * create and destroy. By enabling or disabling these access rights for 151 * a specific object type for a one of the accessor entities (owner, 152 * group, world) the administrator can control what types of objects 153 * may be freely added to the name space and which require the 154 * administrator's approval. 155 */ 156 struct oar_mask { 157 uint_t oa_rights; /* Access rights mask */ 158 zotypes oa_otype; /* Object type */ 159 }; 160 161 struct endpoint { 162 string uaddr<>; 163 string family<>; /* Transport family (INET, OSI, etc) */ 164 string proto<>; /* Protocol (TCP, UDP, CLNP, etc) */ 165 }; 166 167 /* 168 * Note: pkey is a netobj which is limited to 1024 bytes which limits the 169 * keysize to 8192 bits. This is consider to be a reasonable limit for 170 * the expected lifetime of this service. 171 */ 172 struct nis_server { 173 nis_name name; /* Principal name of the server */ 174 endpoint ep<>; /* Universal addr(s) for server */ 175 uint_t key_type; /* Public key type */ 176 netobj pkey; /* server's public key */ 177 }; 178 179 struct directory_obj { 180 nis_name do_name; /* Name of the directory being served */ 181 nstype do_type; /* one of NIS, DNS, IVY, YP, or X.500 */ 182 nis_server do_servers<>; /* <0> == Primary name server */ 183 uint32_t do_ttl; /* Time To Live (for caches) */ 184 oar_mask do_armask<>; /* Create/Destroy rights by object type */ 185 }; 186 187 /* 188 * ENTRY - This is one row of data from an information base. 189 * The type value is used by the client library to convert the entry to 190 * it's internal structure representation. The Table name is a back pointer 191 * to the table where the entry is stored. This allows the client library 192 * to determine where to send a request if the client wishes to change this 193 * entry but got to it through a LINK rather than directly. 194 * If the entry is a "standalone" entry then this field is void. 195 */ 196 const EN_BINARY = 1; /* Indicates value is binary data */ 197 const EN_CRYPT = 2; /* Indicates the value is encrypted */ 198 const EN_XDR = 4; /* Indicates the value is XDR encoded */ 199 const EN_MODIFIED = 8; /* Indicates entry is modified. */ 200 const EN_ASN1 = 64; /* Means contents use ASN.1 encoding */ 201 202 struct entry_col { 203 uint_t ec_flags; /* Flags for this value */ 204 opaque ec_value<>; /* It's textual value */ 205 }; 206 207 struct entry_obj { 208 string en_type<>; /* Type of entry such as "passwd" */ 209 entry_col en_cols<>; /* Value for the entry */ 210 }; 211 212 /* 213 * GROUP - The group object contains a list of NIS principal names. Groups 214 * are used to authorize principals. Each object has a set of access rights 215 * for members of its group. Principal names in groups are in the form 216 * name.directory and recursive groups are expressed as @groupname.directory 217 */ 218 struct group_obj { 219 uint_t gr_flags; /* Flags controlling group */ 220 nis_name gr_members<>; /* List of names in group */ 221 }; 222 223 /* 224 * LINK - This is the LINK object. It is quite similar to a symbolic link 225 * in the UNIX filesystem. The attributes in the main object structure are 226 * relative to the LINK data and not what it points to (like the file system) 227 * "modify" privleges here indicate the right to modify what the link points 228 * at and not to modify that actual object pointed to by the link. 229 */ 230 struct link_obj { 231 zotypes li_rtype; /* Real type of the object */ 232 nis_attr li_attrs<>; /* Attribute/Values for tables */ 233 nis_name li_name; /* The object's real NIS name */ 234 }; 235 236 /* 237 * TABLE - This is the table object. It implements a simple 238 * data base that applications and use for configuration or 239 * administration purposes. The role of the table is to group together 240 * a set of related entries. Tables are the simple database component 241 * of NIS. Like many databases, tables are logically divided into columns 242 * and rows. The columns are labeled with indexes and each ENTRY makes 243 * up a row. Rows may be addressed within the table by selecting one 244 * or more indexes, and values for those indexes. Each row which has 245 * a value for the given index that matches the desired value is returned. 246 * Within the definition of each column there is a flags variable, this 247 * variable contains flags which determine whether or not the column is 248 * searchable, contains binary data, and access rights for the entry objects 249 * column value. 250 */ 251 252 const TA_BINARY = 1; /* Means table data is binary */ 253 const TA_CRYPT = 2; /* Means value should be encrypted */ 254 const TA_XDR = 4; /* Means value is XDR encoded */ 255 const TA_SEARCHABLE = 8; /* Means this column is searchable */ 256 const TA_CASE = 16; /* Means this column is Case Sensitive */ 257 const TA_MODIFIED = 32; /* Means this columns attrs are modified*/ 258 const TA_ASN1 = 64; /* Means contents use ASN.1 encoding */ 259 260 struct table_col { 261 string tc_name<64>; /* Column Name */ 262 uint_t tc_flags; /* control flags */ 263 uint_t tc_rights; /* Access rights mask */ 264 }; 265 266 struct table_obj { 267 string ta_type<64>; /* Table type such as "passwd" */ 268 int ta_maxcol; /* Total number of columns */ 269 u_char ta_sep; /* Separator character */ 270 table_col ta_cols<>; /* The number of table indexes */ 271 string ta_path<>; /* A search path for this table */ 272 }; 273 274 /* 275 * This union joins together all of the currently known objects. 276 */ 277 union objdata switch (zotypes zo_type) { 278 case NIS_DIRECTORY_OBJ : 279 struct directory_obj di_data; 280 case NIS_GROUP_OBJ : 281 struct group_obj gr_data; 282 case NIS_TABLE_OBJ : 283 struct table_obj ta_data; 284 case NIS_ENTRY_OBJ: 285 struct entry_obj en_data; 286 case NIS_LINK_OBJ : 287 struct link_obj li_data; 288 case NIS_PRIVATE_OBJ : 289 opaque po_data<>; 290 case NIS_NO_OBJ : 291 void; 292 case NIS_BOGUS_OBJ : 293 void; 294 default : 295 void; 296 }; 297 298 /* 299 * This is the basic NIS object data type. It consists of a generic part 300 * which all objects contain, and a specialized part which varies depending 301 * on the type of the object. All of the specialized sections have been 302 * described above. You might have wondered why they all start with an 303 * integer size, followed by the useful data. The answer is, when the 304 * server doesn't recognize the type returned it treats it as opaque data. 305 * And the definition for opaque data is {int size; char *data;}. In this 306 * way, servers and utility routines that do not understand a given type 307 * may still pass it around. One has to be careful in setting 308 * this variable accurately, it must take into account such things as 309 * XDR padding of structures etc. The best way to set it is to note one's 310 * position in the XDR encoding stream, encode the structure, look at the 311 * new position and calculate the size. 312 */ 313 struct nis_oid { 314 uint32_t ctime; /* Time of objects creation */ 315 uint32_t mtime; /* Time of objects modification */ 316 }; 317 318 struct nis_object { 319 nis_oid zo_oid; /* object identity verifier. */ 320 nis_name zo_name; /* The NIS name for this object */ 321 nis_name zo_owner; /* NIS name of object owner. */ 322 nis_name zo_group; /* NIS name of access group. */ 323 nis_name zo_domain; /* The administrator for the object */ 324 uint_t zo_access; /* Access rights (owner, group, world) */ 325 uint32_t zo_ttl; /* Object's time to live in seconds. */ 326 objdata zo_data; /* Data structure for this type */ 327 }; 328 #if RPC_HDR 329 % 330 %#endif /* if __nis_object_h */ 331 % 332 #endif 333