cliquota: support setting user quota via SMB2
authorUri Simchoni <uri@samba.org>
Wed, 21 Sep 2016 16:35:39 +0000 (19:35 +0300)
committerJeremy Allison <jra@samba.org>
Tue, 4 Oct 2016 00:00:23 +0000 (02:00 +0200)
Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libsmb/cli_smb2_fnum.c
source3/libsmb/cli_smb2_fnum.h
source3/libsmb/cliquota.c

index 1be93812df9991905185e48e255b32e6551dc339..9ee4daed13d9e3d72ffa3f6da2ee4b0cfd12a686 100644 (file)
@@ -2559,6 +2559,55 @@ cleanup:
        return status;
 }
 
+/***************************************************************
+ Wrapper that allows SMB2 to set user quota.
+ Synchronous only.
+***************************************************************/
+
+NTSTATUS cli_smb2_set_user_quota(struct cli_state *cli,
+                                int quota_fnum,
+                                SMB_NTQUOTA_LIST *qtl)
+{
+       NTSTATUS status;
+       DATA_BLOB inbuf = data_blob_null;
+       struct smb2_hnd *ph = NULL;
+       TALLOC_CTX *frame = talloc_stackframe();
+
+       if (smbXcli_conn_has_async_calls(cli->conn)) {
+               /*
+                * Can't use sync call while an async call is in flight
+                */
+               status = NT_STATUS_INVALID_PARAMETER;
+               goto cleanup;
+       }
+
+       if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) {
+               status = NT_STATUS_INVALID_PARAMETER;
+               goto cleanup;
+       }
+
+       status = map_fnum_to_smb2_handle(cli, quota_fnum, &ph);
+       if (!NT_STATUS_IS_OK(status)) {
+               goto cleanup;
+       }
+
+       status = build_user_quota_buffer(qtl, 0, talloc_tos(), &inbuf, NULL);
+       if (!NT_STATUS_IS_OK(status)) {
+               goto cleanup;
+       }
+
+       status = smb2cli_set_info(cli->conn, cli->timeout, cli->smb2.session,
+                                 cli->smb2.tcon, 4, /* in_info_type */
+                                 0,                 /* in_file_info_class */
+                                 &inbuf,           /* in_input_buffer */
+                                 0,                 /* in_additional_info */
+                                 ph->fid_persistent, ph->fid_volatile);
+cleanup:
+       TALLOC_FREE(frame);
+
+       return status;
+}
+
 struct cli_smb2_read_state {
        struct tevent_context *ev;
        struct cli_state *cli;
index 7fd97ec0934579f244718c1c23db28344bb2cd6a..7c618d186547c1f46b16cdb05a22d6c8b787ee67 100644 (file)
@@ -160,6 +160,9 @@ NTSTATUS cli_smb2_list_user_quota_step(struct cli_state *cli,
 NTSTATUS cli_smb2_get_fs_quota_info(struct cli_state *cli,
                                    int quota_fnum,
                                    SMB_NTQUOTA_STRUCT *pqt);
+NTSTATUS cli_smb2_set_user_quota(struct cli_state *cli,
+                                int quota_fnum,
+                                SMB_NTQUOTA_LIST *qtl);
 struct tevent_req *cli_smb2_read_send(TALLOC_CTX *mem_ctx,
                                struct tevent_context *ev,
                                struct cli_state *cli,
index f11d9a28fb98c3feaf48983db0c66f4c2a144bf8..57bffe2aa290051e42f52dfc71286b0953d7398c 100644 (file)
@@ -397,6 +397,10 @@ cli_set_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_LIST *qtl)
                smb_panic("cli_set_user_quota() called with NULL Pointer!");
        }
 
+       if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
+               return cli_smb2_set_user_quota(cli, quota_fnum, qtl);
+       }
+
        status = build_user_quota_buffer(qtl, 0, talloc_tos(), &data, NULL);
        if (!NT_STATUS_IS_OK(status)) {
                goto cleanup;