libnet dssync: refactor creation of request out into new function
[Samba/bb.git] / source / libnet / libnet_dssync.c
blobb93f906de254c2cf09a6bc136c1aa9b39de5222f
1 /*
2 Unix SMB/CIFS implementation.
4 Copyright (C) Stefan (metze) Metzmacher 2005
5 Copyright (C) Guenther Deschner 2008
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
23 #include "libnet/libnet.h"
25 /****************************************************************
26 ****************************************************************/
28 static int libnet_dssync_free_context(struct dssync_context *ctx)
30 if (!ctx) {
31 return 0;
34 if (is_valid_policy_hnd(&ctx->bind_handle) && ctx->cli) {
35 rpccli_drsuapi_DsUnbind(ctx->cli, ctx, &ctx->bind_handle, NULL);
38 return 0;
41 /****************************************************************
42 ****************************************************************/
44 NTSTATUS libnet_dssync_init_context(TALLOC_CTX *mem_ctx,
45 struct dssync_context **ctx_p)
47 struct dssync_context *ctx;
49 ctx = TALLOC_ZERO_P(mem_ctx, struct dssync_context);
50 NT_STATUS_HAVE_NO_MEMORY(ctx);
52 talloc_set_destructor(ctx, libnet_dssync_free_context);
54 *ctx_p = ctx;
56 return NT_STATUS_OK;
59 /****************************************************************
60 ****************************************************************/
62 static DATA_BLOB *decrypt_attr_val(TALLOC_CTX *mem_ctx,
63 DATA_BLOB *session_key,
64 uint32_t rid,
65 enum drsuapi_DsAttributeId id,
66 DATA_BLOB *raw_data)
68 bool rcrypt = false;
69 DATA_BLOB out_data;
71 ZERO_STRUCT(out_data);
73 switch (id) {
74 case DRSUAPI_ATTRIBUTE_dBCSPwd:
75 case DRSUAPI_ATTRIBUTE_unicodePwd:
76 case DRSUAPI_ATTRIBUTE_ntPwdHistory:
77 case DRSUAPI_ATTRIBUTE_lmPwdHistory:
78 rcrypt = true;
79 break;
80 case DRSUAPI_ATTRIBUTE_supplementalCredentials:
81 case DRSUAPI_ATTRIBUTE_priorValue:
82 case DRSUAPI_ATTRIBUTE_currentValue:
83 case DRSUAPI_ATTRIBUTE_trustAuthOutgoing:
84 case DRSUAPI_ATTRIBUTE_trustAuthIncoming:
85 case DRSUAPI_ATTRIBUTE_initialAuthOutgoing:
86 case DRSUAPI_ATTRIBUTE_initialAuthIncoming:
87 break;
88 default:
89 return raw_data;
92 out_data = decrypt_drsuapi_blob(mem_ctx, session_key, rcrypt,
93 rid, raw_data);
95 if (out_data.length) {
96 return (DATA_BLOB *)talloc_memdup(mem_ctx, &out_data, sizeof(DATA_BLOB));
99 return raw_data;
102 /****************************************************************
103 ****************************************************************/
105 static void parse_obj_identifier(struct drsuapi_DsReplicaObjectIdentifier *id,
106 uint32_t *rid)
108 if (!id || !rid) {
109 return;
112 *rid = 0;
114 if (id->sid.num_auths > 0) {
115 *rid = id->sid.sub_auths[id->sid.num_auths - 1];
119 /****************************************************************
120 ****************************************************************/
122 static void parse_obj_attribute(TALLOC_CTX *mem_ctx,
123 DATA_BLOB *session_key,
124 uint32_t rid,
125 struct drsuapi_DsReplicaAttribute *attr)
127 int i = 0;
129 for (i=0; i<attr->value_ctr.num_values; i++) {
131 DATA_BLOB *plain_data = NULL;
133 plain_data = decrypt_attr_val(mem_ctx,
134 session_key,
135 rid,
136 attr->attid,
137 attr->value_ctr.values[i].blob);
139 attr->value_ctr.values[i].blob = plain_data;
143 /****************************************************************
144 ****************************************************************/
146 static void libnet_dssync_decrypt_attributes(TALLOC_CTX *mem_ctx,
147 DATA_BLOB *session_key,
148 struct drsuapi_DsReplicaObjectListItemEx *cur)
150 for (; cur; cur = cur->next_object) {
152 uint32_t i;
153 uint32_t rid = 0;
155 parse_obj_identifier(cur->object.identifier, &rid);
157 for (i=0; i < cur->object.attribute_ctr.num_attributes; i++) {
159 struct drsuapi_DsReplicaAttribute *attr;
161 attr = &cur->object.attribute_ctr.attributes[i];
163 if (attr->value_ctr.num_values < 1) {
164 continue;
167 if (!attr->value_ctr.values[0].blob) {
168 continue;
171 parse_obj_attribute(mem_ctx,
172 session_key,
173 rid,
174 attr);
178 /****************************************************************
179 ****************************************************************/
181 static NTSTATUS libnet_dssync_bind(TALLOC_CTX *mem_ctx,
182 struct dssync_context *ctx)
184 NTSTATUS status;
185 WERROR werr;
187 struct GUID bind_guid;
188 struct drsuapi_DsBindInfoCtr bind_info;
189 struct drsuapi_DsBindInfo28 info28;
191 ZERO_STRUCT(info28);
193 GUID_from_string(DRSUAPI_DS_BIND_GUID, &bind_guid);
195 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_BASE;
196 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ASYNC_REPLICATION;
197 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_REMOVEAPI;
198 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_MOVEREQ_V2;
199 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHG_COMPRESS;
200 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V1;
201 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_RESTORE_USN_OPTIMIZATION;
202 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_KCC_EXECUTE;
203 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRY_V2;
204 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_LINKED_VALUE_REPLICATION;
205 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V2;
206 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD;
207 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_CRYPTO_BIND;
208 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GET_REPL_INFO;
209 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_STRONG_ENCRYPTION;
210 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V01;
211 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_TRANSITIVE_MEMBERSHIP;
212 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ADD_SID_HISTORY;
213 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_POST_BETA3;
214 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GET_MEMBERSHIPS2;
215 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V6;
216 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_NONDOMAIN_NCS;
217 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8;
218 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V5;
219 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V6;
220 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRYREPLY_V3;
221 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V7;
222 info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_VERIFY_OBJECT;
223 info28.site_guid = GUID_zero();
224 info28.pid = 508;
225 info28.repl_epoch = 0;
227 bind_info.length = 28;
228 bind_info.info.info28 = info28;
230 status = rpccli_drsuapi_DsBind(ctx->cli, mem_ctx,
231 &bind_guid,
232 &bind_info,
233 &ctx->bind_handle,
234 &werr);
236 if (!NT_STATUS_IS_OK(status)) {
237 return status;
240 if (!W_ERROR_IS_OK(werr)) {
241 return werror_to_ntstatus(werr);
244 ZERO_STRUCT(ctx->remote_info28);
245 switch (bind_info.length) {
246 case 24: {
247 struct drsuapi_DsBindInfo24 *info24;
248 info24 = &bind_info.info.info24;
249 ctx->remote_info28.site_guid = info24->site_guid;
250 ctx->remote_info28.supported_extensions = info24->supported_extensions;
251 ctx->remote_info28.pid = info24->pid;
252 ctx->remote_info28.repl_epoch = 0;
253 break;
255 case 28:
256 ctx->remote_info28 = bind_info.info.info28;
257 break;
258 case 48: {
259 struct drsuapi_DsBindInfo48 *info48;
260 info48 = &bind_info.info.info48;
261 ctx->remote_info28.site_guid = info48->site_guid;
262 ctx->remote_info28.supported_extensions = info48->supported_extensions;
263 ctx->remote_info28.pid = info48->pid;
264 ctx->remote_info28.repl_epoch = info48->repl_epoch;
265 break;
267 default:
268 DEBUG(1, ("Warning: invalid info length in bind info: %d\n",
269 bind_info.length));
270 break;
273 return status;
276 /****************************************************************
277 ****************************************************************/
279 static NTSTATUS libnet_dssync_lookup_nc(TALLOC_CTX *mem_ctx,
280 struct dssync_context *ctx)
282 NTSTATUS status;
283 WERROR werr;
284 int32_t level = 1;
285 union drsuapi_DsNameRequest req;
286 int32_t level_out;
287 struct drsuapi_DsNameString names[1];
288 union drsuapi_DsNameCtr ctr;
290 names[0].str = talloc_asprintf(mem_ctx, "%s\\", ctx->domain_name);
291 NT_STATUS_HAVE_NO_MEMORY(names[0].str);
293 req.req1.codepage = 1252; /* german */
294 req.req1.language = 0x00000407; /* german */
295 req.req1.count = 1;
296 req.req1.names = names;
297 req.req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS;
298 req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_UKNOWN;
299 req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
301 status = rpccli_drsuapi_DsCrackNames(ctx->cli, mem_ctx,
302 &ctx->bind_handle,
303 level,
304 &req,
305 &level_out,
306 &ctr,
307 &werr);
308 if (!NT_STATUS_IS_OK(status)) {
309 ctx->error_message = talloc_asprintf(mem_ctx,
310 "Failed to lookup DN for domain name: %s",
311 get_friendly_werror_msg(werr));
312 return status;
315 if (!W_ERROR_IS_OK(werr)) {
316 return werror_to_ntstatus(werr);
319 if (ctr.ctr1->count != 1) {
320 return NT_STATUS_UNSUCCESSFUL;
323 if (ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
324 return NT_STATUS_UNSUCCESSFUL;
327 ctx->nc_dn = talloc_strdup(mem_ctx, ctr.ctr1->array[0].result_name);
328 NT_STATUS_HAVE_NO_MEMORY(ctx->nc_dn);
330 if (!ctx->dns_domain_name) {
331 ctx->dns_domain_name = talloc_strdup_upper(mem_ctx,
332 ctr.ctr1->array[0].dns_domain_name);
333 NT_STATUS_HAVE_NO_MEMORY(ctx->dns_domain_name);
336 return NT_STATUS_OK;
339 /****************************************************************
340 ****************************************************************/
342 static NTSTATUS libnet_dssync_init(TALLOC_CTX *mem_ctx,
343 struct dssync_context *ctx)
345 NTSTATUS status;
347 status = libnet_dssync_bind(mem_ctx, ctx);
348 if (!NT_STATUS_IS_OK(status)) {
349 return status;
352 if (!ctx->nc_dn) {
353 status = libnet_dssync_lookup_nc(mem_ctx, ctx);
356 return status;
359 /****************************************************************
360 ****************************************************************/
362 static NTSTATUS libnet_dssync_build_request(TALLOC_CTX *mem_ctx,
363 struct dssync_context *ctx,
364 const char *dn,
365 struct replUpToDateVectorBlob *utdv,
366 int32_t level,
367 union drsuapi_DsGetNCChangesRequest *preq)
369 NTSTATUS status;
370 uint32_t count;
371 union drsuapi_DsGetNCChangesRequest req;
372 struct dom_sid null_sid;
373 enum drsuapi_DsExtendedOperation extended_op;
374 struct drsuapi_DsReplicaObjectIdentifier *nc = NULL;
375 struct drsuapi_DsReplicaCursorCtrEx *cursors = NULL;
377 uint32_t replica_flags = DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE |
378 DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP |
379 DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS |
380 DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS |
381 DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED;
383 ZERO_STRUCT(null_sid);
384 ZERO_STRUCT(req);
386 nc = TALLOC_ZERO_P(mem_ctx, struct drsuapi_DsReplicaObjectIdentifier);
387 if (!nc) {
388 status = NT_STATUS_NO_MEMORY;
389 goto fail;
391 nc->dn = dn;
392 nc->guid = GUID_zero();
393 nc->sid = null_sid;
395 if (!ctx->repl_nodiff && utdv) {
396 cursors = TALLOC_ZERO_P(mem_ctx,
397 struct drsuapi_DsReplicaCursorCtrEx);
398 if (!cursors) {
399 status = NT_STATUS_NO_MEMORY;
400 goto fail;
403 switch (utdv->version) {
404 case 1:
405 cursors->count = utdv->ctr.ctr1.count;
406 cursors->cursors = utdv->ctr.ctr1.cursors;
407 break;
408 case 2:
409 cursors->count = utdv->ctr.ctr2.count;
410 cursors->cursors = talloc_array(cursors,
411 struct drsuapi_DsReplicaCursor,
412 cursors->count);
413 if (!cursors->cursors) {
414 status = NT_STATUS_NO_MEMORY;
415 goto fail;
417 for (count = 0; count < cursors->count; count++) {
418 cursors->cursors[count].source_dsa_invocation_id =
419 utdv->ctr.ctr2.cursors[count].source_dsa_invocation_id;
420 cursors->cursors[count].highest_usn =
421 utdv->ctr.ctr2.cursors[count].highest_usn;
423 break;
427 if (ctx->single) {
428 extended_op = DRSUAPI_EXOP_REPL_OBJ;
429 } else {
430 extended_op = DRSUAPI_EXOP_NONE;
433 if (level == 8) {
434 req.req8.naming_context = nc;
435 req.req8.replica_flags = replica_flags;
436 req.req8.max_object_count = 402;
437 req.req8.max_ndr_size = 402116;
438 req.req8.uptodateness_vector = cursors;
439 req.req8.extended_op = extended_op;
440 } else if (level == 5) {
441 req.req5.naming_context = nc;
442 req.req5.replica_flags = replica_flags;
443 req.req5.max_object_count = 402;
444 req.req5.max_ndr_size = 402116;
445 req.req5.uptodateness_vector = cursors;
446 req.req5.extended_op = extended_op;
447 } else {
448 status = NT_STATUS_INVALID_PARAMETER;
449 goto fail;
452 if (preq) {
453 *preq = req;
456 return NT_STATUS_OK;
458 fail:
459 TALLOC_FREE(nc);
460 TALLOC_FREE(cursors);
461 return status;
464 static NTSTATUS libnet_dssync_process(TALLOC_CTX *mem_ctx,
465 struct dssync_context *ctx)
467 NTSTATUS status;
468 WERROR werr;
470 int32_t level;
471 int32_t level_out = 0;
472 union drsuapi_DsGetNCChangesRequest req;
473 union drsuapi_DsGetNCChangesCtr ctr;
475 struct drsuapi_DsGetNCChangesCtr1 *ctr1 = NULL;
476 struct drsuapi_DsGetNCChangesCtr6 *ctr6 = NULL;
477 struct replUpToDateVectorBlob *old_utdv = NULL;
478 struct replUpToDateVectorBlob new_utdv;
479 struct replUpToDateVectorBlob *pnew_utdv = NULL;
480 int32_t out_level = 0;
481 int y;
482 const char *dn;
484 status = ctx->ops->startup(ctx, mem_ctx, &old_utdv);
485 if (!NT_STATUS_IS_OK(status)) {
486 ctx->error_message = talloc_asprintf(mem_ctx,
487 "Failed to call startup operation: %s",
488 nt_errstr(status));
489 goto out;
492 if (ctx->remote_info28.supported_extensions
493 & DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8)
495 level = 8;
496 } else {
497 level = 5;
500 if (ctx->single && ctx->object_dn) {
501 dn = ctx->object_dn;
502 } else {
503 dn = ctx->nc_dn;
506 status = libnet_dssync_build_request(mem_ctx, ctx, dn, old_utdv, level,
507 &req);
508 if (!NT_STATUS_IS_OK(status)) {
509 ctx->error_message = talloc_asprintf(mem_ctx,
510 "Failed to build DsGetNCChanges request: %s",
511 nt_errstr(status));
512 goto out;
515 if (!ctx->single) {
516 pnew_utdv = &new_utdv;
519 for (y=0; ;y++) {
521 bool last_query = true;
523 if (level == 8) {
524 DEBUG(1,("start[%d] tmp_higest_usn: %llu , highest_usn: %llu\n",y,
525 (long long)req.req8.highwatermark.tmp_highest_usn,
526 (long long)req.req8.highwatermark.highest_usn));
527 } else if (level == 5) {
528 DEBUG(1,("start[%d] tmp_higest_usn: %llu , highest_usn: %llu\n",y,
529 (long long)req.req5.highwatermark.tmp_highest_usn,
530 (long long)req.req5.highwatermark.highest_usn));
533 status = rpccli_drsuapi_DsGetNCChanges(ctx->cli, mem_ctx,
534 &ctx->bind_handle,
535 level,
536 &req,
537 &level_out,
538 &ctr,
539 &werr);
540 if (!NT_STATUS_IS_OK(status)) {
541 ctx->error_message = talloc_asprintf(mem_ctx,
542 "Failed to get NC Changes: %s",
543 get_friendly_werror_msg(werr));
544 goto out;
547 if (!W_ERROR_IS_OK(werr)) {
548 status = werror_to_ntstatus(werr);
549 goto out;
552 if (level_out == 1) {
553 out_level = 1;
554 ctr1 = &ctr.ctr1;
555 } else if (level_out == 2) {
556 out_level = 1;
557 ctr1 = ctr.ctr2.ctr.mszip1.ctr1;
560 status = cli_get_session_key(mem_ctx, ctx->cli, &ctx->session_key);
561 if (!NT_STATUS_IS_OK(status)) {
562 ctx->error_message = talloc_asprintf(mem_ctx,
563 "Failed to get Session Key: %s",
564 nt_errstr(status));
565 return status;
568 if (out_level == 1) {
569 DEBUG(1,("end[%d] tmp_highest_usn: %llu , highest_usn: %llu\n",y,
570 (long long)ctr1->new_highwatermark.tmp_highest_usn,
571 (long long)ctr1->new_highwatermark.highest_usn));
573 libnet_dssync_decrypt_attributes(mem_ctx,
574 &ctx->session_key,
575 ctr1->first_object);
577 if (ctr1->more_data) {
578 req.req5.highwatermark = ctr1->new_highwatermark;
579 last_query = false;
582 if (ctx->ops->process_objects) {
583 status = ctx->ops->process_objects(ctx, mem_ctx,
584 ctr1->first_object,
585 &ctr1->mapping_ctr);
586 if (!NT_STATUS_IS_OK(status)) {
587 ctx->error_message = talloc_asprintf(mem_ctx,
588 "Failed to call processing function: %s",
589 nt_errstr(status));
590 goto out;
594 if (!last_query) {
595 continue;
598 ZERO_STRUCT(new_utdv);
599 new_utdv.version = 1;
600 if (ctr1->uptodateness_vector) {
601 new_utdv.ctr.ctr1.count = ctr1->uptodateness_vector->count;
602 new_utdv.ctr.ctr1.cursors = ctr1->uptodateness_vector->cursors;
606 if (level_out == 6) {
607 out_level = 6;
608 ctr6 = &ctr.ctr6;
609 } else if (level_out == 7
610 && ctr.ctr7.level == 6
611 && ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP) {
612 out_level = 6;
613 ctr6 = ctr.ctr7.ctr.mszip6.ctr6;
616 if (out_level == 6) {
617 DEBUG(1,("end[%d] tmp_highest_usn: %llu , highest_usn: %llu\n",y,
618 (long long)ctr6->new_highwatermark.tmp_highest_usn,
619 (long long)ctr6->new_highwatermark.highest_usn));
621 libnet_dssync_decrypt_attributes(mem_ctx,
622 &ctx->session_key,
623 ctr6->first_object);
625 if (ctr6->more_data) {
626 req.req8.highwatermark = ctr6->new_highwatermark;
627 last_query = false;
630 if (ctx->ops->process_objects) {
631 status = ctx->ops->process_objects(ctx, mem_ctx,
632 ctr6->first_object,
633 &ctr6->mapping_ctr);
634 if (!NT_STATUS_IS_OK(status)) {
635 ctx->error_message = talloc_asprintf(mem_ctx,
636 "Failed to call processing function: %s",
637 nt_errstr(status));
638 goto out;
642 if (!last_query) {
643 continue;
646 ZERO_STRUCT(new_utdv);
647 new_utdv.version = 2;
648 if (ctr6->uptodateness_vector) {
649 new_utdv.ctr.ctr2.count = ctr6->uptodateness_vector->count;
650 new_utdv.ctr.ctr2.cursors = ctr6->uptodateness_vector->cursors;
654 status = ctx->ops->finish(ctx, mem_ctx, pnew_utdv);
655 if (!NT_STATUS_IS_OK(status)) {
656 ctx->error_message = talloc_asprintf(mem_ctx,
657 "Failed to call finishing operation: %s",
658 nt_errstr(status));
659 goto out;
662 break;
665 out:
666 return status;
669 /****************************************************************
670 ****************************************************************/
672 NTSTATUS libnet_dssync(TALLOC_CTX *mem_ctx,
673 struct dssync_context *ctx)
675 NTSTATUS status;
677 status = libnet_dssync_init(mem_ctx, ctx);
678 if (!NT_STATUS_IS_OK(status)) {
679 goto out;
682 status = libnet_dssync_process(mem_ctx, ctx);
683 if (!NT_STATUS_IS_OK(status)) {
684 goto out;
687 out:
688 return status;