nis_object.x 11 KB

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