1
0

repl_monitor.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 <string.h>
  13. #include "repl.h"
  14. #include "slapi-plugin.h"
  15. #ifdef FOR_40_STYLE_CHANGELOG
  16. /* Forward Declartions */
  17. static int repl_monitor_search (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg);
  18. #endif
  19. int
  20. repl_monitor_init()
  21. {
  22. /* The FE DSE *must* be initialised before we get here */
  23. int return_value= LDAP_SUCCESS;
  24. static int initialized = 0;
  25. if (!initialized)
  26. {
  27. #ifdef FOR_40_STYLE_CHANGELOG
  28. /* ONREPL - this is commented until we implement 4.0 style changelog */
  29. slapi_config_register_callback(SLAPI_OPERATION_SEARCH,DSE_FLAG_PREOP,"cn=monitor",LDAP_SCOPE_BASE,"(objectclass=*)",repl_monitor_search,NULL);
  30. #endif
  31. initialized = 1;
  32. }
  33. return return_value;
  34. }
  35. #ifdef FOR_40_STYLE_CHANGELOG
  36. static int
  37. repl_monitor_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg)
  38. {
  39. const char *sdv = get_server_dataversion();
  40. if ( sdv != NULL )
  41. {
  42. int port;
  43. char buf[BUFSIZ];
  44. struct berval val;
  45. struct berval *vals[2];
  46. vals[0] = &val;
  47. vals[1] = NULL;
  48. port= config_get_port();
  49. if(port==0)
  50. {
  51. port= config_get_secureport();
  52. }
  53. buf[0] = (char)0;
  54. /* ONREPL - how do we publish changenumbers now with multiple changelogs?
  55. sprintf( buf, "%s:%lu %s% lu", get_localhost_DNS(), port, sdv, ldapi_get_last_changenumber());
  56. */
  57. val.bv_val = buf;
  58. val.bv_len = strlen( buf );
  59. slapi_entry_attr_replace( e, attr_dataversion, vals );
  60. }
  61. return SLAPI_DSE_CALLBACK_OK;
  62. }
  63. #endif