las.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. #ifndef ACL_LAS_HEADER
  39. #define ACL_LAS_HEADER
  40. #ifndef NOINTNSACL
  41. #define INTNSACL
  42. #endif /* !NOINTNSACL */
  43. /* #include <prhash.h> */
  44. #include <plhash.h>
  45. #include <prclist.h>
  46. #include <base/plist.h>
  47. #include <libaccess/nserror.h>
  48. #include <libaccess/acl.h>
  49. #ifndef PUBLIC_NSACL_ACLDEF_H
  50. #include "public/nsacl/acldef.h"
  51. #endif /* !PUBLIC_NSACL_ACLDEF_H */
  52. #define ACL_MAX_METHOD 32
  53. #define ACL_MAX_DBTYPE 32
  54. struct ACLAttrGetter {
  55. PRCList list; /* must be first */
  56. ACLMethod_t method;
  57. ACLDbType_t dbtype;
  58. ACLAttrGetterFn_t fn;
  59. void *arg;
  60. };
  61. NSPR_BEGIN_EXTERN_C
  62. NSAPI_PUBLIC extern int
  63. ACL_LasRegister(NSErr_t *errp, char *attr_name, LASEvalFunc_t
  64. eval_func, LASFlushFunc_t flush_func);
  65. NSAPI_PUBLIC extern int
  66. ACL_LasFindEval(NSErr_t *errp, char *attr_name, LASEvalFunc_t
  67. *eval_funcp);
  68. NSAPI_PUBLIC extern int
  69. ACL_LasFindFlush(NSErr_t *errp, char *attr_name, LASFlushFunc_t
  70. *flush_funcp);
  71. extern void
  72. ACL_LasHashInit(void);
  73. extern void
  74. ACL_LasHashDestroy(void);
  75. /*
  76. * Revised, normalized method/dbtype registration routines
  77. */
  78. NSAPI_PUBLIC extern int
  79. ACL_MethodRegister(NSErr_t *errp, const char *name, ACLMethod_t *t);
  80. NSAPI_PUBLIC extern int
  81. ACL_MethodIsEqual(NSErr_t *errp, const ACLMethod_t t1, const ACLMethod_t t2);
  82. NSAPI_PUBLIC extern int
  83. ACL_MethodNameIsEqual(NSErr_t *errp, const ACLMethod_t t, const char *name);
  84. NSAPI_PUBLIC extern int
  85. ACL_MethodFind(NSErr_t *errp, const char *name, ACLMethod_t *t);
  86. NSAPI_PUBLIC extern ACLMethod_t
  87. ACL_MethodGetDefault(NSErr_t *errp);
  88. NSAPI_PUBLIC extern int
  89. ACL_MethodSetDefault(NSErr_t *errp, const ACLMethod_t t);
  90. NSAPI_PUBLIC extern int
  91. ACL_AuthInfoGetMethod(NSErr_t *errp, PList_t auth_info, ACLMethod_t *t);
  92. NSAPI_PUBLIC extern int
  93. ACL_AuthInfoSetMethod(NSErr_t *errp, PList_t auth_info, ACLMethod_t t);
  94. NSAPI_PUBLIC extern int
  95. ACL_DbTypeRegister(NSErr_t *errp, const char *name, DbParseFn_t func, ACLDbType_t *t);
  96. NSAPI_PUBLIC extern int
  97. ACL_DbTypeIsEqual(NSErr_t *errp, const ACLDbType_t t1, const ACLDbType_t t2);
  98. NSAPI_PUBLIC extern int
  99. ACL_DbTypeNameIsEqual(NSErr_t *errp, const ACLDbType_t t, const char *name);
  100. NSAPI_PUBLIC extern int
  101. ACL_DbTypeFind(NSErr_t *errp, const char *name, ACLDbType_t *t);
  102. NSAPI_PUBLIC extern ACLDbType_t
  103. ACL_DbTypeGetDefault(NSErr_t *errp);
  104. NSAPI_PUBLIC extern const char *
  105. ACL_DatabaseGetDefault(NSErr_t *errp);
  106. NSAPI_PUBLIC extern int
  107. ACL_DatabaseSetDefault(NSErr_t *errp, const char *dbname);
  108. NSAPI_PUBLIC extern int
  109. ACL_AuthInfoGetDbType(NSErr_t *errp, PList_t auth_info, ACLDbType_t *t);
  110. NSAPI_PUBLIC extern int
  111. ACL_DbTypeIsRegistered(NSErr_t *errp, const ACLDbType_t dbtype);
  112. NSAPI_PUBLIC extern int
  113. ACL_AttrGetterRegister(NSErr_t *errp, const char *attr,
  114. ACLAttrGetterFn_t fn, ACLMethod_t m,
  115. ACLDbType_t d, int position, void *arg);
  116. extern ACLDbType_t ACL_DbTypeLdap;
  117. NSAPI_PUBLIC extern int
  118. ACL_DbTypeSetDefault(NSErr_t *errp, ACLDbType_t t);
  119. NSAPI_PUBLIC extern DbParseFn_t
  120. ACL_DbTypeParseFn(NSErr_t *errp, const ACLDbType_t dbtype);
  121. NSAPI_PUBLIC extern int
  122. ACL_AttrGetterFind(NSErr_t *errp, const char *attr,
  123. ACLAttrGetterList_t *getters);
  124. NSAPI_PUBLIC extern ACLAttrGetter_t *
  125. ACL_AttrGetterFirst(ACLAttrGetterList_t *getters);
  126. NSAPI_PUBLIC extern ACLAttrGetter_t *
  127. ACL_AttrGetterNext(ACLAttrGetterList_t *getters,
  128. ACLAttrGetter_t *last);
  129. /* typedef PRHashTable AttrGetterTable_t; */
  130. typedef PLHashTable AttrGetterTable_t;
  131. typedef struct {
  132. char *method;
  133. char *authtype;
  134. char *dbtype;
  135. AttrGetterTable_t *attrGetters;
  136. } MethodInfo_t;
  137. NSAPI_PUBLIC int ACL_ModuleRegister (NSErr_t *errp, const char *moduleName, AclModuleInitFunc func);
  138. 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);
  139. NSAPI_PUBLIC int ACL_DatabaseRegister(NSErr_t *errp, ACLDbType_t dbtype, const char *dbname, const char *url, PList_t plist);
  140. NSAPI_PUBLIC int ACL_RegisterDbFromACL(NSErr_t *errp, const char *url, ACLDbType_t *dbtype);
  141. NSAPI_PUBLIC int ACL_DatabaseFind(NSErr_t *errp, const char *dbname,
  142. ACLDbType_t *dbtype, void **db);
  143. NSAPI_PUBLIC int ACL_LDAPDatabaseHandle (NSErr_t *errp,
  144. const char *dbname, LDAP **ld,
  145. char **basedn);
  146. NSAPI_PUBLIC int ACL_AuthInfoGetDbname (PList_t auth_info, char **dbname);
  147. NSAPI_PUBLIC int ACL_AuthInfoSetDbname (NSErr_t *errp, PList_t auth_info,
  148. const char *dbname);
  149. NSAPI_PUBLIC int ACL_CacheFlushRegister(AclCacheFlushFunc_t func);
  150. NSAPI_PUBLIC int ACL_SetDefaultResult (NSErr_t *errp,
  151. ACLEvalHandle_t *acleval,
  152. int result);
  153. NSAPI_PUBLIC int ACL_GetDefaultResult (ACLEvalHandle_t *acleval);
  154. struct program_groups {
  155. char *type;
  156. char **groups;
  157. char **programs;
  158. };
  159. extern int LASTimeOfDayEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
  160. char *pattern, ACLCachable_t *cachable, void **las_cookie,
  161. PList_t subject, PList_t resource, PList_t auth_info,
  162. PList_t global_auth);
  163. extern int LASDayOfWeekEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
  164. char *pattern, ACLCachable_t *cachable, void **las_cookie,
  165. PList_t subject, PList_t resource, PList_t auth_info,
  166. PList_t global_auth);
  167. extern int LASIpEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
  168. char *pattern, ACLCachable_t *cachable, void **las_cookie,
  169. PList_t subject, PList_t resource, PList_t auth_info,
  170. PList_t global_auth);
  171. extern int LASDnsEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
  172. char *pattern, ACLCachable_t *cachable, void **las_cookie,
  173. PList_t subject, PList_t resource, PList_t auth_info,
  174. PList_t global_auth);
  175. extern int LASGroupEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
  176. char *pattern, ACLCachable_t *cachable, void **las_cookie,
  177. PList_t subject, PList_t resource, PList_t auth_info,
  178. PList_t global_auth);
  179. extern int LASUserEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
  180. char *pattern, ACLCachable_t *cachable, void **las_cookie,
  181. PList_t subject, PList_t resource, PList_t auth_info,
  182. PList_t global_auth);
  183. extern int LASProgramEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
  184. char *pattern, ACLCachable_t *cachable, void **las_cookie,
  185. PList_t subject, PList_t resource, PList_t auth_info,
  186. PList_t global_auth);
  187. extern void LASTimeOfDayFlush(void **cookie);
  188. extern void LASDayOfWeekFlush(void **cookie);
  189. extern void LASIpFlush(void **cookie);
  190. extern void LASDnsFlush(void **cookie);
  191. NSPR_END_EXTERN_C
  192. #endif /* ACL_LAS_HEADER */