[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Fri Oct 8 20:22:01 UTC 2021


The branch, master has been updated
       via  3268bcd8f56 vfs: add and use a few SMB_VFS_ODX defines
       via  2f523a03f50 lib: add sys_block_align[_truncate]()
       via  8fa7848b4a0 vfs: Add flags and xferlen args to SMB_VFS_OFFLOAD_READ_RECV
       via  3afd4bd6103 idl: declare token array of storage_offload_token as in-line
       via  83ad7e01fc3 rpc_server3: Remove pipes_struct->private_data
       via  426a7b48055 rpc_server3: Use dcesrv_iface_state in netlogon3
       via  246a5ceab1c netlogon: Move netlogon_server_pipe_state to netlogon.idl
       via  81a7b2e08dd rpc_server3: Remove an outdated comment
       via  ed9e2850bfc rpc_server3: Remove "pipes_struct->opnum"
       via  2e3cea27fc0 rpc_server3: Remove "pipes_struct->call_id"
       via  e5b446fe116 libcli: Simplify get_sec_mask_str()
       via  3a8374b831a dsdb: Simplify schema_attribute_description() & friends
       via  61b06695b70 winbind: Simplify winbindd_sids_to_xids_recv()
       via  fc4ee9c494d winbind: Simplify winbindd_getusersids_recv()
       via  4869497b709 winbind: Simplify winbindd_getsidaliases_recv()
       via  0853a7a2bbf lib: Use talloc_asprintf_addbuf() in utok_string()
       via  18cbeab98bd librpc: Use talloc_asprintf_addbuf() in dcerpc_binding_string()
       via  20536080a56 lib: Add talloc_asprintf_addbuf()
       via  55ec7e6d00f winbind: Align an integer type
       via  10ac08fc1db rpc_server3: Remove unused fields from struct dcerpc_ncacn_conn
       via  34c08da059d libcli: Align integer types
       via  423e5726d2d libcli: Avoid an includes.h
       via  668d3459ac6 idmap_script: Save a few lines with str_list_add_printf()
       via  c38e2d5ff56 lib: Fix a typo in a DEBUG fn prefix by using DBG_
       via  761ede419fc lib: Simplify set_privileges with a struct initialization
       via  b266d39dbb8 lib: Avoid a cast in a DBG statement
       via  f24b2163be0 libcli: Simplify security_session_user_level()
       via  70b1260020d libcli: Introduce a helper variable in security_session_user_level()
       via  82281ca34f9 libcli: Remove unused security_token_has_sid_string()
       via  187529c979c samba: Save a line with TALLOC_FREE
       via  5529aa8c4da smbd: Avoid ZERO_STRUCT() with a struct init
       via  9b260ff8390 lsa_server3: Align integer types
       via  a767eb55d8b rpc_server3: Avoid a literal number available as a constant
       via  e2256c99a65 smbd: Make SID_SAMBA_SMB3 a static SID
      from  a19016e002f Release ldb 2.50 for the future samba 4.16 series

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 3268bcd8f5668c4c1c78d957f7017e7a867288f3
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Jul 9 11:28:22 2021 +0200

    vfs: add and use a few SMB_VFS_ODX defines
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Fri Oct  8 20:21:21 UTC 2021 on sn-devel-184

commit 2f523a03f5061feb68c614f39ae0061748c2d9b3
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Jun 22 18:58:21 2021 +0200

    lib: add sys_block_align[_truncate]()
    
    This implements MS-FSA algorithms BlockAlign() and BlockAlignTruncate().
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8fa7848b4a002900e0c3384d2e0d41ea0fdf6ea9
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Jun 22 20:13:02 2021 +0200

    vfs: Add flags and xferlen args to SMB_VFS_OFFLOAD_READ_RECV
    
    We missed these values which follow from MS-FSCC 2.3.80 “FSCTL_OFFLOAD_READ
    Reply”:
    
      Flags (4 bytes):
    
        A 32-bit unsigned integer that indicates which flags were returned for this
        operation. Possible values for the flags follow. All unused bits are reserved
        for future use, SHOULD be set to 0, and MUST be ignored.
    
        OFFLOAD_READ_FLAG_ALL_ZERO_BEYOND_CURRENT_RANGE (0x00000001)
        => The data beyond the current range is logically equivalent to zero.
    
      TransferLength (8 bytes):
    
        A 64-bit unsigned integer that contains the amount, in bytes, of data that the
        Token logically represents. This value indicates a contiguous region of the
        file from the beginning of the requested offset in the FileOffset field in the
        FSCTL_OFFLOAD_READ_INPUT data element (section 2.3.79). This value can be
        smaller than the CopyLength field specified in the FSCTL_OFFLOAD_READ_INPUT
        data element, which indicates that less data was logically
        represented (logically read) with the Token than was requested. The value of
        this field MUST be greater than 0x0000000000000000 and MUST be aligned to a
        logical sector boundary on the volume.
    
    As we currently only implement COPY_CHUNK over the OFFLOAD VFS interface, the
    VFS COPY_CHUNK backend in vfs_default just sets both values to 0 and they are
    unused in the SMB frontend.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3afd4bd61033773312605102f7203ef54e2e0986
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Jun 18 16:32:53 2021 +0200

    idl: declare token array of storage_offload_token as in-line
    
    This ensures the order of the struct element is the same as in the IDL
    definition. For an conformant array using the [sizeis(n)] syntax the sizeis
    member is stored as first element in the marshall buffer.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 83ad7e01fc34d26cbe1a524d7f2ea3a60f2cbfb4
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Oct 7 11:22:59 2021 +0200

    rpc_server3: Remove pipes_struct->private_data
    
    netlogon3 was the only user
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 426a7b4805597b47df176288e3ed981b69d9c207
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Oct 7 11:22:20 2021 +0200

    rpc_server3: Use dcesrv_iface_state in netlogon3
    
    Align with the source4/rpc_server/netlogon
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 246a5ceab1cba9935af436154172b9e39dc685d7
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Oct 7 10:07:48 2021 +0200

    netlogon: Move netlogon_server_pipe_state to netlogon.idl
    
    Make this available as a shared structure for both source3 and source4
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 81a7b2e08ddd4efd330dfeeada5577192f8281bf
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Oct 4 10:25:14 2021 +0200

    rpc_server3: Remove an outdated comment
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ed9e2850bfc2b4d89da45b36871afe5d6ec88bd0
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Oct 4 10:19:24 2021 +0200

    rpc_server3: Remove "pipes_struct->opnum"
    
    Also available via dce_call->pkt.u.request.opnum
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2e3cea27fc0e5c8bf6117b72255813be62d65707
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Oct 4 10:07:09 2021 +0200

    rpc_server3: Remove "pipes_struct->call_id"
    
    Unused.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e5b446fe116fa6b66e86658a26a38cd40382e996
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Oct 6 10:33:50 2021 +0200

    libcli: Simplify get_sec_mask_str()
    
    Use talloc_asprintf_addbuf()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3a8374b831a8b5faf40e87884b08bff91be3aa5f
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Oct 6 10:47:48 2021 +0200

    dsdb: Simplify schema_attribute_description() & friends
    
    Use talloc_asprintf_addbuf()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 61b06695b703908d57c36077f8707b99124127c9
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Oct 6 10:13:52 2021 +0200

    winbind: Simplify winbindd_sids_to_xids_recv()
    
    Use talloc_asprintf_addbuf(), fix an realloc error path memleak
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit fc4ee9c494d5a0c9330db50337dfec55d1bb127f
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Oct 6 10:10:21 2021 +0200

    winbind: Simplify winbindd_getusersids_recv()
    
    Use talloc_asprintf_addbuf(), fix an realloc error path memleak
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4869497b709789d159e2b0f917218f57516d2e09
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Oct 6 10:09:45 2021 +0200

    winbind: Simplify winbindd_getsidaliases_recv()
    
    Use talloc_asprintf_addbuf(), fix an realloc error path memleak
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0853a7a2bbfc8dc32c3ec1fa9498d01c02080217
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Oct 6 10:01:07 2021 +0200

    lib: Use talloc_asprintf_addbuf() in utok_string()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 18cbeab98bd4c943410936001b541c1a66d5babc
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Oct 6 09:54:46 2021 +0200

    librpc: Use talloc_asprintf_addbuf() in dcerpc_binding_string()
    
    Saves quite a few lines
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 20536080a5699fb33305510a67b401680b042e00
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Oct 6 09:53:57 2021 +0200

    lib: Add talloc_asprintf_addbuf()
    
    Simplifies building up a string step by step, see next commit
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 55ec7e6d00fb807d3eb96c84d47148b95f1a88da
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Oct 6 10:09:27 2021 +0200

    winbind: Align an integer type
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 10ac08fc1dbbd9ecb9438db906b2b50d8ebd73fa
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Oct 6 11:10:57 2021 +0200

    rpc_server3: Remove unused fields from struct dcerpc_ncacn_conn
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 34c08da059dc22021cdfe39223cc263d35e6d209
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Oct 6 09:20:44 2021 +0200

    libcli: Align integer types
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 423e5726d2d066e6504de4aca5985c90999d1be3
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Oct 6 09:16:32 2021 +0200

    libcli: Avoid an includes.h
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 668d3459ac6ba88d8f7114c80b6fc8f64597ac69
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Sep 30 09:27:10 2021 +0200

    idmap_script: Save a few lines with str_list_add_printf()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c38e2d5ff56263bd828a458a79acdbe271f6f00b
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Oct 5 21:44:53 2021 +0200

    lib: Fix a typo in a DEBUG fn prefix by using DBG_
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 761ede419fcdb9abc4cd5c5a188a4c73d31413c0
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Oct 5 21:40:45 2021 +0200

    lib: Simplify set_privileges with a struct initialization
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b266d39dbb85bad46f0f305f33f45f50e5f9386d
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Oct 5 21:31:41 2021 +0200

    lib: Avoid a cast in a DBG statement
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit f24b2163be0c2dfb7ae8fa2f33d4f4bbeb422d03
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Sep 25 08:23:03 2021 +0200

    libcli: Simplify security_session_user_level()
    
    Use sid_compose(), use struct dom_sid on the stack.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 70b1260020d61b8722e9af4290ce1ef61a4969ca
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Sep 25 08:20:18 2021 +0200

    libcli: Introduce a helper variable in security_session_user_level()
    
    Makes it easier to read for me
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 82281ca34f9fb00c803243fc840a2d4996eef1b5
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Sep 25 07:58:47 2021 +0200

    libcli: Remove unused security_token_has_sid_string()
    
    This should have been removed in ef990008f22, I just was not aware
    it's there...
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 187529c979c0bba1dad0034df55cf918dae74971
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Sep 28 11:28:01 2021 +0200

    samba: Save a line with TALLOC_FREE
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 5529aa8c4dacaf71e3d88817d2b96f6994881e22
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Sep 25 08:25:14 2021 +0200

    smbd: Avoid ZERO_STRUCT() with a struct init
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 9b260ff83906af57f21f97e3bb219b8fc550be2a
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Oct 4 10:10:42 2021 +0200

    lsa_server3: Align integer types
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a767eb55d8bd3109907baff311e221dc340ca6ba
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Oct 8 11:38:30 2021 +0200

    rpc_server3: Avoid a literal number available as a constant
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e2256c99a6591092937b9395e39c2a7f461db42e
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Oct 8 11:34:23 2021 +0200

    smbd: Make SID_SAMBA_SMB3 a static SID
    
    No need to parse it
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 examples/VFS/skel_opaque.c                       |   2 +
 examples/VFS/skel_transparent.c                  |   8 +
 lib/util/samba_util.h                            |  14 ++
 lib/util/sys_rw.c                                |  15 ++
 lib/util/sys_rw.h                                |   2 +
 lib/util/tests/test_sys_rw.c                     |  68 ++++++++
 lib/util/util_str.c                              |  23 +++
 libcli/security/display_sec.c                    |  70 ++------
 libcli/security/dom_sid.h                        |   1 +
 libcli/security/privileges.c                     |  30 ++--
 libcli/security/privileges.h                     |   2 +
 libcli/security/security_token.c                 |  14 --
 libcli/security/security_token.h                 |   2 -
 libcli/security/session.c                        |  23 +--
 libcli/security/util_sid.c                       |   4 +
 librpc/idl/ioctl.idl                             |   2 +-
 librpc/idl/netlogon.idl                          |   6 +
 librpc/idl/security.idl                          |   3 -
 librpc/rpc/binding.c                             |  89 +++-------
 librpc/rpc/dcerpc_helper.c                       |   9 +-
 pidl/lib/Parse/Pidl/Samba4/NDR/ServerCompat.pm   |   2 -
 source3/include/vfs.h                            |   7 +
 source3/include/vfs_macros.h                     |   8 +-
 source3/lib/privileges.c                         |  13 +-
 source3/lib/util.c                               |  13 +-
 source3/modules/offload_token.c                  |  12 +-
 source3/modules/offload_token.h                  |   4 +
 source3/modules/vfs_btrfs.c                      |   8 +
 source3/modules/vfs_default.c                    |   4 +
 source3/modules/vfs_fruit.c                      |   8 +
 source3/modules/vfs_full_audit.c                 |   4 +-
 source3/modules/vfs_not_implemented.c            |   2 +
 source3/modules/vfs_time_audit.c                 |   8 +
 source3/rpc_server/lsa/srv_lsa_nt.c              |   9 +-
 source3/rpc_server/netlogon/srv_netlog_nt.c      |  47 ++++--
 source3/rpc_server/rpc_handles.c                 |  10 --
 source3/rpc_server/rpc_pipes.h                   |  10 --
 source3/rpc_server/rpc_server.h                  |   4 -
 source3/rpc_server/samr/srv_samr_nt.c            |   4 +-
 source3/rpc_server/spoolss/srv_iremotewinspool.c |   2 -
 source3/smbd/open.c                              |   6 +-
 source3/smbd/pipes.c                             |   8 +-
 source3/smbd/smb2_ioctl_filesys.c                |   8 +-
 source3/smbd/smb2_ioctl_network_fs.c             |   7 +
 source3/smbd/vfs.c                               |   4 +-
 source3/winbindd/idmap_script.c                  |  48 ++----
 source3/winbindd/winbindd_getsidaliases.c        |  18 +--
 source3/winbindd/winbindd_getusersids.c          |  14 +-
 source3/winbindd/winbindd_sids_to_xids.c         |  18 +--
 source4/dsdb/schema/schema_description.c         | 198 ++++++++++-------------
 source4/rpc_server/netlogon/dcerpc_netlogon.c    |   6 -
 source4/samba/service_stream.c                   |   3 +-
 52 files changed, 448 insertions(+), 456 deletions(-)


Changeset truncated at 500 lines:

diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c
index f393332c681..cc7bb880d5c 100644
--- a/examples/VFS/skel_opaque.c
+++ b/examples/VFS/skel_opaque.c
@@ -560,6 +560,8 @@ static struct tevent_req *skel_offload_read_send(
 static NTSTATUS skel_offload_read_recv(struct tevent_req *req,
 				       struct vfs_handle_struct *handle,
 				       TALLOC_CTX *mem_ctx,
+				       uint32_t *flags,
+				       uint64_t *xferlen,
 				       DATA_BLOB *_token_blob)
 {
 	NTSTATUS status;
diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c
index d6bf3171b95..e145881b704 100644
--- a/examples/VFS/skel_transparent.c
+++ b/examples/VFS/skel_transparent.c
@@ -667,6 +667,8 @@ static uint64_t skel_fs_file_id(vfs_handle_struct *handle,
 
 struct skel_offload_read_state {
 	struct vfs_handle_struct *handle;
+	uint32_t flags;
+	uint64_t xferlen;
 	DATA_BLOB token;
 };
 
@@ -714,6 +716,8 @@ static void skel_offload_read_done(struct tevent_req *subreq)
 	status = SMB_VFS_NEXT_OFFLOAD_READ_RECV(subreq,
 						state->handle,
 						state,
+						&state->flags,
+						&state->xferlen,
 						&state->token);
 	TALLOC_FREE(subreq);
 	if (tevent_req_nterror(req, status)) {
@@ -727,6 +731,8 @@ static void skel_offload_read_done(struct tevent_req *subreq)
 static NTSTATUS skel_offload_read_recv(struct tevent_req *req,
 				       struct vfs_handle_struct *handle,
 				       TALLOC_CTX *mem_ctx,
+				       uint32_t *flags,
+				       uint64_t *xferlen,
 				       DATA_BLOB *_token)
 {
 	struct skel_offload_read_state *state = tevent_req_data(
@@ -749,6 +755,8 @@ static NTSTATUS skel_offload_read_recv(struct tevent_req *req,
 		return NT_STATUS_NO_MEMORY;
 	}
 
+	*flags = state->flags;
+	*xferlen = state->xferlen;
 	*_token = token;
 	return NT_STATUS_OK;
 }
diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h
index 4e279b72df1..ca185909997 100644
--- a/lib/util/samba_util.h
+++ b/lib/util/samba_util.h
@@ -325,6 +325,20 @@ _PUBLIC_ bool conv_str_u64(const char * str, uint64_t * val);
  */
 _PUBLIC_ int memcmp_const_time(const void *s1, const void *s2, size_t n);
 
+/**
+ * @brief Build up a string buffer, handle allocation failure
+ *
+ * @param[in] ps Pointer to the talloc'ed string to be extended
+ * @param[in] fmt The format string
+ * @param[in] ... The parameters used to fill fmt.
+ *
+ * This does nothing if *ps is NULL and sets *ps to NULL if the
+ * intermediate reallocation fails. Useful when building up a string
+ * step by step, no intermediate NULL checks are required.
+ */
+
+_PUBLIC_ void talloc_asprintf_addbuf(char **ps, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
+
 /**
 Do a case-insensitive, whitespace-ignoring string compare.
 **/
diff --git a/lib/util/sys_rw.c b/lib/util/sys_rw.c
index 02aaa871a39..d25a42b7082 100644
--- a/lib/util/sys_rw.c
+++ b/lib/util/sys_rw.c
@@ -23,6 +23,7 @@
 #include "replace.h"
 #include "system/filesys.h"
 #include "lib/util/sys_rw.h"
+#include <assert.h>
 
 bool sys_valid_io_range(off_t offset, size_t length)
 {
@@ -73,6 +74,20 @@ bool sys_io_ranges_overlap(size_t c1, off_t o1,
 	}
 }
 
+off_t sys_block_align_truncate(off_t len, off_t align)
+{
+	assert(align > 1);
+	assert(((align - 1) & align) == 0);
+	return len & (~align + 1);
+}
+
+off_t sys_block_align(off_t len, off_t align)
+{
+	assert(align > 1);
+	assert(((align - 1) & align) == 0);
+	return (len + (align - 1)) & ~(align - 1);
+}
+
 /*******************************************************************
 A read wrapper that will deal with EINTR/EWOULDBLOCK
 ********************************************************************/
diff --git a/lib/util/sys_rw.h b/lib/util/sys_rw.h
index 6693d34de57..3812159a362 100644
--- a/lib/util/sys_rw.h
+++ b/lib/util/sys_rw.h
@@ -27,6 +27,8 @@
 
 struct iovec;
 
+off_t sys_block_align_truncate(off_t len, off_t align);
+off_t sys_block_align(off_t len, off_t align);
 bool sys_valid_io_range(off_t offset, size_t length);
 bool sys_io_ranges_overlap(size_t c1, off_t o1,
 			   size_t c2, off_t o2);
diff --git a/lib/util/tests/test_sys_rw.c b/lib/util/tests/test_sys_rw.c
index 551a6a09bda..22688fb0446 100644
--- a/lib/util/tests/test_sys_rw.c
+++ b/lib/util/tests/test_sys_rw.c
@@ -98,10 +98,78 @@ static void test_sys_io_ranges_overlap(void **state)
 	assert_true(overlap);
 }
 
+static void test_sys_block_align(void **state)
+{
+	int asize;
+
+	asize = sys_block_align(0, 2);
+	assert_int_equal(asize, 0);
+	asize = sys_block_align(1, 2);
+	assert_int_equal(asize, 2);
+	asize = sys_block_align(2, 2);
+	assert_int_equal(asize, 2);
+	asize = sys_block_align(3, 2);
+	assert_int_equal(asize, 4);
+
+	asize = sys_block_align(0, 4);
+	assert_int_equal(asize, 0);
+	asize = sys_block_align(1, 4);
+	assert_int_equal(asize, 4);
+	asize = sys_block_align(3, 4);
+	assert_int_equal(asize, 4);
+	asize = sys_block_align(4, 4);
+	assert_int_equal(asize, 4);
+	asize = sys_block_align(5, 4);
+	assert_int_equal(asize, 8);
+	asize = sys_block_align(7, 4);
+	assert_int_equal(asize, 8);
+	asize = sys_block_align(8, 4);
+	assert_int_equal(asize, 8);
+	asize = sys_block_align(9, 4);
+	assert_int_equal(asize, 12);
+}
+
+static void test_sys_block_align_truncate(void **state)
+{
+	int asize;
+
+	asize = sys_block_align_truncate(0, 2);
+	assert_int_equal(asize, 0);
+	asize = sys_block_align_truncate(1, 2);
+	assert_int_equal(asize, 0);
+	asize = sys_block_align_truncate(2, 2);
+	assert_int_equal(asize, 2);
+	asize = sys_block_align_truncate(3, 2);
+	assert_int_equal(asize, 2);
+	asize = sys_block_align_truncate(4, 2);
+	assert_int_equal(asize, 4);
+	asize = sys_block_align_truncate(5, 2);
+	assert_int_equal(asize, 4);
+
+	asize = sys_block_align_truncate(0, 4);
+	assert_int_equal(asize, 0);
+	asize = sys_block_align_truncate(1, 4);
+	assert_int_equal(asize, 0);
+	asize = sys_block_align_truncate(3, 4);
+	assert_int_equal(asize, 0);
+	asize = sys_block_align_truncate(4, 4);
+	assert_int_equal(asize, 4);
+	asize = sys_block_align_truncate(5, 4);
+	assert_int_equal(asize, 4);
+	asize = sys_block_align_truncate(7, 4);
+	assert_int_equal(asize, 4);
+	asize = sys_block_align_truncate(8, 4);
+	assert_int_equal(asize, 8);
+	asize = sys_block_align_truncate(9, 4);
+	assert_int_equal(asize, 8);
+}
+
 int main(int argc, char **argv)
 {
 	const struct CMUnitTest tests[] = {
 		cmocka_unit_test(test_sys_io_ranges_overlap),
+		cmocka_unit_test(test_sys_block_align),
+		cmocka_unit_test(test_sys_block_align_truncate),
 	};
 
 	cmocka_set_message_output(CM_OUTPUT_SUBUNIT);
diff --git a/lib/util/util_str.c b/lib/util/util_str.c
index da1989f80f2..b5ba3fb716b 100644
--- a/lib/util/util_str.c
+++ b/lib/util/util_str.c
@@ -316,3 +316,26 @@ _PUBLIC_ int memcmp_const_time(const void *s1, const void *s2, size_t n)
 
 	return sum != 0;
 }
+
+_PUBLIC_ void talloc_asprintf_addbuf(char **ps, const char *fmt, ...)
+{
+	va_list ap;
+	char *s = *ps;
+	char *t = NULL;
+
+	if (s == NULL) {
+		return;
+	}
+
+	va_start(ap, fmt);
+	t = talloc_vasprintf_append_buffer(s, fmt, ap);
+	va_end(ap);
+
+	if (t == NULL) {
+		/* signal failure to the next caller */
+		TALLOC_FREE(s);
+		*ps = NULL;
+	} else {
+		*ps = t;
+	}
+}
diff --git a/libcli/security/display_sec.c b/libcli/security/display_sec.c
index 506ecf6d89d..d75b89071c3 100644
--- a/libcli/security/display_sec.c
+++ b/libcli/security/display_sec.c
@@ -31,86 +31,38 @@ char *get_sec_mask_str(TALLOC_CTX *ctx, uint32_t type)
 {
 	char *typestr = talloc_strdup(ctx, "");
 
-	if (!typestr) {
-		return NULL;
-	}
-
 	if (type & SEC_GENERIC_ALL) {
-		typestr = talloc_asprintf_append(typestr,
-				"Generic all access ");
-		if (!typestr) {
-			return NULL;
-		}
+		talloc_asprintf_addbuf(&typestr, "Generic all access ");
 	}
 	if (type & SEC_GENERIC_EXECUTE) {
-		typestr = talloc_asprintf_append(typestr,
-				"Generic execute access");
-		if (!typestr) {
-			return NULL;
-		}
+		talloc_asprintf_addbuf(&typestr, "Generic execute access");
 	}
 	if (type & SEC_GENERIC_WRITE) {
-		typestr = talloc_asprintf_append(typestr,
-				"Generic write access ");
-		if (!typestr) {
-			return NULL;
-		}
+		talloc_asprintf_addbuf(&typestr, "Generic write access ");
 	}
 	if (type & SEC_GENERIC_READ) {
-		typestr = talloc_asprintf_append(typestr,
-				"Generic read access ");
-		if (!typestr) {
-			return NULL;
-		}
+		talloc_asprintf_addbuf(&typestr, "Generic read access ");
 	}
 	if (type & SEC_FLAG_MAXIMUM_ALLOWED) {
-		typestr = talloc_asprintf_append(typestr,
-				"MAXIMUM_ALLOWED_ACCESS ");
-		if (!typestr) {
-			return NULL;
-		}
+		talloc_asprintf_addbuf(&typestr, "MAXIMUM_ALLOWED_ACCESS ");
 	}
 	if (type & SEC_FLAG_SYSTEM_SECURITY) {
-		typestr = talloc_asprintf_append(typestr,
-				"SYSTEM_SECURITY_ACCESS ");
-		if (!typestr) {
-			return NULL;
-		}
+		talloc_asprintf_addbuf(&typestr, "SYSTEM_SECURITY_ACCESS ");
 	}
 	if (type & SEC_STD_SYNCHRONIZE) {
-		typestr = talloc_asprintf_append(typestr,
-				"SYNCHRONIZE_ACCESS ");
-		if (!typestr) {
-			return NULL;
-		}
+		talloc_asprintf_addbuf(&typestr, "SYNCHRONIZE_ACCESS ");
 	}
 	if (type & SEC_STD_WRITE_OWNER) {
-		typestr = talloc_asprintf_append(typestr,
-				"WRITE_OWNER_ACCESS ");
-		if (!typestr) {
-			return NULL;
-		}
+		talloc_asprintf_addbuf(&typestr, "WRITE_OWNER_ACCESS ");
 	}
 	if (type & SEC_STD_WRITE_DAC) {
-		typestr = talloc_asprintf_append(typestr,
-				"WRITE_DAC_ACCESS ");
-		if (!typestr) {
-			return NULL;
-		}
+		talloc_asprintf_addbuf(&typestr, "WRITE_DAC_ACCESS ");
 	}
 	if (type & SEC_STD_READ_CONTROL) {
-		typestr = talloc_asprintf_append(typestr,
-				"READ_CONTROL_ACCESS ");
-		if (!typestr) {
-			return NULL;
-		}
+		talloc_asprintf_addbuf(&typestr, "READ_CONTROL_ACCESS ");
 	}
 	if (type & SEC_STD_DELETE) {
-		typestr = talloc_asprintf_append(typestr,
-				"DELETE_ACCESS ");
-		if (!typestr) {
-			return NULL;
-		}
+		talloc_asprintf_addbuf(&typestr, "DELETE_ACCESS ");
 	}
 
 	printf("\t\tSpecific bits: 0x%lx\n", (unsigned long)type&SEC_MASK_SPECIFIC);
diff --git a/libcli/security/dom_sid.h b/libcli/security/dom_sid.h
index 678b2e21ba6..568916a159d 100644
--- a/libcli/security/dom_sid.h
+++ b/libcli/security/dom_sid.h
@@ -64,6 +64,7 @@ extern const struct dom_sid global_sid_Unix_NFS_Users;
 extern const struct dom_sid global_sid_Unix_NFS_Groups;
 extern const struct dom_sid global_sid_Unix_NFS_Mode;
 extern const struct dom_sid global_sid_Unix_NFS_Other;
+extern const struct dom_sid global_sid_Samba_SMB3;
 
 enum lsa_SidType;
 
diff --git a/libcli/security/privileges.c b/libcli/security/privileges.c
index d2731c3dd05..7910001c60d 100644
--- a/libcli/security/privileges.c
+++ b/libcli/security/privileges.c
@@ -32,10 +32,12 @@
  * some extra functions to hide privs array from lib/privileges.c
  */
 
-#include "includes.h"
+#include "replace.h"
 #include "libcli/security/privileges.h"
 #include "libcli/security/privileges_private.h"
 #include "librpc/gen_ndr/security.h"
+#include "lib/util/samba_util.h"
+#include "lib/util/debug.h"
 
 /* The use of strcasecmp here is safe, all the comparison strings are ASCII */
 #undef strcasecmp
@@ -173,7 +175,7 @@ static const struct {
 */
 uint64_t sec_privilege_mask(enum sec_privilege privilege)
 {
-	int i;
+	size_t i;
 	for (i=0;i<ARRAY_SIZE(privs);i++) {
 		if (privs[i].luid == privilege) {
 			return privs[i].privilege_mask;
@@ -189,7 +191,7 @@ uint64_t sec_privilege_mask(enum sec_privilege privilege)
 
 void se_priv_put_all_privileges(uint64_t *privilege_mask)
 {
-	int i;
+	size_t i;
 
 	*privilege_mask = 0;
 	for ( i=0; i<ARRAY_SIZE(privs); i++ ) {
@@ -203,7 +205,7 @@ void se_priv_put_all_privileges(uint64_t *privilege_mask)
 
 bool se_priv_from_name( const char *name, uint64_t *privilege_mask )
 {
-	int i;
+	size_t i;
 	for ( i=0; i<ARRAY_SIZE(privs); i++ ) {
 		if ( strequal( privs[i].name, name ) ) {
 			*privilege_mask = privs[i].privilege_mask;
@@ -216,7 +218,7 @@ bool se_priv_from_name( const char *name, uint64_t *privilege_mask )
 
 const char* get_privilege_dispname( const char *name )
 {
-	int i;
+	size_t i;
 
 	if (!name) {
 		return NULL;
@@ -271,7 +273,7 @@ static bool privilege_set_add(PRIVILEGE_SET *priv_set, struct lsa_LUIDAttribute
 
 bool se_priv_to_privilege_set( PRIVILEGE_SET *set, uint64_t privilege_mask )
 {
-	int i;
+	size_t i;
 	struct lsa_LUIDAttribute luid;
 
 	luid.attribute = 0;
@@ -323,7 +325,7 @@ bool privilege_set_to_se_priv( uint64_t *privilege_mask, struct lsa_PrivilegeSet
 */
 const char *sec_privilege_name(enum sec_privilege privilege)
 {
-	int i;
+	size_t i;
 	for (i=0;i<ARRAY_SIZE(privs);i++) {
 		if (privs[i].luid == privilege) {
 			return privs[i].name;
@@ -339,7 +341,7 @@ const char *sec_privilege_name(enum sec_privilege privilege)
 */
 const char *sec_privilege_display_name(enum sec_privilege privilege, uint16_t *language)
 {
-	int i;
+	size_t i;
 	for (i=0;i<ARRAY_SIZE(privs);i++) {
 		if (privs[i].luid == privilege) {
 			return privs[i].description;
@@ -353,7 +355,7 @@ const char *sec_privilege_display_name(enum sec_privilege privilege, uint16_t *l
 */
 enum sec_privilege sec_privilege_id(const char *name)
 {
-	int i;
+	size_t i;
 	for (i=0;i<ARRAY_SIZE(privs);i++) {
 		if (strcasecmp(privs[i].name, name) == 0) {
 			return privs[i].luid;
@@ -367,7 +369,7 @@ enum sec_privilege sec_privilege_id(const char *name)
 */
 uint32_t sec_right_bit(const char *name)
 {
-	int i;
+	size_t i;
 	for (i=0;i<ARRAY_SIZE(rights);i++) {
 		if (strcasecmp(rights[i].name, name) == 0) {
 			return rights[i].right_mask;
@@ -381,7 +383,7 @@ uint32_t sec_right_bit(const char *name)
 */
 enum sec_privilege sec_privilege_from_index(int idx)
 {
-	if (idx >= 0 && idx<ARRAY_SIZE(privs)) {
+	if (idx >= 0 && (unsigned)idx<ARRAY_SIZE(privs)) {
 		return privs[idx].luid;
 	}
 	return SEC_PRIV_INVALID;
@@ -392,7 +394,7 @@ enum sec_privilege sec_privilege_from_index(int idx)
 */
 const char *sec_privilege_name_from_index(int idx)
 {
-	if (idx >= 0 && idx<ARRAY_SIZE(privs)) {
+	if (idx >= 0 && (unsigned)idx<ARRAY_SIZE(privs)) {
 		return privs[idx].name;
 	}
 	return NULL;
@@ -458,7 +460,7 @@ void security_token_debug_privileges(int dbg_class, int dbg_lev, const struct se
 				       (unsigned long long) token->privilege_mask));
 
 	if (token->privilege_mask) {
-		int idx = 0;
+		size_t idx = 0;
 		int i = 0;
 		for (idx = 0; idx<ARRAY_SIZE(privs); idx++) {
 			if (token->privilege_mask & privs[idx].privilege_mask) {
@@ -472,7 +474,7 @@ void security_token_debug_privileges(int dbg_class, int dbg_lev, const struct se
 				       (unsigned long) token->rights_mask));
 
 	if (token->rights_mask) {
-		int idx = 0;
+		size_t idx = 0;
 		int i = 0;
 		for (idx = 0; idx<ARRAY_SIZE(rights); idx++) {
 			if (token->rights_mask & rights[idx].right_mask) {
diff --git a/libcli/security/privileges.h b/libcli/security/privileges.h
index eb3ab5e784d..c8a8dadd630 100644
--- a/libcli/security/privileges.h
+++ b/libcli/security/privileges.h
@@ -25,6 +25,8 @@
 #ifndef PRIVILEGES_H
 #define PRIVILEGES_H
 
+#include "lib/util/data_blob.h"
+#include "lib/util/time.h"
 #include "../librpc/gen_ndr/lsa.h"
 #include "../librpc/gen_ndr/security.h"
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list