modrdn.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  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. /*
  39. * Copyright (c) 1995 Regents of the University of Michigan.
  40. * All rights reserved.
  41. *
  42. * Redistribution and use in source and binary forms are permitted
  43. * provided that this notice is preserved and that due credit is given
  44. * to the University of Michigan at Ann Arbor. The name of the University
  45. * may not be used to endorse or promote products derived from this
  46. * software without specific prior written permission. This software
  47. * is provided ``as is'' without express or implied warranty.
  48. */
  49. #include <stdio.h>
  50. #include <string.h>
  51. #include <sys/types.h>
  52. #ifndef _WIN32
  53. #include <sys/socket.h>
  54. #endif
  55. #include "slap.h"
  56. #include "pratom.h"
  57. /* Forward declarations */
  58. static int rename_internal_pb (Slapi_PBlock *pb);
  59. static void op_shared_rename (Slapi_PBlock *pb, int passin_args );
  60. /* This function is called to process operation that come over external connections */
  61. void
  62. do_modrdn( Slapi_PBlock *pb )
  63. {
  64. Slapi_Operation *operation;
  65. BerElement *ber;
  66. char *dn = NULL, *newsuperior = NULL;
  67. char *newrdn = NULL;
  68. int err = 0, deloldrdn = 0;
  69. ber_len_t len = 0;
  70. LDAPDebug( LDAP_DEBUG_TRACE, "do_modrdn\n", 0, 0, 0 );
  71. /* count the modrdn request */
  72. PR_AtomicIncrement(g_get_global_snmp_vars()->ops_tbl.dsModifyRDNOps);
  73. slapi_pblock_get( pb, SLAPI_OPERATION, &operation);
  74. ber = operation->o_ber;
  75. /*
  76. * Parse the modrdn request. It looks like this:
  77. *
  78. * ModifyRDNRequest := SEQUENCE {
  79. * entry DistinguishedName,
  80. * newrdn RelativeDistinguishedName,
  81. * deleteoldrdn BOOLEAN,
  82. * newSuperior [0] LDAPDN OPTIONAL -- v3 only
  83. * }
  84. */
  85. if ( ber_scanf( ber, "{aab", &dn, &newrdn, &deloldrdn )
  86. == LBER_ERROR ) {
  87. LDAPDebug( LDAP_DEBUG_ANY,
  88. "ber_scanf failed (op=ModRDN; params=DN,newRDN,deleteOldRDN)\n",
  89. 0, 0, 0 );
  90. op_shared_log_error_access (pb, "MODRDN", "???", "decoding error");
  91. send_ldap_result( pb, LDAP_PROTOCOL_ERROR, NULL,
  92. "unable to decode DN, newRDN, or deleteOldRDN parameters",
  93. 0, NULL );
  94. goto free_and_return;
  95. }
  96. if ( ber_peek_tag( ber, &len ) == LDAP_TAG_NEWSUPERIOR ) {
  97. if ( pb->pb_conn->c_ldapversion < LDAP_VERSION3 ) {
  98. LDAPDebug( LDAP_DEBUG_ANY,
  99. "got newSuperior in LDAPv2 modrdn op\n", 0, 0, 0 );
  100. op_shared_log_error_access (pb, "MODRDN", dn, "decoding error");
  101. send_ldap_result( pb, LDAP_PROTOCOL_ERROR, NULL,
  102. "received newSuperior in LDAPv2 modrdn", 0, NULL );
  103. goto free_and_return;
  104. }
  105. if ( ber_scanf( ber, "a", &newsuperior ) == LBER_ERROR ) {
  106. LDAPDebug( LDAP_DEBUG_ANY,
  107. "ber_scanf failed (op=ModRDN; params=newSuperior)\n",
  108. 0, 0, 0 );
  109. op_shared_log_error_access (pb, "MODRDN", dn, "decoding error");
  110. send_ldap_result( pb, LDAP_PROTOCOL_ERROR, NULL,
  111. "unable to decode newSuperior parameter", 0, NULL );
  112. goto free_and_return;
  113. }
  114. }
  115. /*
  116. * in LDAPv3 there can be optional control extensions on
  117. * the end of an LDAPMessage. we need to read them in and
  118. * pass them to the backend.
  119. */
  120. if ( (err = get_ldapmessage_controls( pb, ber, NULL )) != 0 ) {
  121. op_shared_log_error_access (pb, "MODRDN", dn, "failed to decode LDAP controls");
  122. send_ldap_result( pb, err, NULL, NULL, 0, NULL );
  123. goto free_and_return;
  124. }
  125. LDAPDebug( LDAP_DEBUG_ARGS,
  126. "do_moddn: dn (%s) newrdn (%s) deloldrdn (%d)\n", dn, newrdn,
  127. deloldrdn );
  128. slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, &pb->pb_op->o_isroot );
  129. slapi_pblock_set( pb, SLAPI_ORIGINAL_TARGET, dn );
  130. slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, newrdn );
  131. slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR, newsuperior );
  132. slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, &deloldrdn );
  133. op_shared_rename(pb, 1 /* pass in ownership of string arguments */ );
  134. return;
  135. free_and_return:;
  136. slapi_ch_free((void **) &dn );
  137. slapi_ch_free((void **) &newrdn );
  138. slapi_ch_free((void **) &newsuperior );
  139. }
  140. /* This function is used to issue internal modrdn operation
  141. This is an old style API. Its use is discoraged because it is not extendable and
  142. because it does not allow to check whether plugin has right to access part of the
  143. tree it is trying to modify. Use slapi_modrdn_internal_pb instead */
  144. Slapi_PBlock *
  145. slapi_modrdn_internal(const char *iodn, const char *inewrdn, int deloldrdn, LDAPControl **controls, int dummy)
  146. {
  147. return slapi_rename_internal(iodn, inewrdn, NULL, deloldrdn, controls, dummy);
  148. }
  149. Slapi_PBlock *
  150. slapi_rename_internal(const char *iodn, const char *inewrdn, const char *inewsuperior, int deloldrdn, LDAPControl **controls, int dummy)
  151. {
  152. Slapi_PBlock pb;
  153. Slapi_PBlock *result_pb = NULL;
  154. int opresult= 0;
  155. pblock_init (&pb);
  156. slapi_rename_internal_set_pb (&pb, iodn, inewrdn, inewsuperior, deloldrdn,
  157. controls, NULL, plugin_get_default_component_id(), 0);
  158. rename_internal_pb (&pb);
  159. result_pb = slapi_pblock_new();
  160. if (result_pb)
  161. {
  162. slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult);
  163. slapi_pblock_set(result_pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult);
  164. }
  165. pblock_done(&pb);
  166. return result_pb;
  167. }
  168. /* This is new style API to issue internal add operation.
  169. pblock should contain the following data (can be set via call to slapi_rename_internal_set_pb):
  170. For uniqueid based operation:
  171. SLAPI_TARGET_DN set to dn that allows to select right backend, can be stale
  172. SLAPI_TARGET_UNIQUEID set to the uniqueid of the entry we are looking for
  173. SLAPI_MODRDN_NEWRDN set to new rdn of the entry
  174. SLAPI_MODRDN_DELOLDRDN tells whether old rdn should be kept in the entry
  175. LAPI_CONTROLS_ARG set to request controls if present
  176. For dn based search:
  177. SLAPI_TARGET_DN set to the entry dn
  178. SLAPI_MODRDN_NEWRDN set to new rdn of the entry
  179. SLAPI_MODRDN_DELOLDRDN tells whether old rdn should be kept in the entry
  180. SLAPI_CONTROLS_ARG set to request controls if present
  181. */
  182. int slapi_modrdn_internal_pb (Slapi_PBlock *pb)
  183. {
  184. if (pb == NULL)
  185. return -1;
  186. return rename_internal_pb (pb);
  187. }
  188. /* Initialize a pblock for a call to slapi_modrdn_internal_pb() */
  189. void slapi_rename_internal_set_pb (Slapi_PBlock *pb, const char *olddn, const char *newrdn, const char *newsuperior, int deloldrdn,
  190. LDAPControl **controls, const char *uniqueid, Slapi_ComponentId *plugin_identity, int operation_flags)
  191. {
  192. Operation *op;
  193. PR_ASSERT (pb != NULL);
  194. if (pb == NULL || olddn == NULL || newrdn == NULL)
  195. {
  196. slapi_log_error(SLAPI_LOG_FATAL, NULL,
  197. "slapi_rename_internal_set_pb: NULL parameter\n");
  198. return;
  199. }
  200. op= internal_operation_new(SLAPI_OPERATION_MODRDN,operation_flags);
  201. slapi_pblock_set(pb, SLAPI_OPERATION, op);
  202. slapi_pblock_set(pb, SLAPI_ORIGINAL_TARGET, (void*)olddn);
  203. slapi_pblock_set(pb, SLAPI_MODRDN_NEWRDN, (void*)newrdn);
  204. slapi_pblock_set(pb, SLAPI_MODRDN_NEWSUPERIOR, (void*)newsuperior);
  205. slapi_pblock_set(pb, SLAPI_MODRDN_DELOLDRDN, &deloldrdn);
  206. slapi_pblock_set(pb, SLAPI_CONTROLS_ARG, controls);
  207. slapi_pblock_set(pb, SLAPI_MODIFY_MODS, NULL);
  208. if (uniqueid)
  209. {
  210. slapi_pblock_set(pb, SLAPI_TARGET_UNIQUEID, (void*)uniqueid);
  211. }
  212. slapi_pblock_set(pb, SLAPI_PLUGIN_IDENTITY, plugin_identity);
  213. }
  214. /* Helper functions */
  215. static int rename_internal_pb (Slapi_PBlock *pb)
  216. {
  217. LDAPControl **controls;
  218. Operation *op;
  219. int opresult = 0;
  220. PR_ASSERT (pb != NULL);
  221. slapi_pblock_get(pb, SLAPI_CONTROLS_ARG, &controls);
  222. slapi_pblock_get(pb, SLAPI_OPERATION, &op);
  223. op->o_handler_data = &opresult;
  224. op->o_result_handler = internal_getresult_callback;
  225. slapi_pblock_set(pb, SLAPI_REQCONTROLS, controls);
  226. /* set parameters common for all internal operations */
  227. set_common_params (pb);
  228. /* set actions taken to process the operation */
  229. set_config_params (pb);
  230. op_shared_rename (pb, 0 /* not passing ownership of args */ );
  231. slapi_pblock_set(pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult);
  232. return 0;
  233. }
  234. /*
  235. * op_shared_rename() -- common frontend code for modDN operations.
  236. *
  237. * Beware: this function resets the following pblock elements that were
  238. * set by the caller:
  239. *
  240. * SLAPI_MODRDN_TARGET
  241. * SLAPI_MODRDN_NEWRDN
  242. * SLAPI_MODRDN_NEWSUPERIOR
  243. */
  244. static void
  245. op_shared_rename(Slapi_PBlock *pb, int passin_args)
  246. {
  247. char *dn, *newsuperior, *newrdn, *newdn = NULL;
  248. char **rdns;
  249. int deloldrdn;
  250. Slapi_Backend *be = NULL;
  251. Slapi_DN sdn;
  252. Slapi_Mods smods;
  253. char dnbuf[BUFSIZ];
  254. char newrdnbuf[BUFSIZ];
  255. char newsuperiorbuf[BUFSIZ];
  256. int internal_op, repl_op, lastmod;
  257. Slapi_Operation *operation;
  258. Slapi_Entry *referral;
  259. char errorbuf[BUFSIZ];
  260. int err;
  261. slapi_pblock_get(pb, SLAPI_ORIGINAL_TARGET, &dn);
  262. slapi_pblock_get(pb, SLAPI_MODRDN_NEWRDN, &newrdn);
  263. slapi_pblock_get(pb, SLAPI_MODRDN_NEWSUPERIOR, &newsuperior);
  264. slapi_pblock_get(pb, SLAPI_MODRDN_DELOLDRDN, &deloldrdn);
  265. slapi_pblock_get(pb, SLAPI_IS_REPLICATED_OPERATION, &repl_op);
  266. slapi_pblock_get (pb, SLAPI_OPERATION, &operation);
  267. internal_op= operation_is_flag_set(operation, OP_FLAG_INTERNAL);
  268. /*
  269. * If ownership has not been passed to this function, we replace the
  270. * string input fields within the pblock with strdup'd copies. Why?
  271. * Because some pre- and post-op plugins may change them, and the
  272. * convention is that plugins should place a malloc'd string in the
  273. * pblock. Therefore, we need to be able to retrieve and free them
  274. * later. But the callers of the internal modrdn calls are promised
  275. * that we will not free these parameters... so if passin_args is
  276. * zero, we need to make copies.
  277. *
  278. * In the case of SLAPI_MODRDN_TARGET and SLAPI_MODRDN_NEWSUPERIOR, we
  279. * replace the existing values with normalized values (because plugins
  280. * expect these DNs to be normalized).
  281. */
  282. if ( passin_args ) {
  283. slapi_sdn_init_dn_passin(&sdn,dn); /* freed by slapi_sdn_done() */
  284. } else {
  285. slapi_sdn_init_dn_byref(&sdn,dn);
  286. }
  287. if ( !passin_args ) {
  288. newrdn = slapi_ch_strdup( newrdn );
  289. newsuperior = slapi_ch_strdup( newsuperior );
  290. }
  291. if ( NULL != newsuperior ) {
  292. slapi_dn_normalize_case( newsuperior ); /* normalize in place */
  293. }
  294. slapi_pblock_set (pb, SLAPI_MODRDN_TARGET,
  295. (void*)slapi_ch_strdup(slapi_sdn_get_ndn (&sdn)));
  296. slapi_pblock_set(pb, SLAPI_MODRDN_NEWRDN, (void *)newrdn );
  297. slapi_pblock_set(pb, SLAPI_MODRDN_NEWSUPERIOR, (void *)newsuperior);
  298. /*
  299. * first, log the operation to the access log,
  300. * then check rdn and newsuperior,
  301. * and - if applicable - log reason of any error to the errors log
  302. */
  303. if (operation_is_flag_set(operation,OP_FLAG_ACTION_LOG_ACCESS))
  304. {
  305. if ( !internal_op )
  306. {
  307. slapi_log_access(LDAP_DEBUG_STATS,
  308. "conn=%d op=%d MODRDN dn=\"%s\" newrdn=\"%s\" newsuperior=\"%s\"\n",
  309. pb->pb_conn->c_connid,
  310. pb->pb_op->o_opid,
  311. escape_string(dn, dnbuf),
  312. (NULL == newrdn) ? "(null)" : escape_string(newrdn, newrdnbuf),
  313. (NULL == newsuperior) ? "(null)" : escape_string(newsuperior, newsuperiorbuf));
  314. }
  315. else
  316. {
  317. slapi_log_access(LDAP_DEBUG_ARGS,
  318. "conn=%s op=%d MODRDN dn=\"%s\" newrdn=\"%s\" newsuperior=\"%s\"\n",
  319. LOG_INTERNAL_OP_CON_ID,
  320. LOG_INTERNAL_OP_OP_ID,
  321. escape_string(dn, dnbuf),
  322. (NULL == newrdn) ? "(null)" : escape_string(newrdn, newrdnbuf),
  323. (NULL == newsuperior) ? "(null)" : escape_string(newsuperior, newsuperiorbuf));
  324. }
  325. }
  326. /* check that the rdn is formatted correctly */
  327. if ((rdns = ldap_explode_rdn(newrdn, 0)) == NULL)
  328. {
  329. slapi_log_error(SLAPI_LOG_FATAL, NULL,
  330. "conn=%d op=%d MODRDN invalid new RDN (\"%s\")\n",
  331. pb->pb_conn->c_connid,
  332. pb->pb_op->o_opid,
  333. (NULL == newrdn) ? "(null)" : newrdn);
  334. send_ldap_result(pb, LDAP_INVALID_DN_SYNTAX, NULL, "invalid RDN", 0, NULL);
  335. goto free_and_return_nolock;
  336. }
  337. else
  338. {
  339. ldap_value_free(rdns);
  340. }
  341. /* check that the dn is formatted correctly */
  342. if ((rdns = ldap_explode_dn(newsuperior, 0)) == NULL)
  343. {
  344. LDAPDebug(LDAP_DEBUG_ARGS, "ldap_explode_dn of newSuperior failed\n", 0, 0, 0);
  345. slapi_log_error(SLAPI_LOG_FATAL, NULL,
  346. "conn=%d op=%d MODRDN invalid new superior (\"%s\")",
  347. pb->pb_conn->c_connid,
  348. pb->pb_op->o_opid,
  349. (NULL == newsuperior) ? "(null)" : newsuperiorbuf);
  350. send_ldap_result(pb, LDAP_PROTOCOL_ERROR, NULL,
  351. "newSuperior does not look like a DN", 0, NULL);
  352. goto free_and_return_nolock;
  353. }
  354. else
  355. {
  356. ldap_value_free(rdns);
  357. }
  358. if (newsuperior != NULL)
  359. {
  360. LDAPDebug(LDAP_DEBUG_ARGS, "do_moddn: newsuperior (%s)\n", newsuperior, 0, 0);
  361. }
  362. /* target spec is used to decide which plugins are applicable for the operation */
  363. operation_set_target_spec (pb->pb_op, &sdn);
  364. /*
  365. * Construct the new DN (code copied from backend
  366. * and modified to handle newsuperior)
  367. */
  368. newdn = slapi_moddn_get_newdn(&sdn,newrdn,newsuperior);
  369. /*
  370. * We could be serving multiple database backends. Select the
  371. * appropriate one, or send a referral to our "referral server"
  372. * if we don't hold it.
  373. */
  374. if ((err = slapi_mapping_tree_select_and_check(pb, newdn, &be, &referral, errorbuf)) != LDAP_SUCCESS)
  375. {
  376. send_ldap_result(pb, err, NULL, errorbuf, 0, NULL);
  377. goto free_and_return_nolock;
  378. }
  379. if (referral)
  380. {
  381. int managedsait;
  382. slapi_pblock_get(pb, SLAPI_MANAGEDSAIT, &managedsait);
  383. if (managedsait)
  384. {
  385. send_ldap_result(pb, LDAP_UNWILLING_TO_PERFORM, NULL,
  386. "cannot update referral", 0, NULL);
  387. slapi_entry_free(referral);
  388. goto free_and_return;
  389. }
  390. send_referrals_from_entry(pb,referral);
  391. slapi_entry_free(referral);
  392. goto free_and_return;
  393. }
  394. slapi_pblock_set(pb, SLAPI_BACKEND, be);
  395. /* can get lastmod only after backend is selected */
  396. slapi_pblock_get(pb, SLAPI_BE_LASTMOD, &lastmod);
  397. /* if it is a replicated operation - leave lastmod attributes alone */
  398. slapi_mods_init (&smods, 2);
  399. if (!repl_op && lastmod)
  400. {
  401. modify_update_last_modified_attr(pb, &smods);
  402. slapi_pblock_set(pb, SLAPI_MODIFY_MODS, (void*)slapi_mods_get_ldapmods_passout(&smods));
  403. }
  404. else {
  405. slapi_mods_done (&smods);
  406. }
  407. /*
  408. * call the pre-modrdn plugins. if they succeed, call
  409. * the backend modrdn function. then call the
  410. * post-modrdn plugins.
  411. */
  412. if (plugin_call_plugins(pb, internal_op ? SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN :
  413. SLAPI_PLUGIN_PRE_MODRDN_FN) == 0)
  414. {
  415. int rc= LDAP_OPERATIONS_ERROR;
  416. slapi_pblock_set(pb, SLAPI_PLUGIN, be->be_database);
  417. set_db_default_result_handlers(pb);
  418. if (be->be_modrdn != NULL)
  419. {
  420. if ((rc = (*be->be_modrdn)(pb)) == 0)
  421. {
  422. Slapi_Entry *pse;
  423. Slapi_Entry *ecopy;
  424. /* we don't perform acl check for internal operations */
  425. /* dont update aci store for remote acis */
  426. if ((!internal_op) &&
  427. (!slapi_be_is_flag_set(be,SLAPI_BE_FLAG_REMOTE_DATA)))
  428. plugin_call_acl_mods_update (pb, SLAPI_OPERATION_MODRDN);
  429. if (operation_is_flag_set(operation,OP_FLAG_ACTION_LOG_AUDIT))
  430. write_audit_log_entry(pb); /* Record the operation in the audit log */
  431. slapi_pblock_get(pb, SLAPI_ENTRY_POST_OP, &pse);
  432. slapi_pblock_get(pb, SLAPI_ENTRY_PRE_OP, &ecopy);
  433. /* GGOODREPL persistent search system needs the changenumber, oops. */
  434. do_ps_service(pse, ecopy, LDAP_CHANGETYPE_MODDN, 0UL);
  435. }
  436. }
  437. else
  438. {
  439. send_ldap_result(pb, LDAP_UNWILLING_TO_PERFORM, NULL, "Function not implemented", 0, NULL);
  440. }
  441. slapi_pblock_set(pb, SLAPI_PLUGIN_OPRETURN, &rc);
  442. plugin_call_plugins(pb, internal_op ? SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN :
  443. SLAPI_PLUGIN_POST_MODRDN_FN);
  444. }
  445. free_and_return:
  446. if (be)
  447. slapi_be_Unlock(be);
  448. free_and_return_nolock:
  449. {
  450. /* Free up everything left in the PBlock */
  451. Slapi_Entry *pse;
  452. Slapi_Entry *ecopy;
  453. LDAPMod **mods;
  454. char *s;
  455. slapi_ch_free((void **) &newdn);
  456. slapi_sdn_done(&sdn);
  457. slapi_pblock_get(pb, SLAPI_ENTRY_PRE_OP, &ecopy);
  458. slapi_entry_free(ecopy);
  459. slapi_pblock_get(pb, SLAPI_ENTRY_POST_OP, &pse);
  460. slapi_entry_free(pse);
  461. slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
  462. ldap_mods_free( mods, 1 );
  463. /* retrieve these in case a pre- or post-op plugin has changed them */
  464. slapi_pblock_get(pb, SLAPI_MODRDN_TARGET, &s);
  465. slapi_ch_free((void **)&s);
  466. slapi_pblock_get(pb, SLAPI_MODRDN_NEWRDN, &s);
  467. slapi_ch_free((void **)&s);
  468. slapi_pblock_get(pb, SLAPI_MODRDN_NEWSUPERIOR, &s);
  469. slapi_ch_free((void **)&s);
  470. slapi_pblock_get(pb, SLAPI_URP_NAMING_COLLISION_DN, &s);
  471. slapi_ch_free((void **)&s);
  472. }
  473. }