las.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2005 Red Hat, Inc.
  36. * All rights reserved.
  37. * END COPYRIGHT BLOCK **/
  38. #ifdef HAVE_CONFIG_H
  39. # include <config.h>
  40. #endif
  41. #ifndef ACL_LAS_HEADER
  42. #define ACL_LAS_HEADER
  43. #ifndef NOINTNSACL
  44. #define INTNSACL
  45. #endif /* !NOINTNSACL */
  46. /* #include <prhash.h> */
  47. #include <plhash.h>
  48. #include <prclist.h>
  49. #include <base/plist.h>
  50. #include <libaccess/nserror.h>
  51. #include <libaccess/acl.h>
  52. #ifndef PUBLIC_NSACL_ACLDEF_H
  53. #include "public/nsacl/acldef.h"
  54. #endif /* !PUBLIC_NSACL_ACLDEF_H */
  55. #define ACL_MAX_METHOD 32
  56. #define ACL_MAX_DBTYPE 32
  57. struct ACLAttrGetter {
  58. PRCList list; /* must be first */
  59. ACLMethod_t method;
  60. ACLDbType_t dbtype;
  61. ACLAttrGetterFn_t fn;
  62. void *arg;
  63. };
  64. NSPR_BEGIN_EXTERN_C
  65. NSAPI_PUBLIC extern int
  66. ACL_LasRegister(NSErr_t *errp, char *attr_name, LASEvalFunc_t
  67. eval_func, LASFlushFunc_t flush_func);
  68. NSAPI_PUBLIC extern int
  69. ACL_LasFindEval(NSErr_t *errp, char *attr_name, LASEvalFunc_t
  70. *eval_funcp);
  71. NSAPI_PUBLIC extern int
  72. ACL_LasFindFlush(NSErr_t *errp, char *attr_name, LASFlushFunc_t
  73. *flush_funcp);
  74. extern void
  75. ACL_LasHashInit(void);
  76. extern void
  77. ACL_LasHashDestroy(void);
  78. /*
  79. * Revised, normalized method/dbtype registration routines
  80. */
  81. NSAPI_PUBLIC extern int
  82. ACL_MethodRegister(NSErr_t *errp, const char *name, ACLMethod_t *t);
  83. NSAPI_PUBLIC extern int
  84. ACL_MethodIsEqual(NSErr_t *errp, const ACLMethod_t t1, const ACLMethod_t t2);
  85. NSAPI_PUBLIC extern int
  86. ACL_MethodNameIsEqual(NSErr_t *errp, const ACLMethod_t t, const char *name);
  87. NSAPI_PUBLIC extern int
  88. ACL_MethodFind(NSErr_t *errp, const char *name, ACLMethod_t *t);
  89. NSAPI_PUBLIC extern ACLMethod_t
  90. ACL_MethodGetDefault(NSErr_t *errp);
  91. NSAPI_PUBLIC extern int
  92. ACL_MethodSetDefault(NSErr_t *errp, const ACLMethod_t t);
  93. NSAPI_PUBLIC extern int
  94. ACL_AuthInfoGetMethod(NSErr_t *errp, PList_t auth_info, ACLMethod_t *t);
  95. NSAPI_PUBLIC extern int
  96. ACL_AuthInfoSetMethod(NSErr_t *errp, PList_t auth_info, ACLMethod_t t);
  97. NSAPI_PUBLIC extern int
  98. ACL_DbTypeRegister(NSErr_t *errp, const char *name, DbParseFn_t func, ACLDbType_t *t);
  99. NSAPI_PUBLIC extern int
  100. ACL_DbTypeIsEqual(NSErr_t *errp, const ACLDbType_t t1, const ACLDbType_t t2);
  101. NSAPI_PUBLIC extern int
  102. ACL_DbTypeNameIsEqual(NSErr_t *errp, const ACLDbType_t t, const char *name);
  103. NSAPI_PUBLIC extern int
  104. ACL_DbTypeFind(NSErr_t *errp, const char *name, ACLDbType_t *t);
  105. NSAPI_PUBLIC extern ACLDbType_t
  106. ACL_DbTypeGetDefault(NSErr_t *errp);
  107. NSAPI_PUBLIC extern const char *
  108. ACL_DatabaseGetDefault(NSErr_t *errp);
  109. NSAPI_PUBLIC extern int
  110. ACL_DatabaseSetDefault(NSErr_t *errp, const char *dbname);
  111. NSAPI_PUBLIC extern int
  112. ACL_AuthInfoGetDbType(NSErr_t *errp, PList_t auth_info, ACLDbType_t *t);
  113. NSAPI_PUBLIC extern int
  114. ACL_DbTypeIsRegistered(NSErr_t *errp, const ACLDbType_t dbtype);
  115. NSAPI_PUBLIC extern int
  116. ACL_AttrGetterRegister(NSErr_t *errp, const char *attr,
  117. ACLAttrGetterFn_t fn, ACLMethod_t m,
  118. ACLDbType_t d, int position, void *arg);
  119. extern ACLDbType_t ACL_DbTypeLdap;
  120. NSAPI_PUBLIC extern int
  121. ACL_DbTypeSetDefault(NSErr_t *errp, ACLDbType_t t);
  122. NSAPI_PUBLIC extern DbParseFn_t
  123. ACL_DbTypeParseFn(NSErr_t *errp, const ACLDbType_t dbtype);
  124. NSAPI_PUBLIC extern int
  125. ACL_AttrGetterFind(NSErr_t *errp, const char *attr,
  126. ACLAttrGetterList_t *getters);
  127. NSAPI_PUBLIC extern ACLAttrGetter_t *
  128. ACL_AttrGetterFirst(ACLAttrGetterList_t *getters);
  129. NSAPI_PUBLIC extern ACLAttrGetter_t *
  130. ACL_AttrGetterNext(ACLAttrGetterList_t *getters,
  131. ACLAttrGetter_t *last);
  132. /* typedef PRHashTable AttrGetterTable_t; */
  133. typedef PLHashTable AttrGetterTable_t;
  134. typedef struct {
  135. char *method;
  136. char *authtype;
  137. char *dbtype;
  138. AttrGetterTable_t *attrGetters;
  139. } MethodInfo_t;
  140. NSAPI_PUBLIC int ACL_ModuleRegister (NSErr_t *errp, const char *moduleName, AclModuleInitFunc func);
  141. NSAPI_PUBLIC int ACL_GetAttribute(NSErr_t *errp, const char *attr, void **val, PList_t subject, PList_t resource, PList_t auth_info, PList_t global_auth);
  142. NSAPI_PUBLIC int ACL_DatabaseRegister(NSErr_t *errp, ACLDbType_t dbtype, const char *dbname, const char *url, PList_t plist);
  143. NSAPI_PUBLIC int ACL_RegisterDbFromACL(NSErr_t *errp, const char *url, ACLDbType_t *dbtype);
  144. NSAPI_PUBLIC int ACL_DatabaseFind(NSErr_t *errp, const char *dbname,
  145. ACLDbType_t *dbtype, void **db);
  146. NSAPI_PUBLIC int ACL_LDAPDatabaseHandle (NSErr_t *errp,
  147. const char *dbname, LDAP **ld,
  148. char **basedn);
  149. NSAPI_PUBLIC int ACL_AuthInfoGetDbname (PList_t auth_info, char **dbname);
  150. NSAPI_PUBLIC int ACL_AuthInfoSetDbname (NSErr_t *errp, PList_t auth_info,
  151. const char *dbname);
  152. NSAPI_PUBLIC int ACL_CacheFlushRegister(AclCacheFlushFunc_t func);
  153. NSAPI_PUBLIC int ACL_SetDefaultResult (NSErr_t *errp,
  154. ACLEvalHandle_t *acleval,
  155. int result);
  156. NSAPI_PUBLIC int ACL_GetDefaultResult (ACLEvalHandle_t *acleval);
  157. struct program_groups {
  158. char *type;
  159. char **groups;
  160. char **programs;
  161. };
  162. extern int LASTimeOfDayEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
  163. char *pattern, ACLCachable_t *cachable, void **las_cookie,
  164. PList_t subject, PList_t resource, PList_t auth_info,
  165. PList_t global_auth);
  166. extern int LASDayOfWeekEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
  167. char *pattern, ACLCachable_t *cachable, void **las_cookie,
  168. PList_t subject, PList_t resource, PList_t auth_info,
  169. PList_t global_auth);
  170. extern int LASIpEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
  171. char *pattern, ACLCachable_t *cachable, void **las_cookie,
  172. PList_t subject, PList_t resource, PList_t auth_info,
  173. PList_t global_auth);
  174. extern int LASDnsEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
  175. char *pattern, ACLCachable_t *cachable, void **las_cookie,
  176. PList_t subject, PList_t resource, PList_t auth_info,
  177. PList_t global_auth);
  178. extern int LASGroupEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
  179. char *pattern, ACLCachable_t *cachable, void **las_cookie,
  180. PList_t subject, PList_t resource, PList_t auth_info,
  181. PList_t global_auth);
  182. extern int LASUserEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
  183. char *pattern, ACLCachable_t *cachable, void **las_cookie,
  184. PList_t subject, PList_t resource, PList_t auth_info,
  185. PList_t global_auth);
  186. extern int LASProgramEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
  187. char *pattern, ACLCachable_t *cachable, void **las_cookie,
  188. PList_t subject, PList_t resource, PList_t auth_info,
  189. PList_t global_auth);
  190. extern void LASTimeOfDayFlush(void **cookie);
  191. extern void LASDayOfWeekFlush(void **cookie);
  192. extern void LASIpFlush(void **cookie);
  193. extern void LASDnsFlush(void **cookie);
  194. NSPR_END_EXTERN_C
  195. #endif /* ACL_LAS_HEADER */