110
if (use_txn) { /* no lock if betxn is enabled */
113
if (NULL == referint_mutex) {
114
referint_mutex = PR_NewLock();
116
if (referint_mutex) {
117
PR_Lock(referint_mutex);
124
if (use_txn) { /* no lock if betxn is enabled */
127
if (referint_mutex) {
128
PR_Unlock(referint_mutex);
110
133
referint_postop_init( Slapi_PBlock *pb )
112
Slapi_Entry *plugin_entry = NULL;
113
char *plugin_type = NULL;
114
int delfn = SLAPI_PLUGIN_POST_DELETE_FN;
115
int mdnfn = SLAPI_PLUGIN_POST_MODRDN_FN;
118
* Get plugin identity and stored it for later use
119
* Used for internal operations
122
slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &referint_plugin_identity);
123
PR_ASSERT (referint_plugin_identity);
126
if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &plugin_entry) == 0) &&
128
(plugin_type = slapi_entry_attr_get_charptr(plugin_entry, "nsslapd-plugintype")) &&
129
plugin_type && strstr(plugin_type, "betxn")) {
130
delfn = SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN;
131
mdnfn = SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN;
133
slapi_ch_free_string(&plugin_type);
135
if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION,
136
SLAPI_PLUGIN_VERSION_01 ) != 0 ||
137
slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION,
138
(void *)&pdesc ) != 0 ||
139
slapi_pblock_set( pb, delfn,
140
(void *) referint_postop_del ) != 0 ||
141
slapi_pblock_set( pb, mdnfn,
142
(void *) referint_postop_modrdn ) != 0 ||
143
slapi_pblock_set(pb, SLAPI_PLUGIN_START_FN,
144
(void *) referint_postop_start ) != 0 ||
145
slapi_pblock_set(pb, SLAPI_PLUGIN_CLOSE_FN,
146
(void *) referint_postop_close ) != 0)
148
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
149
"referint_postop_init failed\n" );
135
Slapi_Entry *plugin_entry = NULL;
136
char *plugin_type = NULL;
137
int delfn = SLAPI_PLUGIN_POST_DELETE_FN;
138
int mdnfn = SLAPI_PLUGIN_POST_MODRDN_FN;
141
* Get plugin identity and stored it for later use.
142
* Used for internal operations.
144
slapi_pblock_get (pb, SLAPI_PLUGIN_IDENTITY, &referint_plugin_identity);
145
PR_ASSERT (referint_plugin_identity);
148
if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &plugin_entry) == 0) &&
150
(plugin_type = slapi_entry_attr_get_charptr(plugin_entry, "nsslapd-plugintype")) &&
151
plugin_type && strstr(plugin_type, "betxn"))
153
delfn = SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN;
154
mdnfn = SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN;
158
char *allow_repl_updates;
160
allow_repl_updates = slapi_entry_attr_get_charptr(plugin_entry, "nsslapd-pluginAllowReplUpdates");
161
if(allow_repl_updates && strcasecmp(allow_repl_updates,"on")==0){
164
slapi_ch_free_string(&allow_repl_updates);
166
slapi_ch_free_string(&plugin_type);
168
if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01 ) != 0 ||
169
slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&pdesc ) != 0 ||
170
slapi_pblock_set( pb, delfn, (void *) referint_postop_del ) != 0 ||
171
slapi_pblock_set( pb, mdnfn, (void *) referint_postop_modrdn ) != 0 ||
172
slapi_pblock_set( pb, SLAPI_PLUGIN_START_FN, (void *) referint_postop_start ) != 0 ||
173
slapi_pblock_set( pb, SLAPI_PLUGIN_CLOSE_FN, (void *) referint_postop_close ) != 0)
175
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM, "referint_postop_init failed\n" );
158
184
referint_postop_del( Slapi_PBlock *pb )
160
Slapi_DN *sdn = NULL;
169
if ( slapi_pblock_get( pb, SLAPI_IS_REPLICATED_OPERATION, &isrepop ) != 0 ||
170
slapi_pblock_get( pb, SLAPI_DELETE_TARGET_SDN, &sdn ) != 0 ||
171
slapi_pblock_get(pb, SLAPI_PLUGIN_OPRETURN, &oprc) != 0)
173
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
174
"referint_postop_del: could not get parameters\n" );
178
/* this plugin should only execute if the delete was successful
179
and this is not a replicated op
181
if(oprc != 0 || isrepop)
186
if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGC, &argc ) != 0) {
187
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
188
"referint_postop failed to get argc\n" );
191
if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGV, &argv ) != 0) {
192
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
193
"referint_postop failed to get argv\n" );
198
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
199
"referint_postop_del, args are NULL\n" );
204
/* argv[0] will be the delay */
205
delay = atoi(argv[0]);
207
/* argv[2] will be wether or not to log changes */
208
logChanges = atoi(argv[2]);
211
/* integrity updating is off */
213
}else if(delay == 0){
215
/* call function to update references to entry */
216
rc = update_integrity(argv, sdn, NULL, NULL, logChanges);
218
/* write the entry to integrity log */
219
writeintegritylog(pb, argv[1], sdn, NULL, NULL, NULL /* slapi_get_requestor_sdn(pb) */);
223
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
224
"referint_postop insufficient arguments supplied\n" );
186
Slapi_DN *sdn = NULL;
195
if (0 == refint_started) {
196
/* not initialized yet */
200
if ( slapi_pblock_get( pb, SLAPI_IS_REPLICATED_OPERATION, &isrepop ) != 0 ||
201
slapi_pblock_get( pb, SLAPI_DELETE_TARGET_SDN, &sdn ) != 0 ||
202
slapi_pblock_get(pb, SLAPI_PLUGIN_OPRETURN, &oprc) != 0)
204
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
205
"referint_postop_del: could not get parameters\n" );
209
* This plugin should only execute if the delete was successful
210
* and this is not a replicated op(unless its allowed)
212
if(oprc != 0 || (isrepop && !allow_repl)){
216
if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGC, &argc ) != 0) {
217
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
218
"referint_postop failed to get argc\n" );
221
if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGV, &argv ) != 0) {
222
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
223
"referint_postop failed to get argv\n" );
228
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
229
"referint_postop_del, args are NULL\n" );
234
/* argv[0] will be the delay */
235
delay = atoi(argv[0]);
237
/* argv[2] will be wether or not to log changes */
238
logChanges = atoi(argv[2]);
241
/* integrity updating is off */
243
} else if(delay == 0){ /* no delay */
244
/* call function to update references to entry */
245
rc = update_integrity(argv, sdn, NULL, NULL, logChanges);
247
/* write the entry to integrity log */
248
writeintegritylog(pb, argv[1], sdn, NULL, NULL, NULL /* slapi_get_requestor_sdn(pb) */);
252
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
253
"referint_postop insufficient arguments supplied\n" );
233
261
referint_postop_modrdn( Slapi_PBlock *pb )
235
Slapi_DN *sdn = NULL;
237
Slapi_DN *newsuperior;
246
if ( slapi_pblock_get( pb, SLAPI_IS_REPLICATED_OPERATION, &isrepop ) != 0 ||
247
slapi_pblock_get( pb, SLAPI_MODRDN_TARGET_SDN, &sdn ) != 0 ||
248
slapi_pblock_get( pb, SLAPI_MODRDN_NEWRDN, &newrdn ) != 0 ||
249
slapi_pblock_get( pb, SLAPI_MODRDN_NEWSUPERIOR_SDN, &newsuperior ) != 0 ||
250
slapi_pblock_get(pb, SLAPI_PLUGIN_OPRETURN, &oprc) != 0 ){
252
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
253
"referint_postop_modrdn: could not get parameters\n" );
257
/* this plugin should only execute if the delete was successful
258
and this is not a replicated op
260
if(oprc != 0 || isrepop){
264
if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGC, &argc ) != 0) {
265
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
266
"referint_postop failed to get argv\n" );
269
if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGV, &argv ) != 0) {
270
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
271
"referint_postop failed to get argv\n" );
276
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
277
"referint_postop_modrdn, args are NULL\n" );
282
/* argv[0] will always be the delay */
283
delay = atoi(argv[0]);
285
/* argv[2] will be wether or not to log changes */
286
logChanges = atoi(argv[2]);
288
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
289
"referint_postop_modrdn insufficient arguments supplied\n" );
294
/* integrity updating is off */
296
}else if(delay == 0){
298
/* call function to update references to entry */
299
rc = update_integrity(argv, sdn, newrdn, newsuperior, logChanges);
301
/* write the entry to integrity log */
302
writeintegritylog(pb, argv[1], sdn, newrdn, newsuperior, NULL /* slapi_get_requestor_sdn(pb) */);
263
Slapi_DN *sdn = NULL;
264
Slapi_DN *newsuperior;
274
if ( slapi_pblock_get( pb, SLAPI_IS_REPLICATED_OPERATION, &isrepop ) != 0 ||
275
slapi_pblock_get( pb, SLAPI_MODRDN_TARGET_SDN, &sdn ) != 0 ||
276
slapi_pblock_get( pb, SLAPI_MODRDN_NEWRDN, &newrdn ) != 0 ||
277
slapi_pblock_get( pb, SLAPI_MODRDN_NEWSUPERIOR_SDN, &newsuperior ) != 0 ||
278
slapi_pblock_get( pb, SLAPI_PLUGIN_OPRETURN, &oprc) != 0 )
280
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
281
"referint_postop_modrdn: could not get parameters\n" );
285
* This plugin should only execute if the delete was successful
286
* and this is not a replicated op (unless its allowed)
288
if(oprc != 0 || (isrepop && !allow_repl)){
292
if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGC, &argc ) != 0) {
293
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
294
"referint_postop failed to get argv\n" );
297
if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGV, &argv ) != 0) {
298
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
299
"referint_postop failed to get argv\n" );
303
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
304
"referint_postop_modrdn, args are NULL\n" );
309
/* argv[0] will always be the delay */
310
delay = atoi(argv[0]);
312
/* argv[2] will be wether or not to log changes */
313
logChanges = atoi(argv[2]);
315
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
316
"referint_postop_modrdn insufficient arguments supplied\n" );
321
/* integrity updating is off */
323
} else if(delay == 0){ /* no delay */
324
/* call function to update references to entry */
325
rc = update_integrity(argv, sdn, newrdn, newsuperior, logChanges);
327
/* write the entry to integrity log */
328
writeintegritylog(pb, argv[1], sdn, newrdn, newsuperior, NULL /* slapi_get_requestor_sdn(pb) */);
309
335
int isFatalSearchError(int search_result)
312
337
/* Make sure search result is fatal
313
338
* Some conditions that happen quite often are not fatal
314
339
* for example if you have two suffixes and one is null, you will always
315
* get no such object, howerever this is not a fatal error.
340
* get no such object, however this is not a fatal error.
316
341
* Add other conditions to the if statement as they are found
319
/* NPCTE fix for bugid 531225, esc 0. <P.R> <30-May-2001> */
320
switch(search_result) {
322
case LDAP_NO_SUCH_OBJECT: return 0 ;
325
/* end of NPCTE fix for bugid 531225 */
343
switch(search_result) {
345
case LDAP_NO_SUCH_OBJECT: return 0 ;
677
709
Slapi_PBlock *search_result_pb = NULL;
678
710
Slapi_PBlock *mod_pb = slapi_pblock_new();
679
711
Slapi_Entry **search_entries = NULL;
681
712
Slapi_DN *sdn = NULL;
713
Slapi_Attr *attr = NULL;
682
714
void *node = NULL;
715
const char *origDN = slapi_sdn_get_dn(origSDN);
716
const char *search_base = NULL;
717
char *attrName = NULL;
683
718
char *filter = NULL;
685
const char *search_base = NULL;
687
size_t len = slapi_sdn_get_ndn_len(origSDN);
688
const char *origDN = slapi_sdn_get_dn(origSDN);
690
if ( argv == NULL ) {
691
726
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
692
727
"referint_postop required config file arguments missing\n" );
694
729
goto free_and_return;
697
/* for now, just putting attributes to keep integrity on in conf file,
698
until resolve the other timing mode issue */
732
* For now, just putting attributes to keep integrity on in conf file,
733
* until resolve the other timing mode issue
699
735
search_result_pb = slapi_pblock_new();
701
737
/* Search each namingContext in turn */
702
738
for ( sdn = slapi_get_first_suffix( &node, 0 ); sdn != NULL;
703
739
sdn = slapi_get_next_suffix( &node, 0 ))
741
Slapi_Backend *be = slapi_be_select(sdn);
705
742
search_base = slapi_sdn_get_dn( sdn );
707
for(i = 3; argv[i] != NULL; i++)
710
filter = slapi_ch_smprintf("(%s=*%s)", argv[i],
711
escape_filter_value(origDN, len, buf));
744
for(i = 3; argv[i] != NULL; i++){
745
filter = slapi_filter_sprintf("(%s=*%s%s)", argv[i], ESC_NEXT_VAL, origDN);
713
747
/* Need only the current attribute and its subtypes */
715
748
attrs[0] = argv[i];
718
751
/* Use new search API */
719
752
slapi_pblock_init(search_result_pb);
753
slapi_pblock_set(search_result_pb, SLAPI_BACKEND, be);
720
754
slapi_search_internal_set_pb(search_result_pb, search_base,
721
755
LDAP_SCOPE_SUBTREE, filter, attrs, 0 /* attrs only */,
722
756
NULL, NULL, referint_plugin_identity, 0);
723
757
slapi_search_internal_pb(search_result_pb);
725
slapi_pblock_get( search_result_pb, SLAPI_PLUGIN_INTOP_RESULT,
759
slapi_pblock_get( search_result_pb, SLAPI_PLUGIN_INTOP_RESULT, &search_result);
728
761
/* if search successfull then do integrity update */
729
762
if(search_result == LDAP_SUCCESS)
731
slapi_pblock_get(search_result_pb,
732
SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES,
764
slapi_pblock_get(search_result_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES,
733
765
&search_entries);
735
for(j=0; search_entries[j] != NULL; j++)
737
Slapi_Attr *attr = NULL;
738
char *attrName = NULL;
740
/* Loop over all the attributes of the entry and search
741
* for the integrity attribute and its subtypes */
767
for(j = 0; search_entries[j] != NULL; j++){
771
* Loop over all the attributes of the entry and search
772
* for the integrity attribute and its subtypes
742
774
for (slapi_entry_first_attr(search_entries[j], &attr); attr;
743
775
slapi_entry_next_attr(search_entries[j], attr, &attr))
745
/* Take into account only the subtypes of the attribute
746
* in argv[i] having the necessary value - origDN */
778
* Take into account only the subtypes of the attribute
779
* in argv[i] having the necessary value - origDN
747
781
slapi_attr_get_type(attr, &attrName);
748
782
if (slapi_attr_type_cmp(argv[i], attrName,
749
783
SLAPI_TYPE_CMP_SUBTYPE) == 0)
752
786
slapi_attr_get_numvalues(attr, &nval);
755
788
* We want to reduce the "modify" call as much as
756
789
* possible. But if an entry contains 1000s of
818
846
int referint_postop_start( Slapi_PBlock *pb)
825
852
if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGC, &argc ) != 0 ) {
826
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
827
"referint_postop failed to get argv\n" );
853
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
854
"referint_postop failed to get argv\n" );
830
857
if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGV, &argv ) != 0 ) {
831
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
832
"referint_postop failed to get argv\n" );
858
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
859
"referint_postop failed to get argv\n" );
836
862
if(argv == NULL){
837
863
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
838
"args were null in referint_postop_start\n" );
864
"args were null in referint_postop_start\n" );
842
/* only bother to start the thread if you are in delay mode.
844
-1 = integrity off */
847
if(atoi(argv[0]) > 0){
849
/* initialize cv and lock */
851
referint_mutex = PR_NewLock();
852
keeprunning_mutex = PR_NewLock();
853
keeprunning_cv = PR_NewCondVar(keeprunning_mutex);
868
* Only bother to start the thread if you are in delay mode.
873
if(atoi(argv[0]) > 0){
874
/* initialize the cv and lock */
875
if (!use_txn && (NULL == referint_mutex)) {
876
referint_mutex = PR_NewLock();
878
keeprunning_mutex = PR_NewLock();
879
keeprunning_cv = PR_NewCondVar(keeprunning_mutex);
856
referint_tid = PR_CreateThread (PR_USER_THREAD,
857
referint_thread_func,
861
PR_UNJOINABLE_THREAD,
862
SLAPD_DEFAULT_THREAD_STACKSIZE);
863
if ( referint_tid == NULL ) {
864
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
865
"referint_postop_start PR_CreateThread failed\n" );
870
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
871
"referint_postop_start insufficient arguments supplied\n" );
882
referint_tid = PR_CreateThread (PR_USER_THREAD,
883
referint_thread_func,
887
PR_UNJOINABLE_THREAD,
888
SLAPD_DEFAULT_THREAD_STACKSIZE);
889
if ( referint_tid == NULL ) {
890
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
891
"referint_postop_start PR_CreateThread failed\n" );
896
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
897
"referint_postop_start insufficient arguments supplied\n" );
879
905
int referint_postop_close( Slapi_PBlock *pb)
882
/* signal the thread to exit */
883
if (NULL != keeprunning_mutex) {
884
PR_Lock(keeprunning_mutex);
886
if (NULL != keeprunning_cv) {
887
PR_NotifyCondVar(keeprunning_cv);
889
PR_Unlock(keeprunning_mutex);
907
/* signal the thread to exit */
908
if (NULL != keeprunning_mutex) {
909
PR_Lock(keeprunning_mutex);
911
if (NULL != keeprunning_cv) {
912
PR_NotifyCondVar(keeprunning_cv);
914
PR_Unlock(keeprunning_mutex);
896
922
referint_thread_func(void *arg)
898
925
char **plugin_argv = (char **)arg;
900
926
char *logfilename;
901
927
char thisline[MAX_LINE];
904
928
char delimiter[]="\t\n";
906
Slapi_DN *sdn = NULL;
932
Slapi_DN *sdn = NULL;
908
933
Slapi_DN *tmpsuperior = NULL;
912
938
if(plugin_argv == NULL){
913
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
914
"referint_thread_func not get args \n" );
939
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
940
"referint_thread_func not get args \n" );
918
/* initialize the thread data index
919
if(slapi_td_dn_init()){
920
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,"Failed to create thread data index\n");
924
944
delay = atoi(plugin_argv[0]);
925
945
logfilename = plugin_argv[1];
926
logChanges = atoi(plugin_argv[2]);
928
/* keep running this thread until plugin is signalled to close */
946
logChanges = atoi(plugin_argv[2]);
948
* keep running this thread until plugin is signaled to close
934
952
while(no_changes){
936
PR_Lock(keeprunning_mutex);
937
if(keeprunning == 0){
938
PR_Unlock(keeprunning_mutex);
941
PR_Unlock(keeprunning_mutex);
944
PR_Lock(referint_mutex);
945
if (( prfd = PR_Open( logfilename, PR_RDONLY,
946
REFERINT_DEFAULT_FILE_MODE )) == NULL )
948
PR_Unlock(referint_mutex);
949
/* go back to sleep and wait for this file */
950
PR_Lock(keeprunning_mutex);
951
PR_WaitCondVar(keeprunning_cv, PR_SecondsToInterval(delay));
953
PR_Lock(keeprunning_mutex);
954
if(keeprunning == 0){
955
PR_Unlock(keeprunning_mutex);
952
958
PR_Unlock(keeprunning_mutex);
958
/* check keep running here, because after break out of no
959
* changes loop on shutdown, also need to break out of this
960
* loop before trying to do the changes. The server
961
* will pick them up on next startup as file still exists
961
if (( prfd = PR_Open( logfilename, PR_RDONLY, REFERINT_DEFAULT_FILE_MODE )) == NULL ){
963
/* go back to sleep and wait for this file */
964
PR_Lock(keeprunning_mutex);
965
PR_WaitCondVar(keeprunning_cv, PR_SecondsToInterval(delay));
966
PR_Unlock(keeprunning_mutex);
972
* Check keep running here, because after break out of no
973
* changes loop on shutdown, also need to break out of this
974
* loop before trying to do the changes. The server
975
* will pick them up on next startup as file still exists
963
977
PR_Lock(keeprunning_mutex);
964
978
if(keeprunning == 0){
965
PR_Unlock(keeprunning_mutex);
979
PR_Unlock(keeprunning_mutex);
968
982
PR_Unlock(keeprunning_mutex);
971
while( GetNextLine(thisline, MAX_LINE, prfd) ){
972
ptoken = ldap_utf8strtok_r(thisline, delimiter, &iter);
973
sdn = slapi_sdn_new_normdn_byref(ptoken);
975
ptoken = ldap_utf8strtok_r (NULL, delimiter, &iter);
976
if(!strcasecmp(ptoken, "NULL")) {
979
tmprdn = slapi_ch_smprintf("%s", ptoken);
982
ptoken = ldap_utf8strtok_r (NULL, delimiter, &iter);
983
if (!strcasecmp(ptoken, "NULL")) {
986
tmpsuperior = slapi_sdn_new_normdn_byref(ptoken);
988
ptoken = ldap_utf8strtok_r (NULL, delimiter, &iter);
989
if (strcasecmp(ptoken, "NULL") != 0) {
990
/* Set the bind DN in the thread data */
991
if(slapi_td_set_dn(slapi_ch_strdup(ptoken))){
992
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,"Failed to set thread data\n");
996
update_integrity(plugin_argv, sdn, tmprdn,
997
tmpsuperior, logChanges);
999
slapi_sdn_free(&sdn);
1000
slapi_ch_free_string(&tmprdn);
1001
slapi_sdn_free(&tmpsuperior);
1006
/* remove the original file */
1007
if( PR_SUCCESS != PR_Delete(logfilename) )
1009
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
1010
"referint_postop_close could not delete \"%s\"\n",
1014
/* unlock and let other writers back at the file */
1015
PR_Unlock(referint_mutex);
1017
/* wait on condition here */
1018
PR_Lock(keeprunning_mutex);
1019
PR_WaitCondVar(keeprunning_cv, PR_SecondsToInterval(delay));
1020
PR_Unlock(keeprunning_mutex);
1023
/* cleanup resources allocated in start */
1024
if (NULL != keeprunning_mutex) {
1025
PR_DestroyLock(keeprunning_mutex);
1027
if (NULL != referint_mutex) {
1028
PR_DestroyLock(referint_mutex);
1030
if (NULL != keeprunning_cv) {
1031
PR_DestroyCondVar(keeprunning_cv);
984
while( GetNextLine(thisline, MAX_LINE, prfd) ){
985
ptoken = ldap_utf8strtok_r(thisline, delimiter, &iter);
986
sdn = slapi_sdn_new_normdn_byref(ptoken);
987
ptoken = ldap_utf8strtok_r (NULL, delimiter, &iter);
989
if(!strcasecmp(ptoken, "NULL")) {
992
tmprdn = slapi_ch_smprintf("%s", ptoken);
995
ptoken = ldap_utf8strtok_r (NULL, delimiter, &iter);
996
if (!strcasecmp(ptoken, "NULL")) {
999
tmpsuperior = slapi_sdn_new_normdn_byref(ptoken);
1001
ptoken = ldap_utf8strtok_r (NULL, delimiter, &iter);
1002
if (strcasecmp(ptoken, "NULL") != 0) {
1003
/* Set the bind DN in the thread data */
1004
if(slapi_td_set_dn(slapi_ch_strdup(ptoken))){
1005
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,"Failed to set thread data\n");
1009
update_integrity(plugin_argv, sdn, tmprdn, tmpsuperior, logChanges);
1011
slapi_sdn_free(&sdn);
1012
slapi_ch_free_string(&tmprdn);
1013
slapi_sdn_free(&tmpsuperior);
1018
/* remove the original file */
1019
if( PR_SUCCESS != PR_Delete(logfilename) ){
1020
slapi_log_error( SLAPI_LOG_FATAL, REFERINT_PLUGIN_SUBSYSTEM,
1021
"referint_postop_close could not delete \"%s\"\n", logfilename );
1024
/* unlock and let other writers back at the file */
1027
/* wait on condition here */
1028
PR_Lock(keeprunning_mutex);
1029
PR_WaitCondVar(keeprunning_cv, PR_SecondsToInterval(delay));
1030
PR_Unlock(keeprunning_mutex);
1033
/* cleanup resources allocated in start */
1034
if (NULL != keeprunning_mutex) {
1035
PR_DestroyLock(keeprunning_mutex);
1037
if (NULL != referint_mutex) {
1038
PR_DestroyLock(referint_mutex);
1040
if (NULL != keeprunning_cv) {
1041
PR_DestroyCondVar(keeprunning_cv);
1037
1045
int my_fgetc(PRFileDesc *stream)