75
75
char *rawdn = NULL, *rawnewsuperior = NULL;
76
76
const char *dn = NULL, *newsuperior = NULL;
77
char *rawnewrdn = NULL;
78
77
char *newrdn = NULL;
79
78
int err = 0, deloldrdn = 0;
109
if ( ber_scanf( ber, "{aab", &rawdn, &rawnewrdn, &deloldrdn )
108
if (ber_scanf(ber, "{aab", &rawdn, &newrdn, &deloldrdn) == LBER_ERROR) {
111
109
LDAPDebug( LDAP_DEBUG_ANY,
112
110
"ber_scanf failed (op=ModRDN; params=DN,newRDN,deleteOldRDN)\n",
128
126
send_ldap_result( pb, LDAP_PROTOCOL_ERROR, NULL,
129
127
"received newSuperior in LDAPv2 modrdn", 0, NULL );
130
128
slapi_ch_free_string( &rawdn );
131
slapi_ch_free_string( &rawnewrdn );
129
slapi_ch_free_string( &newrdn );
132
130
goto free_and_return;
134
132
if ( ber_scanf( ber, "a", &rawnewsuperior ) == LBER_ERROR ) {
139
137
send_ldap_result( pb, LDAP_PROTOCOL_ERROR, NULL,
140
138
"unable to decode newSuperior parameter", 0, NULL );
141
139
slapi_ch_free_string( &rawdn );
142
slapi_ch_free_string( &rawnewrdn );
140
slapi_ch_free_string( &newrdn );
143
141
goto free_and_return;
154
152
send_ldap_result(pb, LDAP_INVALID_DN_SYNTAX,
155
153
NULL, "invalid dn", 0, NULL);
156
154
slapi_ch_free_string( &rawdn );
157
slapi_ch_free_string( &rawnewrdn );
155
slapi_ch_free_string( &newrdn );
158
156
slapi_ch_free_string( &rawnewsuperior );
159
157
goto free_and_return;
161
159
/* check that the new rdn is formatted correctly */
162
err = slapi_dn_syntax_check(pb, rawnewrdn, 1);
160
err = slapi_dn_syntax_check(pb, newrdn, 1);
163
161
if (err) { /* syntax check failed */
164
op_shared_log_error_access(pb, "MODRDN", rawnewrdn?rawnewrdn:"",
162
op_shared_log_error_access(pb, "MODRDN", newrdn?newrdn:"",
165
163
"strict: invalid new rdn");
166
164
send_ldap_result(pb, LDAP_INVALID_DN_SYNTAX,
167
165
NULL, "invalid new rdn", 0, NULL);
168
166
slapi_ch_free_string( &rawdn );
169
slapi_ch_free_string( &rawnewrdn );
167
slapi_ch_free_string( &newrdn );
170
168
slapi_ch_free_string( &rawnewsuperior );
171
169
goto free_and_return;
178
176
op_shared_log_error_access(pb, "MODRDN", rawdn, "invalid dn");
179
177
send_ldap_result(pb, LDAP_INVALID_DN_SYNTAX, NULL,
180
178
"invalid dn", 0, NULL);
181
slapi_ch_free_string( &rawnewrdn );
182
slapi_ch_free_string( &rawnewsuperior );
183
goto free_and_return;
185
newrdn = slapi_create_dn_string("%s", rawnewrdn);
186
if (rawnewrdn && (NULL == newrdn)) {
187
op_shared_log_error_access(pb, "MODRDN", rawnewrdn, "invalid newrdn");
188
send_ldap_result(pb, LDAP_INVALID_DN_SYNTAX,
189
NULL, "invalid newrdn", 0, NULL);
190
slapi_ch_free_string( &rawnewrdn );
191
slapi_ch_free_string( &rawnewsuperior );
192
goto free_and_return;
194
slapi_ch_free_string( &rawnewrdn );
179
slapi_ch_free_string( &newrdn );
180
slapi_ch_free_string( &rawnewsuperior );
181
goto free_and_return;
196
184
if (rawnewsuperior) {
197
185
if (config_get_dn_validate_strict()) {
219
207
newdn = slapi_ch_smprintf("%s,%s", newrdn, parent);
220
208
/* slapi_sdn_init_normdn_passin expects normalized but NOT
221
209
* decapitalized dn */
222
slapi_sdn_init_normdn_passin(&snewdn, newdn); /* newdn is normalized */
210
slapi_sdn_init_dn_passin(&snewdn, newdn);
223
211
if (0 == slapi_sdn_compare(&sdn, snewsuperior) ||
224
212
0 == slapi_sdn_compare(&snewdn, snewsuperior)) {
225
213
op_shared_log_error_access(pb, "MODRDN", newsuperior,
506
494
slapi_log_access(LDAP_DEBUG_STATS,
507
495
"conn=%" NSPRIu64 " op=%d MODRDN dn=\"%s\" newrdn=\"%s\" newsuperior=\"%s\"%s\n",
508
pb->pb_conn->c_connid,
496
(long long unsigned int)pb->pb_conn->c_connid,
509
497
pb->pb_op->o_opid,
511
499
newrdn ? newrdn : "(null)",
539
527
if ( !internal_op ) {
540
528
slapi_log_error(SLAPI_LOG_ARGS, NULL,
541
529
"conn=%" NSPRIu64 " op=%d MODRDN invalid new RDN (\"%s\")\n",
542
pb->pb_conn->c_connid,
530
(long long unsigned int)pb->pb_conn->c_connid,
543
531
pb->pb_op->o_opid,
544
532
(NULL == newrdn) ? "(null)" : newrdn);
572
560
if (!internal_op) {
573
561
slapi_log_error(SLAPI_LOG_ARGS, NULL,
574
562
"conn=%" NSPRIu64 " op=%d MODRDN invalid new superior (\"%s\")",
575
pb->pb_conn->c_connid,
563
(long long unsigned int)pb->pb_conn->c_connid,
576
564
pb->pb_op->o_opid,
577
565
newsuperior ? newsuperior : "(null)");
654
642
* post-modrdn plugins.
656
644
if (plugin_call_plugins(pb, internal_op ? SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN :
657
SLAPI_PLUGIN_PRE_MODRDN_FN) == 0)
645
SLAPI_PLUGIN_PRE_MODRDN_FN) == SLAPI_PLUGIN_SUCCESS)
659
647
int rc= LDAP_OPERATIONS_ERROR;
660
648
slapi_pblock_set(pb, SLAPI_PLUGIN, be->be_database);