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