s3: Convert cli_set_user_quota to cli_trans
authorVolker Lendecke <vl@samba.org>
Sun, 16 Jan 2011 10:33:35 +0000 (11:33 +0100)
committerVolker Lendecke <vl@samba.org>
Mon, 17 Jan 2011 07:03:41 +0000 (08:03 +0100)
source3/include/proto.h
source3/libsmb/cliquota.c
source3/utils/smbcquotas.c

index c3535cd37ca429ed031ceac5094f6109ef1df134..cdde6d7176b0e4d3c6c7994378879de8c9f9afb0 100644 (file)
@@ -2256,7 +2256,8 @@ NTSTATUS cli_get_quota_handle(struct cli_state *cli, uint16_t *quota_fnum);
 void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list);
 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);
+NTSTATUS 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);
 bool cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt);
index 046426740ee1a5d5f67313436165ecd0c00ac351..3a267d76a1514fdc47b7c0810d4bbe0bba40466c 100644 (file)
@@ -185,22 +185,22 @@ NTSTATUS cli_get_user_quota(struct cli_state *cli, int quota_fnum,
        return status;
 }
 
-bool cli_set_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt)
+NTSTATUS cli_set_user_quota(struct cli_state *cli, int quota_fnum,
+                           SMB_NTQUOTA_STRUCT *pqt)
 {
-       bool ret = False;
-       uint16 setup;
-       char params[2];
-       char data[112];
-       char *rparam=NULL, *rdata=NULL;
-       unsigned int rparam_count=0, rdata_count=0;
+       uint16_t setup[1];
+       uint8_t params[2];
+       uint8_t data[112];
        unsigned int sid_len;   
+       NTSTATUS status;
+
        memset(data,'\0',112);
 
        if (!cli||!pqt) {
                smb_panic("cli_set_user_quota() called with NULL Pointer!");
        }
 
-       setup = NT_TRANSACT_SET_USER_QUOTA;
+       SSVAL(setup + 0, 0, NT_TRANSACT_SET_USER_QUOTA);
 
        SSVAL(params,0,quota_fnum);
 
@@ -211,37 +211,25 @@ bool cli_set_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUC
        SBIG_UINT(data,16,pqt->usedspace);
        SBIG_UINT(data,24,pqt->softlim);
        SBIG_UINT(data,32,pqt->hardlim);
-       sid_linearize(data+40, sid_len, &pqt->sid);
+       sid_linearize((char *)data+40, sid_len, &pqt->sid);
 
-       if (!cli_send_nt_trans(cli, 
-                              NT_TRANSACT_SET_USER_QUOTA, 
-                              0, 
-                              &setup, 1, 0,
-                              params, 2, 0,
-                              data, 112, 0)) {
-               DEBUG(1,("Failed to send NT_TRANSACT_SET_USER_QUOTA\n"));
-               goto cleanup;
-       }
-
-
-       if (!cli_receive_nt_trans(cli, 
-                                 &rparam, &rparam_count,
-                                 &rdata, &rdata_count)) {
-               DEBUG(1,("NT_TRANSACT_SET_USER_QUOTA failed\n"));
-               goto cleanup;
-       }
+       status = cli_trans(talloc_tos(), cli, SMBnttrans,
+                          NULL, -1, /* name, fid */
+                          NT_TRANSACT_SET_USER_QUOTA, 0,
+                          setup, 1, 0, /* setup */
+                          params, 2, 0, /* params */
+                          data, 112, 0, /* data */
+                          NULL,                /* recv_flags2 */
+                          NULL, 0, NULL,       /* rsetup */
+                          NULL, 0, NULL,       /* rparams */
+                          NULL, 0, NULL);      /* rdata */
 
-       if (cli_is_error(cli)) {
-               ret = False;
-               goto cleanup;
-       } else {
-               ret = True;
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(1, ("NT_TRANSACT_SET_USER_QUOTA failed: %s\n",
+                         nt_errstr(status)));
        }
 
-  cleanup:
-       SAFE_FREE(rparam);
-       SAFE_FREE(rdata);
-       return ret;
+       return status;
 }
 
 bool cli_list_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST **pqt_list)
index 9c64781d835e56e8defb40ca79e84ce692a575e9..985b9d7e328a2f9e557c69463c0d4c1b6043be05 100644 (file)
@@ -283,9 +283,12 @@ static int do_quota(struct cli_state *cli,
                                        break;
                                case QUOTA_SETLIM:
                                        pqt->sid = qt.sid;
-                                       if (!cli_set_user_quota(cli, quota_fnum, pqt)) {
+                                       status = cli_set_user_quota(
+                                               cli, quota_fnum, pqt);
+                                       if (!NT_STATUS_IS_OK(status)) {
                                                d_printf("%s cli_set_user_quota %s\n",
-                                                        cli_errstr(cli),username_str);
+                                                        nt_errstr(status),
+                                                        username_str);
                                                return -1;
                                        }
                                        status = cli_get_user_quota(