The branch, master has been updated via be944dce00e srvsvcd: Silence a integer type warning via 5f82f01a3be srvsvcd: Avoid an "else" due to the early return via d4a6e72d5c5 srvsvcd: Directly initialize variables in count_for_all_fn() via 48168614d45 srvsvcd: Align integer types via c90aff07ab8 srvsvcd: Fix shareinfo2 max_connections calculation via 8ea8526d131 srvsvcd: Use UINT32_MAX where appropriate via 78ebd8af885 registry3: Align some integer types via a771f1d314b smbd: Simplify copy_file() via e7a60eb7c93 smbd: Simplify copy_file() from 9bacf7529dd s3:winbind: Remove struct winbindd_child_dispatch_table
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit be944dce00e7bad5af68aea0f75c0dd2f2ce26ae Author: Volker Lendecke <v...@samba.org> Date: Sun May 15 13:30:09 2022 +0200 srvsvcd: Silence a integer type warning Okay because lp_csc_policy() is an enum with 4 choices Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Fri May 20 19:59:07 UTC 2022 on sn-devel-184 commit 5f82f01a3be1ff805b3203bc0af806db7800cc76 Author: Volker Lendecke <v...@samba.org> Date: Sun May 15 13:20:34 2022 +0200 srvsvcd: Avoid an "else" due to the early return Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit d4a6e72d5c5bd3556907874045cce9a4782b0730 Author: Volker Lendecke <v...@samba.org> Date: Sun May 15 13:19:35 2022 +0200 srvsvcd: Directly initialize variables in count_for_all_fn() Easier to read for me Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 48168614d4582a6c0466e3a8b83d3d524c47523d Author: Volker Lendecke <v...@samba.org> Date: Sun May 15 13:18:24 2022 +0200 srvsvcd: Align integer types Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit c90aff07ab82d3e91729d89d48bc14dbb348d0d6 Author: Volker Lendecke <v...@samba.org> Date: Sun May 15 13:17:06 2022 +0200 srvsvcd: Fix shareinfo2 max_connections calculation lp_max_connections() being an int could be >UINT32_MAX Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 8ea8526d131107f6d2e71bc56753f89e7125c778 Author: Volker Lendecke <v...@samba.org> Date: Sun May 15 13:15:31 2022 +0200 srvsvcd: Use UINT32_MAX where appropriate Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 78ebd8af885841a39eece623623a7807a83903c4 Author: Volker Lendecke <v...@samba.org> Date: Thu May 19 20:10:52 2022 +0200 registry3: Align some integer types Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit a771f1d314bc41b59a279b1859ed28714bed3040 Author: Volker Lendecke <v...@samba.org> Date: Fri May 20 08:06:28 2022 +0200 smbd: Simplify copy_file() Pass in new_create_disposition directly. We can also remove the if-case (ofun & OPENX_FILE_EXISTS_OPEN) in copy_file, the two callers don't use it. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit e7a60eb7c93f18af0ce05e16511f3c7b17617273 Author: Volker Lendecke <v...@samba.org> Date: Thu May 19 20:43:40 2022 +0200 smbd: Simplify copy_file() The only two callers did not use "count" and "target_is_directory". Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/modules/vfs_fruit.c | 3 +- source3/printing/nt_printing.c | 4 +-- source3/registry/reg_backend_db.c | 6 ++-- source3/registry/reg_parse.c | 4 +-- source3/rpc_server/srvsvc/srv_srvsvc_nt.c | 32 +++++++++--------- source3/smbd/proto.h | 4 +-- source3/smbd/smb2_reply.c | 56 +------------------------------ 7 files changed, 26 insertions(+), 83 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 183c4e02371..05ab8fcea69 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -4781,8 +4781,7 @@ static void fruit_offload_write_done(struct tevent_req *subreq) state->handle->conn, src_fname_tmp, dst_fname_tmp, - OPENX_FILE_CREATE_IF_NOT_EXIST, - 0, false); + FILE_CREATE); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("%s: copy %s to %s failed: %s\n", __func__, smb_fname_str_dbg(src_fname_tmp), diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 6961a4ddda9..0929e532436 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -1460,9 +1460,7 @@ static WERROR move_driver_file_to_download_area(TALLOC_CTX *mem_ctx, smb_fname_new->base_name)); status = copy_file(mem_ctx, conn, smb_fname_old, smb_fname_new, - OPENX_FILE_EXISTS_TRUNCATE | - OPENX_FILE_CREATE_IF_NOT_EXIST, - 0, false); + FILE_OVERWRITE_IF); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("move_driver_file_to_download_area: Unable " diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c index b1f6425d56a..829b82d9059 100644 --- a/source3/registry/reg_backend_db.c +++ b/source3/registry/reg_backend_db.c @@ -1045,7 +1045,7 @@ static WERROR regdb_store_keys_internal2(struct db_context *db, { TDB_DATA dbuf; uint8_t *buffer = NULL; - int i = 0; + uint32_t i = 0; uint32_t len, buflen; uint32_t num_subkeys = regsubkey_ctr_numkeys(ctr); char *keyname = NULL; @@ -1739,7 +1739,7 @@ static WERROR regdb_fetch_keys_internal(struct db_context *db, const char *key, uint32_t num_items; uint8_t *buf; uint32_t buflen, len; - int i; + uint32_t i; fstring subkeyname; TALLOC_CTX *frame = talloc_stackframe(); TDB_DATA value; @@ -1854,7 +1854,7 @@ static int regdb_unpack_values(struct regval_ctr *values, uint32_t size; uint8_t *data_p; uint32_t num_values = 0; - int i; + uint32_t i; /* loop and unpack the rest of the registry values */ diff --git a/source3/registry/reg_parse.c b/source3/registry/reg_parse.c index 6230b000c3b..dc084dc51b7 100644 --- a/source3/registry/reg_parse.c +++ b/source3/registry/reg_parse.c @@ -641,7 +641,7 @@ static bool lookslike_utf16(const char* line, size_t len, bool* little_endian) size_t l = MIN(len/2, 64); const uint16_t* u = (const uint16_t*)line; - int i; + size_t i; assert(len >= 2); @@ -667,7 +667,7 @@ static bool lookslike_utf16(const char* line, size_t len, bool* little_endian) static bool lookslike_dos(const char* line, size_t len) { - int i; + size_t i; for (i=0; i<len; i++) { if ( (line[i] == '\0') || (line[i] & 0x80) ) { return false; diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c index 99808ee8f3a..b6f2b34b8e8 100644 --- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c +++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c @@ -282,9 +282,13 @@ static void init_srv_share_info_2(struct pipes_struct *p, char *remark = NULL; char *path = NULL; int max_connections = lp_max_connections(snum); - uint32_t max_uses = max_connections!=0 ? max_connections : (uint32_t)-1; + uint32_t max_uses = UINT32_MAX; char *net_name = lp_servicename(talloc_tos(), lp_sub, snum); + if (max_connections > 0) { + max_uses = MIN(max_connections, UINT32_MAX); + } + remark = lp_comment(p->mem_ctx, lp_sub, snum); if (remark) { remark = talloc_sub_full( @@ -322,7 +326,7 @@ static void init_srv_share_info_2(struct pipes_struct *p, static void map_generic_share_sd_bits(struct security_descriptor *psd) { - int i; + uint32_t i; struct security_acl *ps_dacl = NULL; if (!psd) @@ -563,16 +567,14 @@ static bool is_enumeration_allowed(struct pipes_struct *p, static int count_for_all_fn(struct smbXsrv_tcon_global0 *tcon, void *udp) { - union srvsvc_NetShareCtr *ctr = NULL; - struct srvsvc_NetShareInfo2 *info2 = NULL; - int share_entries = 0; - int i = 0; + union srvsvc_NetShareCtr *ctr = udp; - ctr = (union srvsvc_NetShareCtr *) udp; + /* Only called for level2 */ + struct srvsvc_NetShareCtr2 *ctr2 = ctr->ctr2; - /* for level 2 */ - share_entries = ctr->ctr2->count; - info2 = &ctr->ctr2->array[0]; + uint32_t share_entries = ctr2->count; + struct srvsvc_NetShareInfo2 *info2 = ctr2->array; + uint32_t i = 0; for (i = 0; i < share_entries; i++, info2++) { if (strequal(tcon->share_name, info2->name)) { @@ -974,7 +976,7 @@ static int count_sess_files_fn(struct file_id fid, { struct sess_file_info *info = data; uint32_t rh = info->resume_handle; - int i; + uint32_t i; for (i=0; i < info->num_entries; i++) { /* rh+info->num_entries is safe, as we've @@ -1968,13 +1970,13 @@ WERROR _srvsvc_NetShareSetInfo(struct pipes_struct *p, SHARE_1005_CSC_POLICY_MASK) >> SHARE_1005_CSC_POLICY_SHIFT; - if (client_csc_policy == lp_csc_policy(snum)) + if (client_csc_policy == (uint32_t)lp_csc_policy(snum)) { return WERR_OK; - else { - csc_policy = csc_policies[client_csc_policy]; - csc_policy_changed = true; } + csc_policy = csc_policies[client_csc_policy]; + csc_policy_changed = true; + pathname = lp_path(ctx, lp_sub, snum); comment = lp_comment(ctx, lp_sub, snum); type = STYPE_DISKTREE; diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index f49191b721f..9917562d1de 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -988,9 +988,7 @@ NTSTATUS copy_file(TALLOC_CTX *ctx, connection_struct *conn, struct smb_filename *smb_fname_src, struct smb_filename *smb_fname_dst, - int ofun, - int count, - bool target_is_directory); + uint32_t new_create_disposition); uint64_t get_lock_offset(const uint8_t *data, int data_offset, bool large_file_format); diff --git a/source3/smbd/smb2_reply.c b/source3/smbd/smb2_reply.c index 5f3c9be41eb..673c1e2216b 100644 --- a/source3/smbd/smb2_reply.c +++ b/source3/smbd/smb2_reply.c @@ -1836,15 +1836,12 @@ NTSTATUS copy_file(TALLOC_CTX *ctx, connection_struct *conn, struct smb_filename *smb_fname_src, struct smb_filename *smb_fname_dst, - int ofun, - int count, - bool target_is_directory) + uint32_t new_create_disposition) { struct smb_filename *smb_fname_dst_tmp = NULL; off_t ret=-1; files_struct *fsp1,*fsp2; uint32_t dosattrs; - uint32_t new_create_disposition; NTSTATUS status; @@ -1853,31 +1850,6 @@ NTSTATUS copy_file(TALLOC_CTX *ctx, return NT_STATUS_NO_MEMORY; } - /* - * If the target is a directory, extract the last component from the - * src filename and append it to the dst filename - */ - if (target_is_directory) { - const char *p; - - /* dest/target can't be a stream if it's a directory. */ - SMB_ASSERT(smb_fname_dst->stream_name == NULL); - - p = strrchr_m(smb_fname_src->base_name,'/'); - if (p) { - p++; - } else { - p = smb_fname_src->base_name; - } - smb_fname_dst_tmp->base_name = - talloc_asprintf_append(smb_fname_dst_tmp->base_name, "/%s", - p); - if (!smb_fname_dst_tmp->base_name) { - status = NT_STATUS_NO_MEMORY; - goto out; - } - } - status = vfs_file_exist(conn, smb_fname_src); if (!NT_STATUS_IS_OK(status)) { goto out; @@ -1888,20 +1860,6 @@ NTSTATUS copy_file(TALLOC_CTX *ctx, goto out; } - if (!target_is_directory && count) { - new_create_disposition = FILE_OPEN; - } else { - if (!map_open_params_to_ntcreate(smb_fname_dst_tmp->base_name, - 0, ofun, - NULL, NULL, - &new_create_disposition, - NULL, - NULL)) { - status = NT_STATUS_INVALID_PARAMETER; - goto out; - } - } - /* Open the src file for reading. */ status = SMB_VFS_CREATE_FILE( conn, /* conn */ @@ -1966,18 +1924,6 @@ NTSTATUS copy_file(TALLOC_CTX *ctx, goto out; } - if (ofun & OPENX_FILE_EXISTS_OPEN) { - ret = SMB_VFS_LSEEK(fsp2, 0, SEEK_END); - if (ret == -1) { - DEBUG(0, ("error - vfs lseek returned error %s\n", - strerror(errno))); - status = map_nt_error_from_unix(errno); - close_file_free(NULL, &fsp1, ERROR_CLOSE); - close_file_free(NULL, &fsp2, ERROR_CLOSE); - goto out; - } - } - /* Do the actual copy. */ if (smb_fname_src->st.st_ex_size) { ret = vfs_transfer_file(fsp1, fsp2, smb_fname_src->st.st_ex_size); -- Samba Shared Repository