diff options
author | Volker Lendecke <vl@samba.org> | 2010-11-11 14:54:25 +0100 |
---|---|---|
committer | Volker Lendecke <vlendec@samba.org> | 2010-11-11 16:16:24 +0000 |
commit | 1d9616113207775916c816708fe442fe84ad0369 (patch) | |
tree | fd68908a6c95ccd33465be96b32540cabe83a9aa | |
parent | 612ded1abf15bfcc3569f061b18764bff66fe9b6 (diff) | |
download | samba-1d9616113207775916c816708fe442fe84ad0369.tar.gz samba-1d9616113207775916c816708fe442fe84ad0369.tar.xz samba-1d9616113207775916c816708fe442fe84ad0369.zip |
s3: Convert cli_dfs_get_referral to cli_trans
-rw-r--r-- | source3/include/proto.h | 2 | ||||
-rw-r--r-- | source3/libsmb/clidfs.c | 61 |
2 files changed, 31 insertions, 32 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 38c5a6d8fab..10468be312c 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1689,7 +1689,7 @@ struct cli_state *cli_cm_open(TALLOC_CTX *ctx, int port, int name_type); void cli_cm_display(const struct cli_state *c); -bool cli_dfs_get_referral(TALLOC_CTX *ctx, +NTSTATUS cli_dfs_get_referral(TALLOC_CTX *ctx, struct cli_state *cli, const char *path, struct client_dfs_referral **refs, diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c index 97c1e0407cc..1c879884fe1 100644 --- a/source3/libsmb/clidfs.c +++ b/source3/libsmb/clidfs.c @@ -618,7 +618,7 @@ static bool cli_dfs_check_error(struct cli_state *cli, NTSTATUS expected, Get the dfs referral link. ********************************************************************/ -bool cli_dfs_get_referral(TALLOC_CTX *ctx, +NTSTATUS cli_dfs_get_referral(TALLOC_CTX *ctx, struct cli_state *cli, const char *path, struct client_dfs_referral **refs, @@ -627,9 +627,9 @@ bool cli_dfs_get_referral(TALLOC_CTX *ctx, { unsigned int data_len = 0; unsigned int param_len = 0; - uint16 setup = TRANSACT2_GET_DFS_REFERRAL; - char *param = NULL; - char *rparam=NULL, *rdata=NULL; + uint16 setup[1]; + uint8_t *param = NULL; + uint8_t *rdata = NULL; char *p; char *endp; size_t pathlen = 2*(strlen(path)+1); @@ -638,43 +638,42 @@ bool cli_dfs_get_referral(TALLOC_CTX *ctx, uint16_t consumed_ucs; uint16 num_referrals; struct client_dfs_referral *referrals = NULL; - bool ret = false; + NTSTATUS status; *num_refs = 0; *refs = NULL; - param = SMB_MALLOC_ARRAY(char, 2+pathlen+2); + SSVAL(setup, 0, TRANSACT2_GET_DFS_REFERRAL); + + param = SMB_MALLOC_ARRAY(uint8_t, 2+pathlen+2); if (!param) { + status = NT_STATUS_NO_MEMORY; goto out; } SSVAL(param, 0, 0x03); /* max referral level */ - p = ¶m[2]; + p = (char *)(¶m[2]); path_ucs = (smb_ucs2_t *)p; p += clistr_push(cli, p, path, pathlen, STR_TERMINATE); param_len = PTR_DIFF(p, param); - if (!cli_send_trans(cli, SMBtrans2, - NULL, /* name */ - -1, 0, /* fid, flags */ - &setup, 1, 0, /* setup, length, max */ - param, param_len, 2, /* param, length, max */ - NULL, 0, cli->max_xmit /* data, length, max */ - )) { - goto out; - } - - if (!cli_receive_trans(cli, SMBtrans2, - &rparam, ¶m_len, - &rdata, &data_len)) { + status = cli_trans(talloc_tos(), cli, SMBtrans2, + NULL, 0xffff, 0, 0, + setup, 1, 0, + param, param_len, 2, + NULL, 0, cli->max_xmit, + NULL, + NULL, 0, NULL, /* rsetup */ + NULL, 0, NULL, + &rdata, 4, &data_len); + if (!NT_STATUS_IS_OK(status)) { goto out; } - if (data_len < 4) { goto out; } - endp = rdata + data_len; + endp = (char *)rdata + data_len; consumed_ucs = SVAL(rdata, 0); num_referrals = SVAL(rdata, 2); @@ -714,7 +713,7 @@ bool cli_dfs_get_referral(TALLOC_CTX *ctx, } /* start at the referrals array */ - p = rdata+8; + p = (char *)rdata+8; for (i=0; i<num_referrals && p < endp; i++) { if (p + 18 > endp) { goto out; @@ -750,8 +749,6 @@ bool cli_dfs_get_referral(TALLOC_CTX *ctx, } } - ret = true; - *num_refs = num_referrals; *refs = referrals; @@ -759,9 +756,8 @@ bool cli_dfs_get_referral(TALLOC_CTX *ctx, TALLOC_FREE(consumed_path); SAFE_FREE(param); - SAFE_FREE(rdata); - SAFE_FREE(rparam); - return ret; + TALLOC_FREE(rdata); + return status; } /******************************************************************** @@ -867,8 +863,9 @@ bool cli_resolve_path(TALLOC_CTX *ctx, return false; } - if (!cli_dfs_get_referral(ctx, cli_ipc, dfs_path, &refs, - &num_refs, &consumed) || !num_refs) { + status = cli_dfs_get_referral(ctx, cli_ipc, dfs_path, &refs, + &num_refs, &consumed); + if (!NT_STATUS_IS_OK(status) || !num_refs) { return false; } @@ -1054,7 +1051,9 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx, } } - res = cli_dfs_get_referral(ctx, cli, fullpath, &refs, &num_refs, &consumed); + status = cli_dfs_get_referral(ctx, cli, fullpath, &refs, + &num_refs, &consumed); + res = NT_STATUS_IS_OK(status); status = cli_tdis(cli); if (!NT_STATUS_IS_OK(status)) { |