From 19fea3242cf6234786b6cbb60631e0071f31ff9f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 4 Sep 2001 07:13:01 +0000 Subject: the next stage in the NTSTATUS/WERROR change. smbd and nmbd now compile, but the client code still needs some work (This used to be commit dcd6e735f709a9231860ceb9682db40ff26c9a66) --- source3/libsmb/cli_lsarpc.c | 21 ++++++------ source3/libsmb/cli_reg.c | 2 +- source3/libsmb/cli_samr.c | 50 +++++++++++++++------------- source3/libsmb/cli_spoolss.c | 59 +++++++++++++++++++-------------- source3/libsmb/domain_client_validate.c | 8 ++--- 5 files changed, 77 insertions(+), 63 deletions(-) (limited to 'source3/libsmb') diff --git a/source3/libsmb/cli_lsarpc.c b/source3/libsmb/cli_lsarpc.c index 791b6eace3..f2fc167606 100644 --- a/source3/libsmb/cli_lsarpc.c +++ b/source3/libsmb/cli_lsarpc.c @@ -78,7 +78,7 @@ NTSTATUS cli_lsa_open_policy(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Return output parameters */ - if ((result = r.status) == NT_STATUS_OK) { + if (NT_STATUS_IS_OK(result = r.status)) { *pol = r.pol; } @@ -136,7 +136,7 @@ NTSTATUS cli_lsa_open_policy2(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Return output parameters */ - if ((result = r.status) == NT_STATUS_OK) { + if (NT_STATUS_IS_OK(result = r.status)) { *pol = r.pol; } @@ -184,7 +184,7 @@ NTSTATUS cli_lsa_close(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Return output parameters */ - if ((result = r.status) == NT_STATUS_OK) { + if (NT_STATUS_IS_OK(result = r.status)) { *pol = r.pol; } @@ -242,8 +242,9 @@ NTSTATUS cli_lsa_lookup_sids(struct cli_state *cli, TALLOC_CTX *mem_ctx, result = r.status; - if (result != NT_STATUS_OK && result != 0x00000107 && - result != (0xC0000000 | NT_STATUS_NONE_MAPPED)) { + if (!NT_STATUS_IS_OK(result) && + NT_STATUS_V(result) != NT_STATUS_V(NT_STATUS_FILES_OPEN) && + NT_STATUS_V(result) != NT_STATUS_V(NT_STATUS_NONE_MAPPED)) { /* An actual error occured */ @@ -347,8 +348,8 @@ NTSTATUS cli_lsa_lookup_names(struct cli_state *cli, TALLOC_CTX *mem_ctx, result = r.status; - if (result != NT_STATUS_OK && - result != (0xC0000000 | NT_STATUS_NONE_MAPPED)) { + if (!NT_STATUS_IS_OK(result) && + NT_STATUS_V(result) != NT_STATUS_V(NT_STATUS_NONE_MAPPED)) { /* An actual error occured */ @@ -441,7 +442,7 @@ NTSTATUS cli_lsa_query_info_policy(struct cli_state *cli, TALLOC_CTX *mem_ctx, goto done; } - if ((result = r.status) != NT_STATUS_OK) { + if (!NT_STATUS_IS_OK(result = r.status)) { goto done; } @@ -536,8 +537,8 @@ NTSTATUS cli_lsa_enum_trust_dom(struct cli_state *cli, TALLOC_CTX *mem_ctx, 0x8000001a (NT_STATUS_UNABLE_TO_FREE_VM) so we ignore it and pretend everything is OK. */ - if (result != NT_STATUS_OK && - result != NT_STATUS_UNABLE_TO_FREE_VM) { + if (!NT_STATUS_IS_OK(result) && + NT_STATUS_V(result) != NT_STATUS_V(NT_STATUS_UNABLE_TO_FREE_VM)) { /* An actual error ocured */ diff --git a/source3/libsmb/cli_reg.c b/source3/libsmb/cli_reg.c index 88e6d3b36d..73eea58cb7 100644 --- a/source3/libsmb/cli_reg.c +++ b/source3/libsmb/cli_reg.c @@ -47,7 +47,7 @@ NTSTATUS cli_reg_shutdown(struct cli_state * cli, TALLOC_CTX *mem_ctx, REG_R_SHUTDOWN r_s; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - if (msg == NULL) return False; + if (msg == NULL) return NT_STATUS_INVALID_PARAMETER; ZERO_STRUCT (q_s); ZERO_STRUCT (r_s); diff --git a/source3/libsmb/cli_samr.c b/source3/libsmb/cli_samr.c index 9e40135801..4a04d67887 100644 --- a/source3/libsmb/cli_samr.c +++ b/source3/libsmb/cli_samr.c @@ -68,7 +68,7 @@ NTSTATUS cli_samr_connect(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Return output parameters */ - if ((result = r.status) == NT_STATUS_OK) { + if (NT_STATUS_IS_OK(result = r.status)) { *connect_pol = r.connect_pol; } @@ -114,7 +114,7 @@ NTSTATUS cli_samr_close(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Return output parameters */ - if ((result = r.status) == NT_STATUS_OK) { + if (NT_STATUS_IS_OK(result = r.status)) { *connect_pol = r.pol; } @@ -161,7 +161,7 @@ NTSTATUS cli_samr_open_domain(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Return output parameters */ - if ((result = r.status) == NT_STATUS_OK) { + if (NT_STATUS_IS_OK(result = r.status)) { *domain_pol = r.domain_pol; } @@ -208,7 +208,7 @@ NTSTATUS cli_samr_open_user(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Return output parameters */ - if ((result = r.status) == NT_STATUS_OK) { + if (NT_STATUS_IS_OK(result = r.status)) { *user_pol = r.user_pol; } @@ -255,7 +255,7 @@ NTSTATUS cli_samr_open_group(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Return output parameters */ - if ((result = r.status) == NT_STATUS_OK) { + if (NT_STATUS_IS_OK(result = r.status)) { *group_pol = r.pol; } @@ -395,7 +395,7 @@ NTSTATUS cli_samr_query_usergroups(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Return output parameters */ - if ((result = r.status) == NT_STATUS_OK) { + if (NT_STATUS_IS_OK(result = r.status)) { *num_groups = r.num_entries; *gid = r.gid; } @@ -443,7 +443,7 @@ NTSTATUS cli_samr_query_groupmem(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Return output parameters */ - if ((result = r.status) == NT_STATUS_OK) { + if (NT_STATUS_IS_OK(result = r.status)) { *num_mem = r.num_entries; *rid = r.rid; *attr = r.attr; @@ -466,7 +466,8 @@ NTSTATUS cli_samr_enum_dom_groups(struct cli_state *cli, TALLOC_CTX *mem_ctx, prs_struct qbuf, rbuf; SAMR_Q_ENUM_DOM_GROUPS q; SAMR_R_ENUM_DOM_GROUPS r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL, name_idx, i; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + uint32 name_idx, i; ZERO_STRUCT(q); ZERO_STRUCT(r); @@ -495,8 +496,8 @@ NTSTATUS cli_samr_enum_dom_groups(struct cli_state *cli, TALLOC_CTX *mem_ctx, result = r.status; - if (result != NT_STATUS_OK && - result != STATUS_MORE_ENTRIES) { + if (!NT_STATUS_IS_OK(result) && + NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES)) { goto done; } @@ -542,7 +543,8 @@ NTSTATUS cli_samr_query_aliasmem(struct cli_state *cli, TALLOC_CTX *mem_ctx, prs_struct qbuf, rbuf; SAMR_Q_QUERY_ALIASMEM q; SAMR_R_QUERY_ALIASMEM r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL, i; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + uint32 i; ZERO_STRUCT(q); ZERO_STRUCT(r); @@ -569,7 +571,7 @@ NTSTATUS cli_samr_query_aliasmem(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Return output parameters */ - if ((result = r.status) != NT_STATUS_OK) { + if (!NT_STATUS_IS_OK(result = r.status)) { goto done; } @@ -629,7 +631,7 @@ NTSTATUS cli_samr_open_alias(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Return output parameters */ - if ((result = r.status) == NT_STATUS_OK) { + if (NT_STATUS_IS_OK(result = r.status)) { *alias_pol = r.pol; } @@ -678,7 +680,7 @@ NTSTATUS cli_samr_query_dom_info(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Return output parameters */ - if ((result = r.status) != NT_STATUS_OK) { + if (!NT_STATUS_IS_OK(result = r.status)) { goto done; } @@ -731,8 +733,8 @@ NTSTATUS cli_samr_query_dispinfo(struct cli_state *cli, TALLOC_CTX *mem_ctx, result = r.status; - if (result != NT_STATUS_OK && - result != STATUS_MORE_ENTRIES) { + if (!NT_STATUS_IS_OK(result) && + NT_STATUS_V(result) != NT_STATUS_V(STATUS_MORE_ENTRIES)) { goto done; } @@ -758,7 +760,8 @@ NTSTATUS cli_samr_lookup_rids(struct cli_state *cli, TALLOC_CTX *mem_ctx, prs_struct qbuf, rbuf; SAMR_Q_LOOKUP_RIDS q; SAMR_R_LOOKUP_RIDS r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL, i; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + uint32 i; if (num_rids > 1000) { DEBUG(2, ("cli_samr_lookup_rids: warning: NT4 can crash if " @@ -791,7 +794,7 @@ NTSTATUS cli_samr_lookup_rids(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Return output parameters */ - if ((result = r.status) != NT_STATUS_OK) { + if (!NT_STATUS_IS_OK(result = r.status)) { goto done; } @@ -831,7 +834,8 @@ NTSTATUS cli_samr_lookup_names(struct cli_state *cli, TALLOC_CTX *mem_ctx, prs_struct qbuf, rbuf; SAMR_Q_LOOKUP_NAMES q; SAMR_R_LOOKUP_NAMES r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL, i; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + uint32 i; ZERO_STRUCT(q); ZERO_STRUCT(r); @@ -859,7 +863,7 @@ NTSTATUS cli_samr_lookup_names(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Return output parameters */ - if ((result = r.status) != NT_STATUS_OK) { + if (!NT_STATUS_IS_OK(result = r.status)) { goto done; } @@ -921,7 +925,7 @@ NTSTATUS cli_samr_create_dom_user(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Return output parameters */ - if ((result = r.status) != NT_STATUS_OK) { + if (!NT_STATUS_IS_OK(result = r.status)) { goto done; } @@ -977,7 +981,7 @@ NTSTATUS cli_samr_set_userinfo(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Return output parameters */ - if ((result = r.status) != NT_STATUS_OK) { + if (!NT_STATUS_IS_OK(result = r.status)) { goto done; } @@ -1024,7 +1028,7 @@ NTSTATUS cli_samr_set_userinfo2(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Return output parameters */ - if ((result = r.status) != NT_STATUS_OK) { + if (!NT_STATUS_IS_OK(result = r.status)) { goto done; } diff --git a/source3/libsmb/cli_spoolss.c b/source3/libsmb/cli_spoolss.c index 54769ce18d..2663e311e0 100644 --- a/source3/libsmb/cli_spoolss.c +++ b/source3/libsmb/cli_spoolss.c @@ -84,8 +84,11 @@ NTSTATUS cli_spoolss_open_printer_ex( /* Return output parameters */ - if ((result = r.status) == NT_STATUS_OK) { + if (W_ERROR_IS_OK(r.status)) { + result = NT_STATUS_OK; *pol = r.handle; + } else { + result = werror_to_ntstatus(r.status); } done: @@ -137,8 +140,11 @@ NTSTATUS cli_spoolss_close_printer( /* Return output parameters */ - if ((result = r.status) == NT_STATUS_OK) { + if (W_ERROR_IS_OK(r.status)) { *pol = r.handle; + result = NT_STATUS_OK; + } else { + result = werror_to_ntstatus(r.status); } done: @@ -428,10 +434,12 @@ NTSTATUS cli_spoolss_enum_printers( } /* Return output parameters */ + if (!W_ERROR_IS_OK(r.status)) { + result = werror_to_ntstatus(r.status); + goto done; + } - if (((result=r.status) == NT_STATUS_OK) && (*returned = r.returned)) - { - + if ((*returned = r.returned)) { switch (level) { case 1: decode_printer_info_1(mem_ctx, r.buffer, r.returned, @@ -452,7 +460,7 @@ NTSTATUS cli_spoolss_enum_printers( prs_mem_free(&qbuf); prs_mem_free(&rbuf); - } while (result == ERROR_INSUFFICIENT_BUFFER); + } while (NT_STATUS_V(result) == NT_STATUS_V(ERROR_INSUFFICIENT_BUFFER)); return result; } @@ -504,8 +512,9 @@ NTSTATUS cli_spoolss_enum_ports( } /* Return output parameters */ + result = werror_to_ntstatus(r.status); - if ((result = r.status) == NT_STATUS_OK && + if (NT_STATUS_IS_OK(result) && r.returned > 0) { *returned = r.returned; @@ -526,7 +535,7 @@ NTSTATUS cli_spoolss_enum_ports( prs_mem_free(&qbuf); prs_mem_free(&rbuf); - } while (result == ERROR_INSUFFICIENT_BUFFER); + } while (NT_STATUS_V(result) == NT_STATUS_V(ERROR_INSUFFICIENT_BUFFER)); return result; } @@ -574,8 +583,8 @@ NTSTATUS cli_spoolss_getprinter( } /* Return output parameters */ - if ((result = r.status) == NT_STATUS_OK) { - + result = werror_to_ntstatus(r.status); + if (NT_STATUS_IS_OK(result)) { switch (level) { case 0: decode_printer_info_0(mem_ctx, r.buffer, 1, &ctr->printers_0); @@ -596,7 +605,7 @@ NTSTATUS cli_spoolss_getprinter( prs_mem_free(&qbuf); prs_mem_free(&rbuf); - } while (result == ERROR_INSUFFICIENT_BUFFER); + } while (NT_STATUS_V(result) == NT_STATUS_V(ERROR_INSUFFICIENT_BUFFER)); return result; } @@ -616,7 +625,7 @@ NTSTATUS cli_spoolss_setprinter( prs_struct qbuf, rbuf; SPOOL_Q_SETPRINTER q; SPOOL_R_SETPRINTER r; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + NTSTATUS result = NT_STATUS_ACCESS_DENIED; ZERO_STRUCT(q); ZERO_STRUCT(r); @@ -631,7 +640,7 @@ NTSTATUS cli_spoolss_setprinter( if (!spoolss_io_q_setprinter("", &q, &qbuf, 0) || !rpc_api_pipe_req(cli, SPOOLSS_SETPRINTER, &qbuf, &rbuf)) { - result = NT_STATUS_UNSUCCESSFUL; + result = NT_STATUS_ACCESS_DENIED; goto done; } @@ -641,7 +650,7 @@ NTSTATUS cli_spoolss_setprinter( goto done; } - result = r.status; + result = werror_to_ntstatus(r.status); done: prs_mem_free(&qbuf); @@ -705,9 +714,9 @@ NTSTATUS cli_spoolss_getprinterdriver ( } /* Return output parameters */ - if ((result = r.status) == NT_STATUS_OK) + result = werror_to_ntstatus(r.status); + if (NT_STATUS_IS_OK(result)) { - switch (level) { case 1: @@ -726,7 +735,7 @@ NTSTATUS cli_spoolss_getprinterdriver ( prs_mem_free(&qbuf); prs_mem_free(&rbuf); - } while (result == ERROR_INSUFFICIENT_BUFFER); + } while (NT_STATUS_V(result) == NT_STATUS_V(ERROR_INSUFFICIENT_BUFFER)); return result; } @@ -784,7 +793,8 @@ NTSTATUS cli_spoolss_enumprinterdrivers ( } /* Return output parameters */ - if (((result=r.status) == NT_STATUS_OK) && + result = werror_to_ntstatus(r.status); + if (NT_STATUS_IS_OK(result) && (r.returned != 0)) { *returned = r.returned; @@ -807,7 +817,7 @@ NTSTATUS cli_spoolss_enumprinterdrivers ( prs_mem_free(&qbuf); prs_mem_free(&rbuf); - } while (result == ERROR_INSUFFICIENT_BUFFER); + } while (NT_STATUS_V(result) == NT_STATUS_V(ERROR_INSUFFICIENT_BUFFER)); return result; } @@ -865,7 +875,8 @@ NTSTATUS cli_spoolss_getprinterdriverdir ( } /* Return output parameters */ - if ((result=r.status) == NT_STATUS_OK) + result = werror_to_ntstatus(r.status); + if (NT_STATUS_IS_OK(result)) { switch (level) { @@ -879,7 +890,7 @@ NTSTATUS cli_spoolss_getprinterdriverdir ( prs_mem_free(&qbuf); prs_mem_free(&rbuf); - } while (result == ERROR_INSUFFICIENT_BUFFER); + } while (NT_STATUS_V(result) == NT_STATUS_V(ERROR_INSUFFICIENT_BUFFER)); return result; } @@ -931,7 +942,7 @@ NTSTATUS cli_spoolss_addprinterdriver ( } /* Return output parameters */ - result = r.status; + result = werror_to_ntstatus(r.status); done: prs_mem_free(&qbuf); @@ -993,7 +1004,7 @@ NTSTATUS cli_spoolss_addprinterex ( } /* Return output parameters */ - result = r.status; + result = werror_to_ntstatus(r.status); done: prs_mem_free(&qbuf); @@ -1050,7 +1061,7 @@ NTSTATUS cli_spoolss_deleteprinterdriver ( } /* Return output parameters */ - result = r.status; + result = werror_to_ntstatus(r.status); done: prs_mem_free(&qbuf); diff --git a/source3/libsmb/domain_client_validate.c b/source3/libsmb/domain_client_validate.c index 69b5739b63..a6890f1027 100644 --- a/source3/libsmb/domain_client_validate.c +++ b/source3/libsmb/domain_client_validate.c @@ -323,16 +323,14 @@ NTSTATUS domain_client_validate(const auth_usersupplied_info *user_info, ZERO_STRUCT(info3); - if ((status = cli_nt_login_network(&cli, user_info, smb_uid_low, - &ctr, &info3)) - != NT_STATUS_OK) { + status = cli_nt_login_network(&cli, user_info, smb_uid_low, + &ctr, &info3); + if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("domain_client_validate: unable to validate password " "for user %s in domain %s to Domain controller %s. " "Error was %s.\n", user_info->smb_username.str, user_info->domain.str, remote_machine, get_nt_error_msg(status))); - } else { - status = NT_STATUS_OK; } /* -- cgit