[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Tue Oct 4 03:44:03 UTC 2016
The branch, master has been updated
via a782148 README.Coding: Add clang-format style file
via 533b121 README.Coding: Add rule about function declaration indentation
via 1b5dd78 README.Coding: Remove an extra space
via 1dacc09 smbcquotas: add -m option
via f596bbf cliquota: support setting file system quota via SMB2
via d82f0e9 cliquota: factor out building of FILE_FS_CONTROL_INFORMATION
via fba19ad cliquota: support setting user quota via SMB2
via 5e9b1f7 cliquota: factor out building of FILE_QUOTA_INFORMATION
via a1d9090 cliquota: support getting fs quota by SMB2
via 0ed8b49 cliquota: factor out fs quota parsing
via e0e5002 cliquota: implement quota listing in SMB2
via debc97e cliquota: factor out parsing of a quota record buffer
via 72c773c cliquota: some security hardening
via 621d7b4 cliquota: refactor and cleanup listing of user quotas
via b6375ce s3-libsmb: support getting user's quota in SMB2
via 7f08a3b s3-libsmb: make parse_user_quota_record() public
via 2e7e5df s3-libsmb: Support getting fs attributes via SMB2
via 175bc6f smbd: free talloc context if no quota records are available
via dad6c2d cliquota: fix param count when setting fs quota
via dd8a057 ntquotas: support "freeing" an empty quota list
via 610c26d smbcquotas: fix error message listing quotas
via 5a947d6 s3-cliquota: correctly handle no-more-entries
from 7c786f8 s3/winbindd: using default domain with user at domain.com format fails
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit a7821482ecb2535bf93d07283b7a0392298d19d2
Author: Uri Simchoni <uri at samba.org>
Date: Sun Oct 2 20:41:45 2016 +0300
README.Coding: Add clang-format style file
Add how the coding style is represented in clang-format directives.
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Tue Oct 4 05:43:18 CEST 2016 on sn-devel-144
commit 533b1210ea8e86bf90d55c01560b82f1741ca78d
Author: Uri Simchoni <uri at samba.org>
Date: Sun Oct 2 20:40:06 2016 +0300
README.Coding: Add rule about function declaration indentation
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 1b5dd78c7b43ce6d6c409cbf8b0402ee254eb950
Author: Uri Simchoni <uri at samba.org>
Date: Sun Oct 2 20:37:37 2016 +0300
README.Coding: Remove an extra space
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 1dacc09b256e942776967a5bfecd2fdf77ea972b
Author: Uri Simchoni <uri at samba.org>
Date: Tue Sep 20 18:51:00 2016 +0300
smbcquotas: add -m option
Add the "standard" -m command line option that controls max
client protocol.
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit f596bbff3046a38aa9cd9ce77072ba3542dfc403
Author: Uri Simchoni <uri at samba.org>
Date: Thu Sep 22 01:03:41 2016 +0300
cliquota: support setting file system quota via SMB2
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit d82f0e99b0d3e1685e35c377c2f6e8f138d8973f
Author: Uri Simchoni <uri at samba.org>
Date: Wed Sep 21 23:58:33 2016 +0300
cliquota: factor out building of FILE_FS_CONTROL_INFORMATION
add a service routine that builds FILE_FS_CONTROL_INFORMATION
with default quota and flags. This will be reused by SMB2 and
by server code.
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit fba19ad9dc6b776d068344f592aa0e06c0747d7d
Author: Uri Simchoni <uri at samba.org>
Date: Wed Sep 21 19:35:39 2016 +0300
cliquota: support setting user quota via SMB2
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 5e9b1f77add716168283b3557d0ddc0cf175b6d7
Author: Uri Simchoni <uri at samba.org>
Date: Wed Sep 21 18:37:40 2016 +0300
cliquota: factor out building of FILE_QUOTA_INFORMATION
Add a function to build a FILE_QUOTA_INFORMATION buffer
out of a quota list, and a function that adds a record
to a quota list.
Some parameters of the new functions are unused by
client code, but will be used by server code.
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit a1d9090e3c00283beb3ecf599a2b29a8fc08dfbf
Author: Uri Simchoni <uri at samba.org>
Date: Tue Sep 20 06:46:28 2016 +0300
cliquota: support getting fs quota by SMB2
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 0ed8b49fafb73f9ebe1188af194f522ccf848f6c
Author: Uri Simchoni <uri at samba.org>
Date: Tue Sep 20 06:45:03 2016 +0300
cliquota: factor out fs quota parsing
This code will be reused by SMB2 code.
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit e0e500258a2e9c92fa371f018e97c452c9bf8c83
Author: Uri Simchoni <uri at samba.org>
Date: Mon Sep 19 22:17:10 2016 +0300
cliquota: implement quota listing in SMB2
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit debc97ef8e4e432764bada162e866791c898b419
Author: Uri Simchoni <uri at samba.org>
Date: Mon Sep 19 21:14:01 2016 +0300
cliquota: factor out parsing of a quota record buffer
In preparation for SMB2 support, take parsing of the return
buffer into a separate function.
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 72c773c9c29d5971d3e8403a11937323997fa0b0
Author: Uri Simchoni <uri at samba.org>
Date: Mon Sep 19 18:24:58 2016 +0300
cliquota: some security hardening
Add some checks for validity of the offset in
the return buffer.
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 621d7b41d9e58aeaaae98a22ef453c01a66a082d
Author: Uri Simchoni <uri at samba.org>
Date: Sun Sep 18 11:13:16 2016 +0300
cliquota: refactor and cleanup listing of user quotas
Split cli_list_user_quota into an outer loop function and
an inner loop function.
This simplifies the code somewhat, paves the way for SMB2
support, and fixes a couple of memory leaks in error
conditions. No functional changes.
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit b6375ce54934ea61eda0af03e354f08b6ec9494e
Author: Uri Simchoni <uri at samba.org>
Date: Mon Sep 12 22:38:15 2016 +0300
s3-libsmb: support getting user's quota in SMB2
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 7f08a3b0313d26e991e2a04437aa25979f97fb93
Author: Uri Simchoni <uri at samba.org>
Date: Mon Sep 12 22:33:12 2016 +0300
s3-libsmb: make parse_user_quota_record() public
For reuse by SMB2 client code.
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 2e7e5dfbc660045d5dd964e78d771cdf80e8f9f5
Author: Uri Simchoni <uri at samba.org>
Date: Tue Sep 20 14:32:06 2016 +0300
s3-libsmb: Support getting fs attributes via SMB2
Add a wrapper function arounf GET_INFO to obtain
file system attributes, and plumb it in.
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 175bc6f1e3442f5cb2258aaadf318ebf23c5d769
Author: Uri Simchoni <uri at samba.org>
Date: Sun Sep 18 11:05:23 2016 +0300
smbd: free talloc context if no quota records are available
When generating a list of user quota records, free the memory
context that controls this list if the list is empty. Otherwise,
the context remains unreferenced and memory is leaked.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12289
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit dad6c2d5631ab9879dd4cd35231b2e8c8a9e8311
Author: Uri Simchoni <uri at samba.org>
Date: Thu Sep 22 16:06:12 2016 +0300
cliquota: fix param count when setting fs quota
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12288
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit dd8a0578d8c9f562a4f13a90f4fe51f66058dd02
Author: Uri Simchoni <uri at samba.org>
Date: Sun Sep 18 11:09:54 2016 +0300
ntquotas: support "freeing" an empty quota list
This avoids dereferencing a null pointer if there's
an attempt to free an empty list.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12307
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 610c26d74c1314142981e5cc31a0706a4a99766f
Author: Uri Simchoni <uri at samba.org>
Date: Fri Sep 16 22:01:46 2016 +0300
smbcquotas: fix error message listing quotas
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12270
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 5a947d6ca1928e4e4bd4caf2b86698b86d378a81
Author: Uri Simchoni <uri at samba.org>
Date: Fri Sep 16 21:57:50 2016 +0300
s3-cliquota: correctly handle no-more-entries
When listing quota records, a Windows server would
return STATUS_SUCCESS until no more entries are available,
where it would return STATUS_NO_MORE_ENTRIES.
The fix keeps old behavior of empty answer also signifying
end of record, to maintain compatibility with Samba servers.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12270
Signed-off-by: Uri Simchoni <uri at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
README.Coding | 18 +-
docs-xml/manpages/smbcquotas.1.xml | 12 +
source3/libsmb/cli_smb2_fnum.c | 382 +++++++++++++++++++++++++++
source3/libsmb/cli_smb2_fnum.h | 18 ++
source3/libsmb/clifsinfo.c | 4 +
source3/libsmb/cliquota.c | 514 +++++++++++++++++++++++++------------
source3/libsmb/proto.h | 28 +-
source3/smbd/ntquotas.c | 6 +-
source3/utils/smbcquotas.c | 28 +-
9 files changed, 840 insertions(+), 170 deletions(-)
Changeset truncated at 500 lines:
diff --git a/README.Coding b/README.Coding
index 2b011a6..19a363f 100644
--- a/README.Coding
+++ b/README.Coding
@@ -90,6 +90,16 @@ displaying trailing whitespace:
set textwidth=80
autocmd BufNewFile,BufRead *.c,*.h exec 'match Todo /\%>' . &textwidth . 'v.\+/'
+clang-format
+------------
+BasedOnStyle: LLVM
+IndentWidth: 8
+UseTab: true
+BreakBeforeBraces: Linux
+AllowShortIfStatementsOnASingleLine: false
+IndentCaseLabels: false
+BinPackParameters: false
+
=========================
FAQ & Statement Reference
@@ -189,7 +199,13 @@ characters or less with whitespace. For example,
The previous example is intended to illustrate alignment of function
parameters across lines and not as encourage for gratuitous line
splitting. Never split a line before columns 70 - 79 unless you
-have a really good reason. Be smart about formatting.
+have a really good reason. Be smart about formatting.
+
+One exception to the previous rule is function declarations and
+definitions. In function declarations and definitions, either the
+declaration is a one-liner, or each parameter is listed on its own
+line. The rationale is that if there are many parameters, each one
+should be on its own line to make tracking interface changes easier.
If, switch, & Code blocks
diff --git a/docs-xml/manpages/smbcquotas.1.xml b/docs-xml/manpages/smbcquotas.1.xml
index bbdb9fd..bff24a4 100644
--- a/docs-xml/manpages/smbcquotas.1.xml
+++ b/docs-xml/manpages/smbcquotas.1.xml
@@ -34,6 +34,7 @@
<arg choice="opt">-V</arg>
<arg choice="opt">-U username</arg>
+ <arg choice="opt">-m|--max-protocol LEVEL</arg>
<arg choice="opt">-N</arg>
<arg choice="opt">-k</arg>
<arg choice="opt">-A</arg>
@@ -96,6 +97,17 @@
</varlistentry>
<varlistentry>
+ <term>-m|--max-protocol PROTOCOL_NAME</term>
+ <listitem><para>This allows the user to select the
+ highest SMB protocol level that smbcquotas will use to
+ connect to the server. By default this is set to
+ NT1, which is the highest available SMB1 protocol.
+ To connect using SMB2 or SMB3 protocol, use the
+ strings SMB2 or SMB3 respectively.
+ </para></listitem>
+ </varlistentry>
+
+ <varlistentry>
<term>-t|--test-args</term>
<listitem><para>
Don't actually do anything, only validate the correctness of the arguments.
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index ac72090..cf00f60 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -37,6 +37,7 @@
#include "libsmb/proto.h"
#include "lib/util/tevent_ntstatus.h"
#include "../libcli/security/security.h"
+#include "../librpc/gen_ndr/ndr_security.h"
#include "lib/util_ea.h"
#include "librpc/gen_ndr/ndr_ioctl.h"
#include "ntioctl.h"
@@ -1756,6 +1757,83 @@ NTSTATUS cli_smb2_dskattr(struct cli_state *cli, const char *path,
}
/***************************************************************
+ Wrapper that allows SMB2 to query file system attributes.
+ Synchronous only.
+***************************************************************/
+
+NTSTATUS cli_smb2_get_fs_attr_info(struct cli_state *cli, uint32_t *fs_attr)
+{
+ NTSTATUS status;
+ uint16_t fnum = 0xffff;
+ DATA_BLOB outbuf = 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 fail;
+ }
+
+ if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) {
+ status = NT_STATUS_INVALID_PARAMETER;
+ goto fail;
+ }
+
+ /* First open the top level directory. */
+ status =
+ cli_smb2_create_fnum(cli, "", 0, /* create_flags */
+ FILE_READ_ATTRIBUTES, /* desired_access */
+ FILE_ATTRIBUTE_DIRECTORY, /* file attributes */
+ FILE_SHARE_READ | FILE_SHARE_WRITE |
+ FILE_SHARE_DELETE, /* share_access */
+ FILE_OPEN, /* create_disposition */
+ FILE_DIRECTORY_FILE, /* create_options */
+ &fnum,
+ NULL);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ goto fail;
+ }
+
+ status = map_fnum_to_smb2_handle(cli, fnum, &ph);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto fail;
+ }
+
+ status = smb2cli_query_info(cli->conn, cli->timeout, cli->smb2.session,
+ cli->smb2.tcon, 2, /* in_info_type */
+ 5, /* in_file_info_class */
+ 0xFFFF, /* in_max_output_length */
+ NULL, /* in_input_buffer */
+ 0, /* in_additional_info */
+ 0, /* in_flags */
+ ph->fid_persistent, ph->fid_volatile, frame,
+ &outbuf);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto fail;
+ }
+
+ if (outbuf.length < 12) {
+ status = NT_STATUS_INVALID_NETWORK_RESPONSE;
+ goto fail;
+ }
+
+ *fs_attr = IVAL(outbuf.data, 0);
+
+fail:
+
+ if (fnum != 0xffff) {
+ cli_smb2_close_fnum(cli, fnum);
+ }
+
+ TALLOC_FREE(frame);
+ return status;
+}
+
+/***************************************************************
Wrapper that allows SMB2 to query a security descriptor.
Synchronous only.
***************************************************************/
@@ -2270,6 +2348,310 @@ NTSTATUS cli_smb2_get_ea_list_path(struct cli_state *cli,
return status;
}
+/***************************************************************
+ Wrapper that allows SMB2 to get user quota.
+ Synchronous only.
+***************************************************************/
+
+NTSTATUS cli_smb2_get_user_quota(struct cli_state *cli,
+ int quota_fnum,
+ SMB_NTQUOTA_STRUCT *pqt)
+{
+ NTSTATUS status;
+ DATA_BLOB inbuf = data_blob_null;
+ DATA_BLOB outbuf = data_blob_null;
+ struct smb2_hnd *ph = NULL;
+ TALLOC_CTX *frame = talloc_stackframe();
+ unsigned sid_len;
+ unsigned int offset;
+ uint8_t *buf;
+
+ 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 fail;
+ }
+
+ if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) {
+ status = NT_STATUS_INVALID_PARAMETER;
+ goto fail;
+ }
+
+ status = map_fnum_to_smb2_handle(cli, quota_fnum, &ph);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto fail;
+ }
+
+ sid_len = ndr_size_dom_sid(&pqt->sid, 0);
+
+ inbuf = data_blob_talloc_zero(frame, 24 + sid_len);
+ if (inbuf.data == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto fail;
+ }
+
+ buf = inbuf.data;
+
+ SCVAL(buf, 0, 1); /* ReturnSingle */
+ SCVAL(buf, 1, 0); /* RestartScan */
+ SSVAL(buf, 2, 0); /* Reserved */
+ if (8 + sid_len < 8) {
+ status = NT_STATUS_INVALID_PARAMETER;
+ goto fail;
+ }
+ SIVAL(buf, 4, 8 + sid_len); /* SidListLength */
+ SIVAL(buf, 8, 0); /* StartSidLength */
+ SIVAL(buf, 12, 0); /* StartSidOffset */
+ SIVAL(buf, 16, 0); /* NextEntryOffset */
+ SIVAL(buf, 20, sid_len); /* SidLength */
+ sid_linearize(buf + 24, sid_len, &pqt->sid);
+
+ status = smb2cli_query_info(cli->conn, cli->timeout, cli->smb2.session,
+ cli->smb2.tcon, 4, /* in_info_type */
+ 0, /* in_file_info_class */
+ 0xFFFF, /* in_max_output_length */
+ &inbuf, /* in_input_buffer */
+ 0, /* in_additional_info */
+ 0, /* in_flags */
+ ph->fid_persistent, ph->fid_volatile, frame,
+ &outbuf);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ goto fail;
+ }
+
+ if (!parse_user_quota_record(outbuf.data, outbuf.length, &offset,
+ pqt)) {
+ status = NT_STATUS_INVALID_NETWORK_RESPONSE;
+ DEBUG(0, ("Got invalid FILE_QUOTA_INFORMATION in reply.\n"));
+ }
+
+fail:
+ TALLOC_FREE(frame);
+ return status;
+}
+
+/***************************************************************
+ Wrapper that allows SMB2 to list user quota.
+ Synchronous only.
+***************************************************************/
+
+NTSTATUS cli_smb2_list_user_quota_step(struct cli_state *cli,
+ TALLOC_CTX *mem_ctx,
+ int quota_fnum,
+ SMB_NTQUOTA_LIST **pqt_list,
+ bool first)
+{
+ NTSTATUS status;
+ DATA_BLOB inbuf = data_blob_null;
+ DATA_BLOB outbuf = data_blob_null;
+ struct smb2_hnd *ph = NULL;
+ TALLOC_CTX *frame = talloc_stackframe();
+ uint8_t *buf;
+
+ 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;
+ }
+
+ inbuf = data_blob_talloc_zero(frame, 16);
+ if (inbuf.data == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto cleanup;
+ }
+
+ buf = inbuf.data;
+
+ SCVAL(buf, 0, 0); /* ReturnSingle */
+ SCVAL(buf, 1, first ? 1 : 0); /* RestartScan */
+ SSVAL(buf, 2, 0); /* Reserved */
+ SIVAL(buf, 4, 0); /* SidListLength */
+ SIVAL(buf, 8, 0); /* StartSidLength */
+ SIVAL(buf, 12, 0); /* StartSidOffset */
+
+ status = smb2cli_query_info(cli->conn, cli->timeout, cli->smb2.session,
+ cli->smb2.tcon, 4, /* in_info_type */
+ 0, /* in_file_info_class */
+ 0xFFFF, /* in_max_output_length */
+ &inbuf, /* in_input_buffer */
+ 0, /* in_additional_info */
+ 0, /* in_flags */
+ ph->fid_persistent, ph->fid_volatile, frame,
+ &outbuf);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ goto cleanup;
+ }
+
+ status = parse_user_quota_list(outbuf.data, outbuf.length, mem_ctx,
+ pqt_list);
+
+cleanup:
+ TALLOC_FREE(frame);
+ return status;
+}
+
+/***************************************************************
+ Wrapper that allows SMB2 to get file system quota.
+ Synchronous only.
+***************************************************************/
+
+NTSTATUS cli_smb2_get_fs_quota_info(struct cli_state *cli,
+ int quota_fnum,
+ SMB_NTQUOTA_STRUCT *pqt)
+{
+ NTSTATUS status;
+ DATA_BLOB outbuf = 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 = smb2cli_query_info(
+ cli->conn, cli->timeout, cli->smb2.session, cli->smb2.tcon,
+ 2, /* in_info_type */
+ SMB_FS_QUOTA_INFORMATION - 1000, /* in_file_info_class */
+ 0xFFFF, /* in_max_output_length */
+ NULL, /* in_input_buffer */
+ 0, /* in_additional_info */
+ 0, /* in_flags */
+ ph->fid_persistent, ph->fid_volatile, frame, &outbuf);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ goto cleanup;
+ }
+
+ status = parse_fs_quota_buffer(outbuf.data, outbuf.length, pqt);
+
+cleanup:
+ TALLOC_FREE(frame);
+ 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;
+}
+
+NTSTATUS cli_smb2_set_fs_quota_info(struct cli_state *cli,
+ int quota_fnum,
+ SMB_NTQUOTA_STRUCT *pqt)
+{
+ 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_fs_quota_buffer(talloc_tos(), pqt, &inbuf, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ status = smb2cli_set_info(
+ cli->conn, cli->timeout, cli->smb2.session, cli->smb2.tcon,
+ 2, /* in_info_type */
+ SMB_FS_QUOTA_INFORMATION - 1000, /* 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;
diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h
index 0436c68..3289f7e 100644
--- a/source3/libsmb/cli_smb2_fnum.h
+++ b/source3/libsmb/cli_smb2_fnum.h
@@ -121,6 +121,7 @@ NTSTATUS cli_smb2_dskattr(struct cli_state *cli,
uint64_t *bsize,
uint64_t *total,
uint64_t *avail);
+NTSTATUS cli_smb2_get_fs_attr_info(struct cli_state *cli, uint32_t *fs_attr);
NTSTATUS cli_smb2_query_security_descriptor(struct cli_state *cli,
uint16_t fnum,
uint32_t sec_info,
@@ -148,6 +149,23 @@ NTSTATUS cli_smb2_set_ea_path(struct cli_state *cli,
const char *ea_name,
const char *ea_val,
size_t ea_len);
+NTSTATUS cli_smb2_get_user_quota(struct cli_state *cli,
+ int quota_fnum,
+ SMB_NTQUOTA_STRUCT *pqt);
+NTSTATUS cli_smb2_list_user_quota_step(struct cli_state *cli,
+ TALLOC_CTX *mem_ctx,
+ int quota_fnum,
+ SMB_NTQUOTA_LIST **pqt_list,
+ bool first);
+NTSTATUS cli_smb2_get_fs_quota_info(struct cli_state *cli,
+ int quota_fnum,
+ SMB_NTQUOTA_STRUCT *pqt);
--
Samba Shared Repository
More information about the samba-cvs
mailing list