repl_monitor.c 1.6 KB

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