diff options
author | Volker Lendecke <vl@samba.org> | 2011-01-16 08:34:58 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2011-01-17 08:03:41 +0100 |
commit | e2a96711d708dd6df32bc68883a5bb0ef908a639 (patch) | |
tree | c5cadb1c43f6193eb2345544a89fb3031c522bf5 | |
parent | bc5554bdcc9ece0e1f443653d87a541f74210fa0 (diff) | |
download | samba-e2a96711d708dd6df32bc68883a5bb0ef908a639.tar.gz samba-e2a96711d708dd6df32bc68883a5bb0ef908a639.tar.bz2 samba-e2a96711d708dd6df32bc68883a5bb0ef908a639.zip |
s3: Convert cli_get_user_quota to cli_trans
-rw-r--r-- | source3/include/proto.h | 3 | ||||
-rw-r--r-- | source3/libsmb/cliquota.c | 89 | ||||
-rw-r--r-- | source3/utils/smbcquotas.c | 14 |
3 files changed, 54 insertions, 52 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 0e66a523a8..c3535cd37c 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -2254,7 +2254,8 @@ bool cli_spl_close(struct cli_state *cli, uint16_t fnum); NTSTATUS cli_get_quota_handle(struct cli_state *cli, uint16_t *quota_fnum); void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list); -bool cli_get_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt); +NTSTATUS cli_get_user_quota(struct cli_state *cli, int quota_fnum, + SMB_NTQUOTA_STRUCT *pqt); bool cli_set_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt); bool cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST **pqt_list); bool cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt); diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index 32be011db9..046426740e 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -43,7 +43,10 @@ void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list) return; } -static bool parse_user_quota_record(const char *rdata, unsigned int rdata_count, unsigned int *offset, SMB_NTQUOTA_STRUCT *pqt) +static bool parse_user_quota_record(const uint8_t *rdata, + unsigned int rdata_count, + unsigned int *offset, + SMB_NTQUOTA_STRUCT *pqt) { int sid_len; SMB_NTQUOTA_STRUCT qt; @@ -114,7 +117,7 @@ static bool parse_user_quota_record(const char *rdata, unsigned int rdata_count, } #endif /* LARGE_SMB_OFF_T */ - if (!sid_parse(rdata+40,sid_len,&qt.sid)) { + if (!sid_parse((char *)rdata+40,sid_len,&qt.sid)) { return false; } @@ -125,23 +128,24 @@ static bool parse_user_quota_record(const char *rdata, unsigned int rdata_count, return True; } -bool cli_get_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt) +NTSTATUS cli_get_user_quota(struct cli_state *cli, int quota_fnum, + SMB_NTQUOTA_STRUCT *pqt) { - bool ret = False; - uint16 setup; - char params[16]; + uint16_t setup[1]; + uint8_t params[16]; unsigned int data_len; - char data[SID_MAX_SIZE+8]; - char *rparam=NULL, *rdata=NULL; - unsigned int rparam_count=0, rdata_count=0; + uint8_t data[SID_MAX_SIZE+8]; + uint8_t *rparam, *rdata; + uint32_t rparam_count, rdata_count; unsigned int sid_len; unsigned int offset; + NTSTATUS status; if (!cli||!pqt) { smb_panic("cli_get_user_quota() called with NULL Pointer!"); } - setup = NT_TRANSACT_GET_USER_QUOTA; + SSVAL(setup + 0, 0, NT_TRANSACT_GET_USER_QUOTA); SSVAL(params, 0,quota_fnum); SSVAL(params, 2,TRANSACT_GET_USER_QUOTA_FOR_SID); @@ -153,44 +157,32 @@ bool cli_get_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUC data_len = sid_len+8; SIVAL(data, 0, 0x00000000); SIVAL(data, 4, sid_len); - sid_linearize(data+8, sid_len, &pqt->sid); - - if (!cli_send_nt_trans(cli, - NT_TRANSACT_GET_USER_QUOTA, - 0, - &setup, 1, 0, - params, 16, 4, - data, data_len, 112)) { - DEBUG(1,("Failed to send NT_TRANSACT_GET_USER_QUOTA\n")); - goto cleanup; - } - - - if (!cli_receive_nt_trans(cli, - &rparam, &rparam_count, - &rdata, &rdata_count)) { - DEBUG(1,("Failed to recv NT_TRANSACT_GET_USER_QUOTA\n")); - goto cleanup; - } - - if (cli_is_error(cli)) { - ret = False; - goto cleanup; - } else { - ret = True; - } - - if ((rparam&&rdata)&&(rparam_count>=4&&rdata_count>=8)) { - ret = parse_user_quota_record(rdata, rdata_count, &offset, pqt); - } else { + sid_linearize((char *)data+8, sid_len, &pqt->sid); + + status = cli_trans(talloc_tos(), cli, SMBnttrans, + NULL, -1, /* name, fid */ + NT_TRANSACT_GET_USER_QUOTA, 0, + setup, 1, 0, /* setup */ + params, 16, 4, /* params */ + data, data_len, 112, /* data */ + NULL, /* recv_flags2 */ + NULL, 0, NULL, /* rsetup */ + &rparam, 4, &rparam_count, + &rdata, 8, &rdata_count); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("NT_TRANSACT_GET_USER_QUOTA failed: %s\n", + nt_errstr(status))); + return status; + } + + if (!parse_user_quota_record(rdata, rdata_count, &offset, pqt)) { + status = NT_STATUS_INVALID_NETWORK_RESPONSE; DEBUG(0,("Got INVALID NT_TRANSACT_GET_USER_QUOTA reply.\n")); - ret = False; } - cleanup: - SAFE_FREE(rparam); - SAFE_FREE(rdata); - return ret; + TALLOC_FREE(rparam); + TALLOC_FREE(rdata); + return status; } bool cli_set_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt) @@ -318,7 +310,8 @@ bool cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST ((curdata)&&(curdata_count>=8)&&(offset>0)); curdata +=offset,curdata_count -= offset) { ZERO_STRUCT(qt); - if (!parse_user_quota_record(curdata, curdata_count, &offset, &qt)) { + if (!parse_user_quota_record((uint8_t *)curdata, curdata_count, + &offset, &qt)) { DEBUG(1,("Failed to parse the quota record\n")); goto cleanup; } @@ -378,7 +371,9 @@ bool cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST ((curdata)&&(curdata_count>=8)&&(offset>0)); curdata +=offset,curdata_count -= offset) { ZERO_STRUCT(qt); - if (!parse_user_quota_record(curdata, curdata_count, &offset, &qt)) { + if (!parse_user_quota_record((uint8_t *)curdata, + curdata_count, &offset, + &qt)) { DEBUG(1,("Failed to parse the quota record\n")); goto cleanup; } diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c index cef3f579ee..9c64781d83 100644 --- a/source3/utils/smbcquotas.c +++ b/source3/utils/smbcquotas.c @@ -271,9 +271,12 @@ static int do_quota(struct cli_state *cli, switch(cmd) { case QUOTA_GET: - if (!cli_get_user_quota(cli, quota_fnum, &qt)) { + status = cli_get_user_quota( + cli, quota_fnum, &qt); + if (!NT_STATUS_IS_OK(status)) { d_printf("%s cli_get_user_quota %s\n", - cli_errstr(cli),username_str); + nt_errstr(status), + username_str); return -1; } dump_ntquota(&qt,verbose,numeric,SidToString); @@ -285,9 +288,12 @@ static int do_quota(struct cli_state *cli, cli_errstr(cli),username_str); return -1; } - if (!cli_get_user_quota(cli, quota_fnum, &qt)) { + status = cli_get_user_quota( + cli, quota_fnum, &qt); + if (!NT_STATUS_IS_OK(status)) { d_printf("%s cli_get_user_quota %s\n", - cli_errstr(cli),username_str); + nt_errstr(status), + username_str); return -1; } dump_ntquota(&qt,verbose,numeric,SidToString); |