cb_acl.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. # include <config.h>
  11. #endif
  12. #include "cb.h"
  13. /*
  14. ** generic function to send back results
  15. ** Turn off acl eval on front-end when needed
  16. */
  17. void cb_set_acl_policy(Slapi_PBlock *pb) {
  18. Slapi_Backend *be;
  19. cb_backend_instance *cb;
  20. int noacl;
  21. slapi_pblock_get( pb, SLAPI_BACKEND, &be );
  22. cb = cb_get_instance(be);
  23. /* disable acl checking if the local_acl flag is not set
  24. or if the associated backend is disabled */
  25. noacl=!(cb->local_acl) || cb->associated_be_is_disabled;
  26. if (noacl) {
  27. slapi_pblock_set(pb, SLAPI_PLUGIN_DB_NO_ACL, &noacl);
  28. } else {
  29. /* Be very conservative about acl evaluation */
  30. slapi_pblock_set(pb, SLAPI_PLUGIN_DB_NO_ACL, &noacl);
  31. }
  32. }
  33. int cb_access_allowed(
  34. Slapi_PBlock *pb,
  35. Slapi_Entry *e, /* The Slapi_Entry */
  36. char *attr, /* Attribute of the entry */
  37. struct berval *val, /* value of attr. NOT USED */
  38. int access, /* access rights */
  39. char **errbuf
  40. )
  41. {
  42. switch (access) {
  43. case SLAPI_ACL_ADD:
  44. case SLAPI_ACL_DELETE:
  45. case SLAPI_ACL_COMPARE:
  46. case SLAPI_ACL_WRITE:
  47. case SLAPI_ACL_PROXY:
  48. /* Keep in mind some entries are NOT */
  49. /* available for acl evaluation */
  50. return slapi_access_allowed(pb,e,attr,val,access);
  51. default:
  52. return LDAP_INSUFFICIENT_ACCESS;
  53. }
  54. }