nislib.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. /* Copyright (C) 1997, 1998, 1999, 2006, 2007, 2009
  2. Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. #ifndef __RPCSVC_NISLIB_H__
  18. #define __RPCSVC_NISLIB_H__
  19. #include <features.h>
  20. __BEGIN_DECLS
  21. typedef const char *const_nis_name;
  22. /* nis_names: These functions are used to locate and manipulate all NIS+
  23. * objects except the NIS+ entry objects.
  24. *
  25. * nis_lookup (name, flags) resolves a NIS+ name and returns a copy of
  26. * that object from a NIS+ server.
  27. * const nis_name name: name of the object to be resolved
  28. * unsigned int flags: logically ORing zero or more flags (FOLLOW_LINKS,
  29. * HARD_LOOKUP, [NO_CACHE], MASTER_ONLY, EXPAND_NAME)
  30. *
  31. * nis_add (name, obj) adds objects to the NIS+ namespace.
  32. * const nis_name name: fully qualified NIS+ name.
  33. * const nis_object *obj: object members zo_name and zo_domain will be
  34. * constructed from name.
  35. *
  36. * nis_remove (name, obj) removes objects from the NIS+ namespace.
  37. * const nis_name name: fully qualified NIS+ name.
  38. * const nis_object *obj: if not NULL, it is assumed to point to a copy
  39. * of the object being removed. In this case, if
  40. * the object on the server does not have the same
  41. * object identifier as the object being passed,
  42. * the operation will fail with the NIS_NOTSAMEOBJ
  43. * error.
  44. *
  45. * nis_modify (name, obj) can change specific attributes of an object
  46. * that already exists in the namespace.
  47. */
  48. extern nis_result *nis_lookup (const_nis_name name, unsigned int flags)
  49. __THROW;
  50. extern nis_result *nis_add (const_nis_name name, const nis_object *obj)
  51. __THROW;
  52. extern nis_result *nis_remove (const_nis_name name,
  53. const nis_object *obj) __THROW;
  54. extern nis_result *nis_modify (const_nis_name name,
  55. const nis_object *obj) __THROW;
  56. /* nis_tables: These functions are used to search and modify NIS+ tables.
  57. *
  58. * nis_list (table_name, flags, callback(table_name, obj, userdata), userdata)
  59. * search a table in the NIS+ namespace.
  60. * const nis_name table_name: indexed name ([xx=yy],table.dir)
  61. * unsigned int flags: logically ORing one or more flags (FOLLOW_LINKS,
  62. * [FOLLOW_PATH], HARD_LOOKUP, [ALL_RESULTS], [NO_CACHE],
  63. * MASTER_ONLY, EXPAND_NAME, RETURN_RESULT)
  64. * callback(): callback is an optional pointer to a function that will
  65. * process the ENTRY type objects that are returned from the
  66. * search. If this pointer is NULL, then all entries that match
  67. * the search criteria are returned in the nis_result structure,
  68. * otherwise this function will be called once for each
  69. * entry returned.
  70. * void *userdata: passed to callback function along with the returned
  71. * entry object.
  72. *
  73. * nis_add_entry (table_name, obj, flags) will add the NIS+ object to the
  74. * NIS+ table_name.
  75. * const nis_name table_name
  76. * const nis_object *obj
  77. * unsigned int flags: 0, ADD_OVERWRITE, RETURN_RESULT
  78. *
  79. * nis_modify_entry (name, obj, flags) modifies an object identified by name.
  80. * const nis_name name: object identifier
  81. * const nis_object *obj: should point to an entry with the EN_MODIFIED
  82. * flag set in each column that contains new
  83. * information.
  84. * unsigned int flags: 0, MOD_SAMEOBJ, RETURN_RESULT
  85. *
  86. * nis_remove_entry (table_name, obj, flags) removes a set of entries
  87. * identified by table_name from the table.
  88. * const nis_name table_name: indexed NIS+ name
  89. * const nis_object *obj: if obj is non-null, it is presumed to point to
  90. * a cached copy of the entry. When the removal is
  91. * attempted, and the object that would be removed
  92. * is not the same as the cached object pointed to
  93. * by object then the operation will fail with an
  94. * NIS_NOTSAMEOBJ error
  95. * unsigned int flags: 0, REM_MULTIPLE
  96. *
  97. * nis_first_entry (table_name) fetches entries from a table one at a time.
  98. * const nis_name table_name
  99. *
  100. * nis_next_entry (table_name, cookie) retrieves the "next" entry from a
  101. * table specified by table_name.
  102. * const nis_name table_name:
  103. * const netobj *cookie: The value of cookie from the nis_result structure
  104. * form the previous call.
  105. */
  106. extern nis_result *nis_list (const_nis_name __name, unsigned int __flags,
  107. int (*__callback)(const_nis_name __table_name,
  108. const nis_object *__obj,
  109. const void *__userdata),
  110. const void *__userdata) __THROW;
  111. extern nis_result *nis_add_entry (const_nis_name __table_name,
  112. const nis_object *__obj,
  113. unsigned int __flags) __THROW;
  114. extern nis_result *nis_modify_entry (const_nis_name __name,
  115. const nis_object *__obj,
  116. unsigned int __flags) __THROW;
  117. extern nis_result *nis_remove_entry (const_nis_name __table_name,
  118. const nis_object *__obj,
  119. unsigned int __flags) __THROW;
  120. extern nis_result *nis_first_entry (const_nis_name __table_name) __THROW;
  121. extern nis_result *nis_next_entry (const_nis_name __table_name,
  122. const netobj *__cookie) __THROW;
  123. /*
  124. ** nis_server
  125. */
  126. extern nis_error nis_mkdir (const_nis_name __dirname,
  127. const nis_server *__machine) __THROW;
  128. extern nis_error nis_rmdir (const_nis_name __dirname,
  129. const nis_server *__machine) __THROW;
  130. extern nis_error nis_servstate (const nis_server *__machine,
  131. const nis_tag *__tags, int __numtags,
  132. nis_tag **__result) __THROW;
  133. extern nis_error nis_stats (const nis_server *__machine,
  134. const nis_tag *__tags, int __numtags,
  135. nis_tag **__result) __THROW;
  136. extern void nis_freetags (nis_tag *__tags, int __numtags) __THROW;
  137. extern nis_server **nis_getservlist (const_nis_name __dirname) __THROW;
  138. extern void nis_freeservlist (nis_server **__machines) __THROW;
  139. /*
  140. ** nis_subr
  141. */
  142. extern nis_name nis_leaf_of (const_nis_name __name) __THROW;
  143. extern nis_name nis_leaf_of_r (const_nis_name __name, char *__buffer,
  144. size_t __buflen) __THROW;
  145. extern nis_name nis_name_of (const_nis_name __name) __THROW;
  146. extern nis_name nis_name_of_r (const_nis_name __name, char *__buffer,
  147. size_t __buflen) __THROW;
  148. extern nis_name nis_domain_of (const_nis_name __name) __THROW;
  149. extern nis_name nis_domain_of_r (const_nis_name __name, char *__buffer,
  150. size_t __buflen) __THROW;
  151. extern nis_name *nis_getnames (const_nis_name __name) __THROW;
  152. extern void nis_freenames (nis_name *__namelist) __THROW;
  153. extern name_pos nis_dir_cmp (const_nis_name __n1, const_nis_name __n2) __THROW;
  154. extern nis_object *nis_clone_object (const nis_object *__src,
  155. nis_object *__dest) __THROW;
  156. extern void nis_destroy_object (nis_object *__obj) __THROW;
  157. extern void nis_print_object (const nis_object *__obj) __THROW;
  158. /*
  159. ** nis_local_names
  160. */
  161. extern nis_name nis_local_group (void) __THROW;
  162. extern nis_name nis_local_directory (void) __THROW;
  163. extern nis_name nis_local_principal (void) __THROW;
  164. extern nis_name nis_local_host (void) __THROW;
  165. /*
  166. ** nis_error
  167. */
  168. extern const char *nis_sperrno (const nis_error __status) __THROW;
  169. extern void nis_perror (const nis_error __status, const char *__label) __THROW;
  170. extern void nis_lerror (const nis_error __status, const char *__label) __THROW;
  171. extern char *nis_sperror (const nis_error status, const char *__label) __THROW;
  172. extern char *nis_sperror_r (const nis_error __status, const char *__label,
  173. char *__buffer, size_t __buflen) __THROW;
  174. /*
  175. ** nis_groups
  176. */
  177. extern bool_t nis_ismember (const_nis_name __principal,
  178. const_nis_name __group) __THROW;
  179. extern nis_error nis_addmember (const_nis_name __member,
  180. const_nis_name __group) __THROW;
  181. extern nis_error nis_removemember (const_nis_name __member,
  182. const_nis_name __group) __THROW;
  183. extern nis_error nis_creategroup (const_nis_name __group,
  184. unsigned int __flags) __THROW;
  185. extern nis_error nis_destroygroup (const_nis_name __group) __THROW;
  186. extern void nis_print_group_entry (const_nis_name __group) __THROW;
  187. extern nis_error nis_verifygroup (const_nis_name __group) __THROW;
  188. /*
  189. ** nis_ping
  190. */
  191. extern void nis_ping (const_nis_name __dirname, uint32_t __utime,
  192. const nis_object *__dirobj) __THROW;
  193. extern nis_result *nis_checkpoint (const_nis_name __dirname) __THROW;
  194. /*
  195. ** nis_print (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!)
  196. */
  197. extern void nis_print_result (const nis_result *__result) __THROW;
  198. extern void nis_print_rights (unsigned int __rights) __THROW;
  199. extern void nis_print_directory (const directory_obj *__dirobj) __THROW;
  200. extern void nis_print_group (const group_obj *__grpobj) __THROW;
  201. extern void nis_print_table (const table_obj *__tblobj) __THROW;
  202. extern void nis_print_link (const link_obj *__lnkobj) __THROW;
  203. extern void nis_print_entry (const entry_obj *__enobj) __THROW;
  204. /*
  205. ** nis_file (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!)
  206. */
  207. extern directory_obj *readColdStartFile (void) __THROW;
  208. extern bool_t writeColdStartFile (const directory_obj *__dirobj) __THROW;
  209. extern nis_object *nis_read_obj (const char *__obj) __THROW;
  210. extern bool_t nis_write_obj (const char *__file, const nis_object *__obj) __THROW;
  211. /*
  212. ** nis_clone - (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!)
  213. */
  214. extern directory_obj *nis_clone_directory (const directory_obj *__src,
  215. directory_obj *__dest) __THROW;
  216. extern nis_result *nis_clone_result (const nis_result *__src,
  217. nis_result *__dest) __THROW;
  218. /* nis_free - nis_freeresult */
  219. extern void nis_freeresult (nis_result *__result) __THROW;
  220. /* (XXX THE FOLLOWING ARE INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) */
  221. extern void nis_free_request (ib_request *__req) __THROW;
  222. extern void nis_free_directory (directory_obj *__dirobj) __THROW;
  223. extern void nis_free_object (nis_object *__obj) __THROW;
  224. /* (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) */
  225. extern nis_name __nis_default_owner (char *) __THROW;
  226. extern nis_name __nis_default_group (char *) __THROW;
  227. extern uint32_t __nis_default_ttl (char *) __THROW;
  228. extern unsigned int __nis_default_access (char *, unsigned int) __THROW;
  229. extern fd_result *__nis_finddirectory (directory_obj *, const_nis_name) __THROW;
  230. extern void __free_fdresult (fd_result *) __THROW;
  231. extern uint32_t __nis_hash (const void *__keyarg, size_t __len) __THROW;
  232. /* NIS+ cache locking */
  233. extern int __nis_lock_cache (void) __THROW;
  234. extern int __nis_unlock_cache (void) __THROW;
  235. /* (XXX INTERNAL FUNCTIONS, ONLY FOR rpc.nisd AND glibc !!) */
  236. #if defined (NIS_INTERNAL) || defined (_LIBC)
  237. struct dir_binding
  238. {
  239. CLIENT *clnt; /* RPC CLIENT handle */
  240. nis_server *server_val; /* List of servers */
  241. unsigned int server_len; /* # of servers */
  242. unsigned int server_used; /* Which server we are bind in the moment ? */
  243. unsigned int current_ep; /* Which endpoint of the server are in use? */
  244. unsigned int trys; /* How many server have we tried ? */
  245. unsigned int class; /* From which class is server_val ? */
  246. bool_t master_only; /* Is only binded to the master */
  247. bool_t use_auth; /* Do we use AUTH ? */
  248. bool_t use_udp; /* Do we use UDP ? */
  249. struct sockaddr_in addr; /* Server's IP address */
  250. int socket; /* Server's local socket */
  251. };
  252. typedef struct dir_binding dir_binding;
  253. extern nis_error __nisbind_create (dir_binding *, const nis_server *,
  254. unsigned int, unsigned int, unsigned int,
  255. unsigned int) __THROW;
  256. extern nis_error __nisbind_connect (dir_binding *) __THROW;
  257. extern nis_error __nisbind_next (dir_binding *) __THROW;
  258. extern void __nisbind_destroy (dir_binding *) __THROW;
  259. extern nis_error __nisfind_server (const_nis_name, int, directory_obj **,
  260. dir_binding *, unsigned int) __THROW;
  261. #endif
  262. __END_DECLS
  263. #endif /* __RPCSVC_NISLIB_H__ */