The branch, master has been updated via 39e3300b8d8 smbd: Some README.Coding in smbd_do_qfilepathinfo() via ebb8084c67b samr_server: Modernize a DBG statement via 73a27939676 samr_server: Avoid a DEBUGADD() via 995d1958e9a lib: Simplify grant_privilege_bitmap() via 8e741b596e9 lib: Modernize (and fix) a DBG statement via 36303bbdec4 libsmb: Fix whitespace and a typo via 6877e4849e8 lib: Avoid 70k of r/w memory via 24ad425e284 lib: Simplify hresult.c from 13d98c8fa6d s3:passdb: Fix memory leak caused by recursion of get_global_sam_sid()
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 39e3300b8d8f01a39a5ec80b22724b21e91d34d6 Author: Volker Lendecke <v...@samba.org> Date: Wed Jan 3 10:34:42 2024 +0100 smbd: Some README.Coding in smbd_do_qfilepathinfo() 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): Wed Jan 24 00:35:33 UTC 2024 on atb-devel-224 commit ebb8084c67b35b11a24f56e6f6c8217b4e3f752c Author: Volker Lendecke <v...@samba.org> Date: Mon Dec 18 22:03:07 2023 +0100 samr_server: Modernize a DBG statement Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 73a279396769b54d045b7cdf0fff9a045dd50d69 Author: Volker Lendecke <v...@samba.org> Date: Mon Dec 18 22:00:26 2023 +0100 samr_server: Avoid a DEBUGADD() Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 995d1958e9a83c3a19181a343d5c66894b1efee7 Author: Volker Lendecke <v...@samba.org> Date: Mon Dec 18 21:40:46 2023 +0100 lib: Simplify grant_privilege_bitmap() ZERO_STRUCT on a uint64_t doesn't really make sense... Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 8e741b596e908035a59fc635eed9cd5f62f2434a Author: Volker Lendecke <v...@samba.org> Date: Mon Dec 18 21:39:47 2023 +0100 lib: Modernize (and fix) a DBG statement Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 36303bbdec482b797234155c8e6929a550fb0527 Author: Volker Lendecke <v...@samba.org> Date: Mon Dec 18 21:13:56 2023 +0100 libsmb: Fix whitespace and a typo Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 6877e4849e81ed8f7f355fa4069f13a134e999ce Author: Volker Lendecke <v...@samba.org> Date: Mon Jan 22 21:21:54 2024 +0100 lib: Avoid 70k of r/w memory This adds more .text than it strips .data, but .text is shared between all processes, .data is copied. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 24ad425e2843ca321304bf8d503f52e0f6f8fd42 Author: Volker Lendecke <v...@samba.org> Date: Mon Jan 22 20:57:31 2024 +0100 lib: Simplify hresult.c Functions don't need a ; at the end. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/lib/privileges.c | 21 ++++++------- source3/libsmb/cliconnect.c | 12 ++++---- source3/libsmb/clidgram.c | 2 +- source3/libsmb/clierror.c | 2 +- source3/libsmb/clifile.c | 2 +- source3/libsmb/clifsinfo.c | 2 +- source3/libsmb/cliquota.c | 4 +-- source3/libsmb/clisecdesc.c | 2 +- source3/libsmb/conncache.c | 2 +- source3/libsmb/errormap.c | 9 +++--- source3/libsmb/errormap_wbc.c | 9 +++--- source3/libsmb/libsmb_thread_impl.c | 10 +++---- source3/libsmb/libsmb_thread_posix.c | 9 +++--- source3/libsmb/libsmb_xattr.c | 22 +++++++------- source3/libsmb/namequery_dc.c | 2 +- source3/libsmb/smberr.c | 4 +-- source3/rpc_server/samr/srv_samr_chgpasswd.c | 8 +++-- source3/rpc_server/samr/srv_samr_nt.c | 11 +++---- source3/smbd/smb2_trans2.c | 5 ++-- source4/scripting/bin/gen_hresult.py | 45 +++++++++------------------- 20 files changed, 82 insertions(+), 101 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/lib/privileges.c b/source3/lib/privileges.c index 789e05a9c44..05a4c9a1e76 100644 --- a/source3/lib/privileges.c +++ b/source3/lib/privileges.c @@ -339,24 +339,21 @@ NTSTATUS privilege_enum_sids(enum sec_privilege privilege, TALLOC_CTX *mem_ctx, static bool grant_privilege_bitmap(const struct dom_sid *sid, const uint64_t priv_mask) { - uint64_t old_mask, new_mask; + uint64_t old_mask = 0, new_mask = 0; struct dom_sid_buf buf; - ZERO_STRUCT( old_mask ); - ZERO_STRUCT( new_mask ); - - if ( get_privileges( sid, &old_mask ) ) + if ( get_privileges( sid, &old_mask ) ) { new_mask = old_mask; - else - new_mask = 0; + } new_mask |= priv_mask; - DEBUG(10,("grant_privilege: %s\n", dom_sid_str_buf(sid, &buf))); - - DEBUGADD( 10, ("original privilege mask: 0x%llx\n", (unsigned long long)new_mask)); - - DEBUGADD( 10, ("new privilege mask: 0x%llx\n", (unsigned long long)new_mask)); + DBG_DEBUG("%s\n" + "original privilege mask: 0x%"PRIx64"\n" + "new privilege mask: 0x%"PRIx64"\n", + dom_sid_str_buf(sid, &buf), + old_mask, + new_mask); return set_privileges( sid, new_mask ); } diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index af9f215dc75..61e35042586 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -1,4 +1,4 @@ -/* +/* Unix SMB/CIFS implementation. client connect/disconnect routines Copyright (C) Andrew Tridgell 1994-1998 @@ -2776,7 +2776,7 @@ static void cli_start_connection_connected(struct tevent_req *subreq); static void cli_start_connection_done(struct tevent_req *subreq); /** - establishes a connection to after the negprot. + establishes a connection to after the negprot. @param output_cli A fully initialised cli structure, non-null only on success @param dest_host The netbios name of the remote host @param dest_ss (optional) The destination IP, NULL for name based lookup @@ -2938,9 +2938,9 @@ static NTSTATUS cli_start_connection_recv(struct tevent_req *req, return NT_STATUS_OK; } -NTSTATUS cli_start_connection(struct cli_state **output_cli, - const char *my_name, - const char *dest_host, +NTSTATUS cli_start_connection(struct cli_state **output_cli, + const char *my_name, + const char *dest_host, const struct sockaddr_storage *dest_ss, int port, enum smb_signing_setting signing_state, int flags) { @@ -3387,7 +3387,7 @@ NTSTATUS cli_smb1_setup_encryption(struct cli_state *cli, @param dest_ip (optional) The the destination IP, NULL for name based lookup @param port (optional) The destination port (0 for default) @param service (optional) The share to make the connection to. Should be 'unqualified' in any way. - @param service_type The 'type' of serivice. + @param service_type The 'type' of service. @param creds The used user credentials */ diff --git a/source3/libsmb/clidgram.c b/source3/libsmb/clidgram.c index ec0b1efa8ce..a45bdac7771 100644 --- a/source3/libsmb/clidgram.c +++ b/source3/libsmb/clidgram.c @@ -1,4 +1,4 @@ -/* +/* Unix SMB/CIFS implementation. client dgram calls Copyright (C) Andrew Tridgell 1994-1998 diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 0a5df8b9ae3..afbec47934b 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -1,4 +1,4 @@ -/* +/* Unix SMB/CIFS implementation. client error handling routines Copyright (C) Andrew Tridgell 1994-1998 diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 5dc11f69458..cc1b4d40044 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -1,4 +1,4 @@ -/* +/* Unix SMB/CIFS implementation. client file operations Copyright (C) Andrew Tridgell 1994-1998 diff --git a/source3/libsmb/clifsinfo.c b/source3/libsmb/clifsinfo.c index 3183e2f4f43..cc95f47d4b1 100644 --- a/source3/libsmb/clifsinfo.c +++ b/source3/libsmb/clifsinfo.c @@ -1,4 +1,4 @@ -/* +/* Unix SMB/CIFS implementation. FS info functions Copyright (C) Stefan (metze) Metzmacher 2003 diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index 1f92960639e..0c41272f21a 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -1,4 +1,4 @@ -/* +/* Unix SMB/CIFS implementation. client quota functions Copyright (C) Stefan (metze) Metzmacher 2003 @@ -45,7 +45,7 @@ void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list) (*qt_list) = NULL; - return; + return; } bool add_record_to_ntquota_list(TALLOC_CTX *mem_ctx, diff --git a/source3/libsmb/clisecdesc.c b/source3/libsmb/clisecdesc.c index 0a5708f7ebd..d6a266191ab 100644 --- a/source3/libsmb/clisecdesc.c +++ b/source3/libsmb/clisecdesc.c @@ -1,4 +1,4 @@ -/* +/* Unix SMB/CIFS implementation. client security descriptor functions Copyright (C) Andrew Tridgell 2000 diff --git a/source3/libsmb/conncache.c b/source3/libsmb/conncache.c index d5a865fb112..7310b508a3b 100644 --- a/source3/libsmb/conncache.c +++ b/source3/libsmb/conncache.c @@ -1,4 +1,4 @@ -/* +/* Unix SMB/CIFS implementation. Winbind daemon connection manager diff --git a/source3/libsmb/errormap.c b/source3/libsmb/errormap.c index ba8bc659bab..fd7d6a19e9a 100644 --- a/source3/libsmb/errormap.c +++ b/source3/libsmb/errormap.c @@ -1,20 +1,20 @@ -/* +/* * Unix SMB/CIFS implementation. * error mapping functions * Copyright (C) Andrew Tridgell 2001 * Copyright (C) Andrew Bartlett 2001 * Copyright (C) Tim Potter 2000 - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, see <http://www.gnu.org/licenses/>. */ @@ -293,4 +293,3 @@ NTSTATUS dos_to_ntstatus(uint8_t eclass, uint32_t ecode) } return NT_STATUS_UNSUCCESSFUL; } - diff --git a/source3/libsmb/errormap_wbc.c b/source3/libsmb/errormap_wbc.c index b7e6ec067e0..ad523d6f26d 100644 --- a/source3/libsmb/errormap_wbc.c +++ b/source3/libsmb/errormap_wbc.c @@ -1,20 +1,20 @@ -/* +/* * Unix SMB/CIFS implementation. * error mapping functions * Copyright (C) Andrew Tridgell 2001 * Copyright (C) Andrew Bartlett 2001 * Copyright (C) Tim Potter 2000 - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, see <http://www.gnu.org/licenses/>. */ @@ -60,4 +60,3 @@ NTSTATUS map_nt_error_from_wbcErr(wbcErr wbc_err) /* Default return */ return NT_STATUS_UNSUCCESSFUL; } - diff --git a/source3/libsmb/libsmb_thread_impl.c b/source3/libsmb/libsmb_thread_impl.c index dce611073ea..8b5d8597b21 100644 --- a/source3/libsmb/libsmb_thread_impl.c +++ b/source3/libsmb/libsmb_thread_impl.c @@ -1,18 +1,18 @@ -/* +/* Unix SMB/Netbios implementation. SMB client library implementation Copyright (C) Derrell Lipman 2009 - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ @@ -99,7 +99,7 @@ smbc_thread_impl( int (*lock_mutex)(void *plock, int lock_type, const char *location), - + /* Thread local storage. */ int (*create_tls)(const char *keyname, void **ppkey, diff --git a/source3/libsmb/libsmb_thread_posix.c b/source3/libsmb/libsmb_thread_posix.c index 8c8299dd7f0..36afc02feb2 100644 --- a/source3/libsmb/libsmb_thread_posix.c +++ b/source3/libsmb/libsmb_thread_posix.c @@ -1,18 +1,18 @@ -/* +/* Unix SMB/Netbios implementation. SMB client library implementation Copyright (C) Derrell Lipman 2009 - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ @@ -50,4 +50,3 @@ smbc_thread_posix(void) { smb_thread_set_functions(&tf); } - diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c index 3ccb063160a..dcb2f9e74a7 100644 --- a/source3/libsmb/libsmb_xattr.c +++ b/source3/libsmb/libsmb_xattr.c @@ -1,10 +1,10 @@ -/* +/* Unix SMB/Netbios implementation. SMB client library implementation Copyright (C) Andrew Tridgell 1998 Copyright (C) Richard Sharpe 2000, 2002 Copyright (C) John Terpstra 2000 - Copyright (C) Tom Jansen (Ninja ISD) 2002 + Copyright (C) Tom Jansen (Ninja ISD) 2002 Copyright (C) Derrell Lipman 2003-2008 Copyright (C) Jeremy Allison 2007, 2008 @@ -1060,9 +1060,9 @@ cacl_get(SMBCCTX *context, if (all || all_nt) { if (determine_size) { p = talloc_asprintf( - ctx, + ctx, ",ACL:" - "%s:%d/%d/0x%08x", + "%s:%d/%d/0x%08x", sidstr, ace->type, ace->flags, @@ -1075,7 +1075,7 @@ cacl_get(SMBCCTX *context, } else { n = snprintf( buf, bufsize, - ",ACL:%s:%d/%d/0x%08x", + ",ACL:%s:%d/%d/0x%08x", sidstr, ace->type, ace->flags, @@ -1087,8 +1087,8 @@ cacl_get(SMBCCTX *context, strcasecmp_m(name+4, sidstr) == 0)) { if (determine_size) { p = talloc_asprintf( - ctx, - "%d/%d/0x%08x", + ctx, + "%d/%d/0x%08x", ace->type, ace->flags, ace->access_mask); @@ -1099,7 +1099,7 @@ cacl_get(SMBCCTX *context, n = strlen(p); } else { n = snprintf(buf, bufsize, - "%d/%d/0x%08x", + "%d/%d/0x%08x", ace->type, ace->flags, ace->access_mask); @@ -1107,7 +1107,7 @@ cacl_get(SMBCCTX *context, } else if (all_nt_acls) { if (determine_size) { p = talloc_asprintf( - ctx, + ctx, "%s%s:%d/%d/0x%08x", i ? "," : "", sidstr, @@ -1848,7 +1848,7 @@ SMBC_setxattr_ctx(SMBCCTX *context, dad->mode); if (!ok) { /* cause failure if NT failed too */ - dad = NULL; + dad = NULL; } } @@ -2171,7 +2171,7 @@ SMBC_getxattr_ctx(SMBCCTX *context, /* Yup. */ const char *filename = name; ret = cacl_get(context, talloc_tos(), srv, - ipc_srv == NULL ? NULL : ipc_srv->cli, + ipc_srv == NULL ? NULL : ipc_srv->cli, &ipc_srv->pol, path, filename, discard_const_p(char, value), diff --git a/source3/libsmb/namequery_dc.c b/source3/libsmb/namequery_dc.c index f2598ed223f..06e2c5088e0 100644 --- a/source3/libsmb/namequery_dc.c +++ b/source3/libsmb/namequery_dc.c @@ -1,4 +1,4 @@ -/* +/* Unix SMB/CIFS implementation. Winbind daemon connection manager diff --git a/source3/libsmb/smberr.c b/source3/libsmb/smberr.c index 854f9bbdf50..167c796217a 100644 --- a/source3/libsmb/smberr.c +++ b/source3/libsmb/smberr.c @@ -1,4 +1,4 @@ -/* +/* Unix SMB/CIFS implementation. Copyright (C) Andrew Tridgell 1998 @@ -142,7 +142,7 @@ static const struct int code; const char *e_class; err_code_struct *err_msgs; -} err_classes[] = { +} err_classes[] = { {0,"SUCCESS",NULL}, {0x01,"ERRDOS",dos_msgs}, {0x02,"ERRSRV",server_msgs}, diff --git a/source3/rpc_server/samr/srv_samr_chgpasswd.c b/source3/rpc_server/samr/srv_samr_chgpasswd.c index 3373ffa76f6..5fcc08e6315 100644 --- a/source3/rpc_server/samr/srv_samr_chgpasswd.c +++ b/source3/rpc_server/samr/srv_samr_chgpasswd.c @@ -1127,9 +1127,11 @@ NTSTATUS change_oem_password(struct samu *hnd, const char *rhost, } if (pdb_get_account_policy(PDB_POLICY_MIN_PASSWORD_LEN, &min_len) && (str_charnum(new_passwd) < min_len)) { - DEBUG(1, ("user %s cannot change password - password too short\n", - username)); - DEBUGADD(1, (" account policy min password len = %d\n", min_len)); + DBG_WARNING("user %s cannot change password - " + "password too short\n" + " account policy min password len = %"PRIu32"\n", + username, + min_len); if (samr_reject_reason) { *samr_reject_reason = SAM_PWD_CHANGE_PASSWORD_TOO_SHORT; } diff --git a/source3/rpc_server/samr/srv_samr_nt.c b/source3/rpc_server/samr/srv_samr_nt.c index e8a95f75e70..d26a8d5a440 100644 --- a/source3/rpc_server/samr/srv_samr_nt.c +++ b/source3/rpc_server/samr/srv_samr_nt.c @@ -7046,11 +7046,12 @@ NTSTATUS _samr_RemoveMemberFromForeignDomain(struct pipes_struct *p, if (!sid_check_is_builtin(&dinfo->sid)) { struct dom_sid_buf buf2; - DEBUG(1,("_samr_RemoveMemberFromForeignDomain: domain_sid = %s, " - "global_sam_sid() = %s\n", - dom_sid_str_buf(&dinfo->sid, &buf), - dom_sid_str_buf(get_global_sam_sid(), &buf2))); - DEBUGADD(1,("please report to samba-techni...@lists.samba.org!\n")); + DBG_WARNING("domain_sid = %s, " + "global_sam_sid() = %s\n" + "please report to " + "samba-techni...@lists.samba.org!\n", + dom_sid_str_buf(&dinfo->sid, &buf), + dom_sid_str_buf(get_global_sam_sid(), &buf2)); return NT_STATUS_OK; } diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c index 6f272dd6c49..8997c402c12 100644 --- a/source3/smbd/smb2_trans2.c +++ b/source3/smbd/smb2_trans2.c @@ -3115,10 +3115,11 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn, } p = strrchr_m(smb_fname->base_name,'/'); - if (!p) + if (p == NULL) { base_name = smb_fname->base_name; - else + } else { base_name = p+1; + } /* NT expects the name to be in an exact form of the *full* filename. See the trans2 torture test */ diff --git a/source4/scripting/bin/gen_hresult.py b/source4/scripting/bin/gen_hresult.py index 2ac80029270..3caca259436 100755 --- a/source4/scripting/bin/gen_hresult.py +++ b/source4/scripting/bin/gen_hresult.py @@ -94,55 +94,38 @@ def generateSourceFile(out_file, errors): out_file.write(" * see http://msdn.microsoft.com/en-us/library/cc704587.aspx\n") out_file.write(" */\n") out_file.write("\n") - out_file.write("static const struct {\n") - out_file.write(" HRESULT error_code;\n") - out_file.write(" const char *error_str;\n") - out_file.write(" const char *error_message;\n") - out_file.write("} hresult_errs[] = {\n") - - for err in errors: - out_file.write(" {\n") - if err.isWinError: - out_file.write(" HRESULT_FROM_WIN32(%s),\n"%err.err_define) - out_file.write(" \"HRESULT_FROM_WIN32(%s)\",\n"%err.err_define) - else: - out_file.write(" %s,\n"%err.err_define) - out_file.write(" \"%s\",\n"%err.err_define) - out_file.write(" \"%s\"\n"%err.err_string) - out_file.write(" },\n") - out_file.write("};\n") - out_file.write("\n") out_file.write("const char *hresult_errstr_const(HRESULT err_code)\n") out_file.write("{\n") out_file.write(" const char *result = NULL;\n") - out_file.write(" size_t i;\n") - out_file.write(" for (i = 0; i < ARRAY_SIZE(hresult_errs); ++i) {\n") - out_file.write(" if (HRES_IS_EQUAL(err_code, hresult_errs[i].error_code)) {\n") - out_file.write(" result = hresult_errs[i].error_message;\n") -- Samba Shared Repository