s3: reduce db_ctdb_marshall_loop_next to specialized db_ctdb_marshall_buf_parse
[Samba/gbeck.git] / source3 / rpc_client / cli_lsarpc.c
blobc6e402d6edd8b3ead642c925ee44a45ef9beeeb7
1 /*
2 Unix SMB/CIFS implementation.
3 RPC pipe client
4 Copyright (C) Tim Potter 2000-2001,
5 Copyright (C) Andrew Tridgell 1992-1997,2000,
6 Copyright (C) Rafal Szczesniak 2002
7 Copyright (C) Jeremy Allison 2005.
8 Copyright (C) Michael Adam 2007.
9 Copyright (C) Guenther Deschner 2008.
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include "includes.h"
26 #include "rpc_client/rpc_client.h"
27 #include "../librpc/gen_ndr/ndr_lsa_c.h"
28 #include "rpc_client/cli_lsarpc.h"
29 #include "rpc_client/init_lsa.h"
30 #include "../libcli/security/security.h"
32 /** @defgroup lsa LSA - Local Security Architecture
33 * @ingroup rpc_client
35 * @{
36 **/
38 /**
39 * @file cli_lsarpc.c
41 * RPC client routines for the LSA RPC pipe. LSA means "local
42 * security authority", which is half of a password database.
43 **/
45 NTSTATUS dcerpc_lsa_open_policy(struct dcerpc_binding_handle *h,
46 TALLOC_CTX *mem_ctx,
47 bool sec_qos,
48 uint32_t des_access,
49 struct policy_handle *pol,
50 NTSTATUS *result)
52 struct lsa_ObjectAttribute attr;
53 struct lsa_QosInfo qos;
54 uint16_t system_name = '\\';
56 ZERO_STRUCT(attr);
58 attr.len = 0x18;
60 if (sec_qos) {
61 qos.len = 0xc;
62 qos.impersonation_level = 2;
63 qos.context_mode = 1;
64 qos.effective_only = 0;
66 attr.sec_qos = &qos;
69 return dcerpc_lsa_OpenPolicy(h,
70 mem_ctx,
71 &system_name,
72 &attr,
73 des_access,
74 pol,
75 result);
78 /** Open a LSA policy handle
80 * @param cli Handle on an initialised SMB connection */
82 NTSTATUS rpccli_lsa_open_policy(struct rpc_pipe_client *cli,
83 TALLOC_CTX *mem_ctx,
84 bool sec_qos, uint32 des_access,
85 struct policy_handle *pol)
87 NTSTATUS status;
88 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
90 status = dcerpc_lsa_open_policy(cli->binding_handle,
91 mem_ctx,
92 sec_qos,
93 des_access,
94 pol,
95 &result);
96 if (!NT_STATUS_IS_OK(status)) {
97 return status;
100 return result;
103 NTSTATUS dcerpc_lsa_open_policy2(struct dcerpc_binding_handle *h,
104 TALLOC_CTX *mem_ctx,
105 const char *srv_name_slash,
106 bool sec_qos,
107 uint32_t des_access,
108 struct policy_handle *pol,
109 NTSTATUS *result)
111 struct lsa_ObjectAttribute attr;
112 struct lsa_QosInfo qos;
114 ZERO_STRUCT(attr);
116 attr.len = 0x18;
118 if (sec_qos) {
119 qos.len = 0xc;
120 qos.impersonation_level = 2;
121 qos.context_mode = 1;
122 qos.effective_only = 0;
124 attr.sec_qos = &qos;
127 return dcerpc_lsa_OpenPolicy2(h,
128 mem_ctx,
129 srv_name_slash,
130 &attr,
131 des_access,
132 pol,
133 result);
136 /** Open a LSA policy handle
138 * @param cli Handle on an initialised SMB connection
141 NTSTATUS rpccli_lsa_open_policy2(struct rpc_pipe_client *cli,
142 TALLOC_CTX *mem_ctx, bool sec_qos,
143 uint32 des_access, struct policy_handle *pol)
145 NTSTATUS status;
146 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
148 status = dcerpc_lsa_open_policy2(cli->binding_handle,
149 mem_ctx,
150 cli->srv_name_slash,
151 sec_qos,
152 des_access,
153 pol,
154 &result);
155 if (!NT_STATUS_IS_OK(status)) {
156 return status;
159 return result;
162 /* Lookup a list of sids
164 * internal version withOUT memory allocation of the target arrays.
165 * this assumes sufficiently sized arrays to store domains, names and types. */
167 static NTSTATUS dcerpc_lsa_lookup_sids_noalloc(struct dcerpc_binding_handle *h,
168 TALLOC_CTX *mem_ctx,
169 TALLOC_CTX *domains_ctx,
170 TALLOC_CTX *names_ctx,
171 struct policy_handle *pol,
172 int num_sids,
173 const struct dom_sid *sids,
174 char **domains,
175 char **names,
176 enum lsa_SidType *types,
177 bool use_lookupsids3,
178 NTSTATUS *presult)
180 NTSTATUS status = NT_STATUS_OK;
181 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
182 struct lsa_SidArray sid_array;
183 struct lsa_RefDomainList *ref_domains = NULL;
184 struct lsa_TransNameArray lsa_names;
185 enum lsa_LookupNamesLevel level = LSA_LOOKUP_NAMES_ALL;
186 uint32_t count = 0;
187 int i;
189 ZERO_STRUCT(lsa_names);
191 sid_array.num_sids = num_sids;
192 sid_array.sids = talloc_array(mem_ctx, struct lsa_SidPtr, num_sids);
193 if (sid_array.sids == NULL) {
194 return NT_STATUS_NO_MEMORY;
197 for (i = 0; i<num_sids; i++) {
198 sid_array.sids[i].sid = dom_sid_dup(mem_ctx, &sids[i]);
199 if (!sid_array.sids[i].sid) {
200 return NT_STATUS_NO_MEMORY;
204 if (use_lookupsids3) {
205 struct lsa_TransNameArray2 lsa_names2;
206 uint32_t n;
208 ZERO_STRUCT(lsa_names2);
210 status = dcerpc_lsa_LookupSids3(h,
211 mem_ctx,
212 &sid_array,
213 &ref_domains,
214 &lsa_names2,
215 level,
216 &count,
217 LSA_LOOKUP_OPTION_SEARCH_ISOLATED_NAMES,
218 LSA_CLIENT_REVISION_2,
219 &result);
220 if (!NT_STATUS_IS_OK(status)) {
221 return status;
224 if(!NT_STATUS_IS_ERR(result)) {
225 lsa_names.count = lsa_names2.count;
226 lsa_names.names = talloc_array(mem_ctx,
227 struct lsa_TranslatedName,
228 lsa_names.count);
229 if (lsa_names.names == NULL) {
230 return NT_STATUS_NO_MEMORY;
232 for (n=0; n < lsa_names.count; n++) {
233 lsa_names.names[n].sid_type = lsa_names2.names[n].sid_type;
234 lsa_names.names[n].name = lsa_names2.names[n].name;
235 lsa_names.names[n].sid_index = lsa_names2.names[n].sid_index;
239 } else {
240 status = dcerpc_lsa_LookupSids(h,
241 mem_ctx,
242 pol,
243 &sid_array,
244 &ref_domains,
245 &lsa_names,
246 level,
247 &count,
248 &result);
251 DEBUG(10, ("LSA_LOOKUPSIDS returned status: '%s', result: '%s', "
252 "mapped count = %d'\n",
253 nt_errstr(status), nt_errstr(result), count));
255 if (!NT_STATUS_IS_OK(status)) {
256 return status;
259 if (!NT_STATUS_IS_OK(result) &&
260 !NT_STATUS_EQUAL(result, NT_STATUS_NONE_MAPPED) &&
261 !NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED))
263 *presult = result;
264 return status;
267 /* Return output parameters */
268 if (NT_STATUS_EQUAL(result, NT_STATUS_NONE_MAPPED) ||
269 (count == 0))
271 for (i = 0; i < num_sids; i++) {
272 (names)[i] = NULL;
273 (domains)[i] = NULL;
274 (types)[i] = SID_NAME_UNKNOWN;
276 *presult = NT_STATUS_NONE_MAPPED;
277 return status;
280 for (i = 0; i < num_sids; i++) {
281 const char *name, *dom_name;
282 uint32_t dom_idx = lsa_names.names[i].sid_index;
284 /* Translate optimised name through domain index array */
286 if (dom_idx != 0xffffffff) {
288 dom_name = ref_domains->domains[dom_idx].name.string;
289 name = lsa_names.names[i].name.string;
291 if (name) {
292 (names)[i] = talloc_strdup(names_ctx, name);
293 if ((names)[i] == NULL) {
294 DEBUG(0, ("cli_lsa_lookup_sids_noalloc(): out of memory\n"));
295 *presult = NT_STATUS_UNSUCCESSFUL;
296 return status;
298 } else {
299 (names)[i] = NULL;
301 domains[i] = talloc_strdup(domains_ctx,
302 dom_name ? dom_name : "");
303 (types)[i] = lsa_names.names[i].sid_type;
304 if ((domains)[i] == NULL) {
305 DEBUG(0, ("cli_lsa_lookup_sids_noalloc(): out of memory\n"));
306 *presult = NT_STATUS_UNSUCCESSFUL;
307 return status;
310 } else {
311 (names)[i] = NULL;
312 (domains)[i] = NULL;
313 (types)[i] = SID_NAME_UNKNOWN;
317 *presult = NT_STATUS_OK;
318 return status;
321 /* Lookup a list of sids
323 * do it the right way: there is a limit (of 20480 for w2k3) entries
324 * returned by this call. when the sids list contains more entries,
325 * empty lists are returned. This version of lsa_lookup_sids passes
326 * the list of sids in hunks of LOOKUP_SIDS_HUNK_SIZE to the lsa call. */
328 /* This constant defines the limit of how many sids to look up
329 * in one call (maximum). the limit from the server side is
330 * at 20480 for win2k3, but we keep it at a save 1000 for now. */
331 #define LOOKUP_SIDS_HUNK_SIZE 1000
333 static NTSTATUS dcerpc_lsa_lookup_sids_generic(struct dcerpc_binding_handle *h,
334 TALLOC_CTX *mem_ctx,
335 struct policy_handle *pol,
336 int num_sids,
337 const struct dom_sid *sids,
338 char ***pdomains,
339 char ***pnames,
340 enum lsa_SidType **ptypes,
341 bool use_lookupsids3,
342 NTSTATUS *presult)
344 NTSTATUS status = NT_STATUS_OK;
345 NTSTATUS result = NT_STATUS_OK;
346 int sids_left = 0;
347 int sids_processed = 0;
348 const struct dom_sid *hunk_sids = sids;
349 char **hunk_domains;
350 char **hunk_names;
351 enum lsa_SidType *hunk_types;
352 char **domains = NULL;
353 char **names = NULL;
354 enum lsa_SidType *types = NULL;
355 bool have_mapped = false;
356 bool have_unmapped = false;
358 if (num_sids) {
359 if (!(domains = talloc_array(mem_ctx, char *, num_sids))) {
360 DEBUG(0, ("rpccli_lsa_lookup_sids(): out of memory\n"));
361 status = NT_STATUS_NO_MEMORY;
362 goto fail;
365 if (!(names = talloc_array(mem_ctx, char *, num_sids))) {
366 DEBUG(0, ("rpccli_lsa_lookup_sids(): out of memory\n"));
367 status = NT_STATUS_NO_MEMORY;
368 goto fail;
371 if (!(types = talloc_array(mem_ctx, enum lsa_SidType, num_sids))) {
372 DEBUG(0, ("rpccli_lsa_lookup_sids(): out of memory\n"));
373 status = NT_STATUS_NO_MEMORY;
374 goto fail;
378 sids_left = num_sids;
379 hunk_domains = domains;
380 hunk_names = names;
381 hunk_types = types;
383 while (sids_left > 0) {
384 int hunk_num_sids;
385 NTSTATUS hunk_result = NT_STATUS_UNSUCCESSFUL;
387 hunk_num_sids = ((sids_left > LOOKUP_SIDS_HUNK_SIZE)
388 ? LOOKUP_SIDS_HUNK_SIZE
389 : sids_left);
391 DEBUG(10, ("rpccli_lsa_lookup_sids: processing items "
392 "%d -- %d of %d.\n",
393 sids_processed,
394 sids_processed + hunk_num_sids - 1,
395 num_sids));
397 status = dcerpc_lsa_lookup_sids_noalloc(h,
398 mem_ctx,
399 (TALLOC_CTX *)domains,
400 (TALLOC_CTX *)names,
401 pol,
402 hunk_num_sids,
403 hunk_sids,
404 hunk_domains,
405 hunk_names,
406 hunk_types,
407 use_lookupsids3,
408 &hunk_result);
409 if (!NT_STATUS_IS_OK(status)) {
410 goto fail;
413 if (!NT_STATUS_IS_OK(hunk_result) &&
414 !NT_STATUS_EQUAL(hunk_result, STATUS_SOME_UNMAPPED) &&
415 !NT_STATUS_EQUAL(hunk_result, NT_STATUS_NONE_MAPPED))
417 /* An actual error occured */
418 *presult = hunk_result;
419 goto fail;
422 if (NT_STATUS_IS_OK(hunk_result)) {
423 have_mapped = true;
425 if (NT_STATUS_EQUAL(hunk_result, NT_STATUS_NONE_MAPPED)) {
426 have_unmapped = true;
428 if (NT_STATUS_EQUAL(hunk_result, STATUS_SOME_UNMAPPED)) {
429 int i;
430 for (i=0; i<hunk_num_sids; i++) {
431 if (hunk_types[i] == SID_NAME_UNKNOWN) {
432 have_unmapped = true;
433 } else {
434 have_mapped = true;
439 sids_left -= hunk_num_sids;
440 sids_processed += hunk_num_sids;
441 hunk_sids += hunk_num_sids;
442 hunk_domains += hunk_num_sids;
443 hunk_names += hunk_num_sids;
444 hunk_types += hunk_num_sids;
447 *pdomains = domains;
448 *pnames = names;
449 *ptypes = types;
451 if (!have_mapped) {
452 result = NT_STATUS_NONE_MAPPED;
454 if (have_unmapped) {
455 result = STATUS_SOME_UNMAPPED;
457 *presult = result;
459 return status;
461 fail:
462 TALLOC_FREE(domains);
463 TALLOC_FREE(names);
464 TALLOC_FREE(types);
466 return status;
469 NTSTATUS dcerpc_lsa_lookup_sids(struct dcerpc_binding_handle *h,
470 TALLOC_CTX *mem_ctx,
471 struct policy_handle *pol,
472 int num_sids,
473 const struct dom_sid *sids,
474 char ***pdomains,
475 char ***pnames,
476 enum lsa_SidType **ptypes,
477 NTSTATUS *result)
479 return dcerpc_lsa_lookup_sids_generic(h,
480 mem_ctx,
481 pol,
482 num_sids,
483 sids,
484 pdomains,
485 pnames,
486 ptypes,
487 false,
488 result);
491 NTSTATUS rpccli_lsa_lookup_sids(struct rpc_pipe_client *cli,
492 TALLOC_CTX *mem_ctx,
493 struct policy_handle *pol,
494 int num_sids,
495 const struct dom_sid *sids,
496 char ***pdomains,
497 char ***pnames,
498 enum lsa_SidType **ptypes)
500 NTSTATUS status;
501 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
503 status = dcerpc_lsa_lookup_sids_generic(cli->binding_handle,
504 mem_ctx,
505 pol,
506 num_sids,
507 sids,
508 pdomains,
509 pnames,
510 ptypes,
511 false,
512 &result);
513 if (!NT_STATUS_IS_OK(status)) {
514 return status;
517 return result;
520 NTSTATUS dcerpc_lsa_lookup_sids3(struct dcerpc_binding_handle *h,
521 TALLOC_CTX *mem_ctx,
522 struct policy_handle *pol,
523 int num_sids,
524 const struct dom_sid *sids,
525 char ***pdomains,
526 char ***pnames,
527 enum lsa_SidType **ptypes,
528 NTSTATUS *result)
530 return dcerpc_lsa_lookup_sids_generic(h,
531 mem_ctx,
532 pol,
533 num_sids,
534 sids,
535 pdomains,
536 pnames,
537 ptypes,
538 true,
539 result);
542 NTSTATUS rpccli_lsa_lookup_sids3(struct rpc_pipe_client *cli,
543 TALLOC_CTX *mem_ctx,
544 struct policy_handle *pol,
545 int num_sids,
546 const struct dom_sid *sids,
547 char ***pdomains,
548 char ***pnames,
549 enum lsa_SidType **ptypes)
551 NTSTATUS status;
552 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
554 status = dcerpc_lsa_lookup_sids_generic(cli->binding_handle,
555 mem_ctx,
556 pol,
557 num_sids,
558 sids,
559 pdomains,
560 pnames,
561 ptypes,
562 true,
563 &result);
564 if (!NT_STATUS_IS_OK(status)) {
565 return status;
568 return result;
571 /** Lookup a list of names */
573 static NTSTATUS dcerpc_lsa_lookup_names_generic(struct dcerpc_binding_handle *h,
574 TALLOC_CTX *mem_ctx,
575 struct policy_handle *pol,
576 uint32_t num_names,
577 const char **names,
578 const char ***dom_names,
579 enum lsa_LookupNamesLevel level,
580 struct dom_sid **sids,
581 enum lsa_SidType **types,
582 bool use_lookupnames4,
583 NTSTATUS *presult)
585 NTSTATUS status;
586 struct lsa_String *lsa_names = NULL;
587 struct lsa_RefDomainList *domains = NULL;
588 struct lsa_TransSidArray sid_array;
589 struct lsa_TransSidArray3 sid_array3;
590 uint32_t count = 0;
591 uint32_t i;
593 ZERO_STRUCT(sid_array);
594 ZERO_STRUCT(sid_array3);
596 lsa_names = talloc_array(mem_ctx, struct lsa_String, num_names);
597 if (lsa_names == NULL) {
598 return NT_STATUS_NO_MEMORY;
601 for (i = 0; i < num_names; i++) {
602 init_lsa_String(&lsa_names[i], names[i]);
605 if (use_lookupnames4) {
606 status = dcerpc_lsa_LookupNames4(h,
607 mem_ctx,
608 num_names,
609 lsa_names,
610 &domains,
611 &sid_array3,
612 level,
613 &count,
614 LSA_LOOKUP_OPTION_SEARCH_ISOLATED_NAMES,
615 LSA_CLIENT_REVISION_2,
616 presult);
617 } else {
618 status = dcerpc_lsa_LookupNames(h,
619 mem_ctx,
620 pol,
621 num_names,
622 lsa_names,
623 &domains,
624 &sid_array,
625 level,
626 &count,
627 presult);
629 if (!NT_STATUS_IS_OK(status)) {
630 goto done;
633 if (!NT_STATUS_IS_OK(*presult) &&
634 !NT_STATUS_EQUAL(*presult, STATUS_SOME_UNMAPPED)) {
635 /* An actual error occured */
636 goto done;
639 /* Return output parameters */
640 if (count == 0) {
641 *presult = NT_STATUS_NONE_MAPPED;
642 goto done;
645 if (num_names) {
646 if (!((*sids = talloc_array(mem_ctx, struct dom_sid, num_names)))) {
647 DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
648 *presult = NT_STATUS_NO_MEMORY;
649 goto done;
652 if (!((*types = talloc_array(mem_ctx, enum lsa_SidType, num_names)))) {
653 DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
654 *presult = NT_STATUS_NO_MEMORY;
655 goto done;
658 if (dom_names != NULL) {
659 *dom_names = talloc_array(mem_ctx, const char *, num_names);
660 if (*dom_names == NULL) {
661 DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
662 *presult = NT_STATUS_NO_MEMORY;
663 goto done;
666 } else {
667 *sids = NULL;
668 *types = NULL;
669 if (dom_names != NULL) {
670 *dom_names = NULL;
674 for (i = 0; i < num_names; i++) {
675 uint32_t dom_idx;
676 struct dom_sid *sid = &(*sids)[i];
678 if (use_lookupnames4) {
679 dom_idx = sid_array3.sids[i].sid_index;
680 (*types)[i] = sid_array3.sids[i].sid_type;
681 } else {
682 dom_idx = sid_array.sids[i].sid_index;
683 (*types)[i] = sid_array.sids[i].sid_type;
686 /* Translate optimised sid through domain index array */
688 if (dom_idx == 0xffffffff) {
689 /* Nothing to do, this is unknown */
690 ZERO_STRUCTP(sid);
691 (*types)[i] = SID_NAME_UNKNOWN;
692 continue;
695 if (use_lookupnames4) {
696 sid_copy(sid, sid_array3.sids[i].sid);
697 } else {
698 sid_copy(sid, domains->domains[dom_idx].sid);
700 if (sid_array.sids[i].rid != 0xffffffff) {
701 sid_append_rid(sid, sid_array.sids[i].rid);
705 if (dom_names == NULL) {
706 continue;
709 (*dom_names)[i] = domains->domains[dom_idx].name.string;
712 done:
713 return status;
716 NTSTATUS dcerpc_lsa_lookup_names(struct dcerpc_binding_handle *h,
717 TALLOC_CTX *mem_ctx,
718 struct policy_handle *pol,
719 uint32_t num_names,
720 const char **names,
721 const char ***dom_names,
722 enum lsa_LookupNamesLevel level,
723 struct dom_sid **sids,
724 enum lsa_SidType **types,
725 NTSTATUS *result)
727 return dcerpc_lsa_lookup_names_generic(h,
728 mem_ctx,
729 pol,
730 num_names,
731 names,
732 dom_names,
733 level,
734 sids,
735 types,
736 false,
737 result);
740 NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli,
741 TALLOC_CTX *mem_ctx,
742 struct policy_handle *pol,
743 int num_names,
744 const char **names,
745 const char ***dom_names,
746 int level,
747 struct dom_sid **sids,
748 enum lsa_SidType **types)
750 NTSTATUS status;
751 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
753 status = dcerpc_lsa_lookup_names(cli->binding_handle,
754 mem_ctx,
755 pol,
756 num_names,
757 names,
758 dom_names,
759 level,
760 sids,
761 types,
762 &result);
763 if (!NT_STATUS_IS_OK(status)) {
764 return status;
767 return result;
770 NTSTATUS dcerpc_lsa_lookup_names4(struct dcerpc_binding_handle *h,
771 TALLOC_CTX *mem_ctx,
772 struct policy_handle *pol,
773 uint32_t num_names,
774 const char **names,
775 const char ***dom_names,
776 enum lsa_LookupNamesLevel level,
777 struct dom_sid **sids,
778 enum lsa_SidType **types,
779 NTSTATUS *result)
781 return dcerpc_lsa_lookup_names_generic(h,
782 mem_ctx,
783 pol,
784 num_names,
785 names,
786 dom_names,
787 level,
788 sids,
789 types,
790 true,
791 result);
794 NTSTATUS rpccli_lsa_lookup_names4(struct rpc_pipe_client *cli,
795 TALLOC_CTX *mem_ctx,
796 struct policy_handle *pol,
797 int num_names,
798 const char **names,
799 const char ***dom_names,
800 int level,
801 struct dom_sid **sids,
802 enum lsa_SidType **types)
804 NTSTATUS status;
805 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
807 status = dcerpc_lsa_lookup_names4(cli->binding_handle,
808 mem_ctx,
809 pol,
810 num_names,
811 names,
812 dom_names,
813 level,
814 sids,
815 types,
816 &result);
817 if (!NT_STATUS_IS_OK(status)) {
818 return status;
821 return result;