1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-03 01:18:10 +03:00
Commit Graph

62475 Commits

Author SHA1 Message Date
Michael Tokarev
5a560ba489 include <grp.h> for setgroups in a few places
setgroups(), unlike getgroups(), is not in <unistd.h> but in <grp.h>.
Recent compilers require function declaration before using a function
(or more and more distributions treat lack of declaration as error),
so all configure-time tests fails with source3/lib/util_sec.c:

source3/../lib/util/setid.c: In function 'samba_setgroups':
source3/../lib/util/setid.c:244:16: error: implicit declaration of function \
  'setgroups'; did you mean 'getgroups'? [-Wimplicit-function-declaration]
  244 |         return setgroups(setlen, gidset);

Add the missing include so configuration finds the existing system
functions instead of failing.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>

Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Thu Jan  2 17:58:50 UTC 2025 on atb-devel-224
2025-01-02 17:58:50 +00:00
Michael Tokarev
2b65de9b32 testparm: do not fail if /run/samba does not exist
testparm explicitly fails if $piddir or $lockdir does not exist.
However, the daemons which actually use these directories, will
create it on demand, there is no need to fail even simple testparm
operations if the dirs are not there.

This change lets to (pre)configure samba without bothering to
pre-create the directories which are overwise needed only to fulfil
testparm criteria.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2025-01-02 17:01:30 +00:00
Michael Tokarev
4ecbdd689a passchange: error message fix
Missing space and newline.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2025-01-02 17:01:30 +00:00
Michael Tokarev
3831a7e2fd silence "Can not convert group sid" warnings in the log
/var/log/samba/log.winbind is full of messages like:

[2024/02/09 06:25:04.788182,  1, pid=74620] source3/winbindd/winbindd_getgroups.c:259(winbindd_getgroups_recv)
  Could not convert sid S-0-0: NT_STATUS_NONE_MAPPED

On a busy server these are logged several 1000s times per minute,
making any other messages basically invisible.

This is a work-around, a proper solution is to handle some
special SIDs (like this one) separately.  Once this is done,
this change can be reverted.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2025-01-02 17:01:30 +00:00
Michael Tokarev
05bf702f4a silence DNS lookup mismatch messages
There's just too much useless noise in the logs,
especially when the PTR record just doesn't exist.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2025-01-02 17:01:30 +00:00
Michael Tokarev
bf239def4f specify some deps on private libs actually used directly
Lots of samba libraries has incomplete dependencies listed
in wscript files.  This usually is not a problem since the
link line includes dependencies of their dependencies of
their dependencies, and somewhere down that line all immediate
dependencies which are missing are actually present.  But
sometimes this becomes a problem when a library does not
declare direct dependency on at least one private library
which it actually uses: in case no private library is
listed as direct dependency, private library directory is
not put into RUNPATH of the resulting binary, so the binary
can not find its own dependencies.

Fix a few such places, including some libraries which are
a part of public abi (libsmbldap, libndr).

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2025-01-02 17:01:30 +00:00
Volker Lendecke
ff4c70e03a lib: Fix error path memleaks in read_ea_list_entry()
Don't leak the result on error

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Dec 18 09:30:33 UTC 2024 on atb-devel-224
2024-12-18 09:30:33 +00:00
Volker Lendecke
dc84e98ed5 lib: Fix a comment
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-12-18 08:25:35 +00:00
Volker Lendecke
df219ed818 smbd: Simplify smbd_do_qfsinfo()
Do early returns, avoid else statements

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-12-18 08:25:34 +00:00
Volker Lendecke
70b3699f8b Fix whitespace
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-12-18 08:25:34 +00:00
Volker Lendecke
ff63874306 vfs: Slightly speed up stream_dir()
lp_parm_bool() is a relatively expensive string-based operation. Do it
only when needed.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-12-18 08:25:34 +00:00
Volker Lendecke
0dfaa08ce3 vfs: Simplify stream_dir()
We know in advance how large "id_hex" is.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-12-18 08:25:34 +00:00
Volker Lendecke
fca8887900 Modernize DEBUGs
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-12-18 08:25:34 +00:00
Pavel Filipenský
e0aab377bd s3:winbindd: Remove unused set_routing_domain()
Commit 9a613f4 winbindd: add routing_domain as parameter to add_trusted_domain
deleted all calls of set_routing_domain().

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Dec 17 13:30:25 UTC 2024 on atb-devel-224
2024-12-17 13:30:25 +00:00
Pavel Filipenský
bf20ec9642 s3:winbindd: Remove implementation of WINBINDD_SHOW_SEQUENCE
Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
04977dbb67 smbd: Simplify rmdir_internals()
Remove another "copy" of recursive_rmdir()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
83f7129e58 smbd: Streamline recursive_rmdir()
By factoring out recursive_rmdir_fsp() we can do the recursion using
openat_pathref_fsp_lcomp(). This makes strace for a recursive
directory removal look a *lot* cleaner.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
663f03996c smbd: Simplify rmdir_internals()
Remove a "copy" of can_delete_directory_hnd()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
cf69a9ef14 smbd: Factor out can_delete_directory_hnd()
To be used in close.c next

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
671186d8f6 smbd: Make can_delete_directory_fsp() look cleaner in strace
I'm not sure, but it might be that we don't have a full fd coming into
can_delete_directory_fsp() without O_PATH. We open a real fd for
readdir() in all cases, which we can use for sure in openat &
friends. Use that as dirfsp for openat.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
f29b06760a smbd: Fix can_delete_directory_fsp()
We should only ignore veto files if they are about to deleted anyway

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
9afd9fc7da smbd: simplify can_delete_directory_fsp()
openat_pathref_fsp_lcomp does all of what we do here manually
anyway. Use it.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
6262f9a66e smbd: Remove a pointless and partially wrong comment
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
719d4f98c4 smbd: Fix typos
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
6098724e8b smbd: Simplify ReadDirName()
"fp" is only used for DBG messages where I don't think we need the
full accuracy of full_path_from_dirfsp_at_basename(). Save a talloc.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
e166299b18 lib: Simplify ad_get_internal()
We have metadata_fsp() for this

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
e1767db3db smbd: Pass "dirfsp" through open_streams_for_delete()
One SMB_VFS_CREATE_FILE call less with "NULL" as dirfsp

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
6b7ca29ffb smbd: Fix a %d/%u format string hickup
num_streams is an unsigned int

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
7116dca925 rpcclient: Fix Coverity ID 1508978 Use of 32-bit time_t
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
be20007cc7 net: Fix Coverity ID 1508974 Use of 32-bit time_t
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
c1b9dc9f7a eventlog: Fix Coverity ID 1508977 Use of 32-bit time_t
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
3035f98364 winbind: Fix Coverity ID 1509002 Use of 32-bit time_t
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
de8babd6af printing: Remove a few obsolete openat_pathref_fsp() calls
driver_convert_unix calls filename_convert_dirfsp, which these days
fills smb_fname->fsp. So openat_pathref_fsp() will immediately return
success as it finds smb_fname->fsp != NULL.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
d745a0799b smbd: Remove an obsolete comment
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
aff7a1fde6 smbd: Simplify smb_set_file_end_of_file_info()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
ee3a7b31e0 smbd: Simplify call_trans2setfileinfo()
Avoid an "else"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
06cca7bf02 smbd: Modernize DEBUGs
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:31 +00:00
Volker Lendecke
69d74563ad smbd: Avoid a (double) cast
We don't need floating point here, intmax_t and %jd should be
sufficient

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:30 +00:00
Volker Lendecke
2d6d890f45 smbd: Pass "dirfsp" to get_posix_fsp()
The two places where get_posix_fsp() is called we do have the dirfsp
around. Pass this through to SMB_VFS_CREATE_FILE(), looks much cleaner
in strace.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:30 +00:00
Volker Lendecke
3a16c35ab4 smbd: Simplify smb_set_posix_acl()
Call get_posix_fsp() in the caller, this removes if-conditions in
smb_set_posix_acl() itself

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:30 +00:00
Volker Lendecke
b768c54bd5 smbd: Simplify smb_q_posix_acl()
Ensure it's called with a valid fsp. In the pathinfo case, use
get_posix_fsp() in the caller, in the fileinfo case the client has
sent us the fid. A client-visible fid is always a fsa fsp.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:30 +00:00
Volker Lendecke
a780c07c24 smbd: Simplify get_posix_fsp()
Remove three variables only set at initialization time

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:30 +00:00
Volker Lendecke
8f1d903524 vfs: Simplify connect_acl_tdb()
We don't need talloc for printing a mask with %o

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:30 +00:00
Volker Lendecke
d088738342 vfs: Simplify connect_acl_xattr()
We don't need talloc for printing a mask with %o

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:30 +00:00
Volker Lendecke
54124677f6 smbd: Pass "dirfsp" through posix_mkdir()
One less caller of SMB_VFS_CREATE_FILE with dirfsp==NULL

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-12-17 12:30:30 +00:00
Pavel Filipenský
e37e4d16e9 s3:open.c: Fix a typo
Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Tue Dec 17 11:23:50 UTC 2024 on atb-devel-224
2024-12-17 11:23:50 +00:00
Pavel Filipenský
02d4f58a2f selftest: Add test for vfs crossrename module
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15724

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-12-17 10:27:34 +00:00
Jones Syue
1a089a16c4 s3:vfs_crossrename: add back checking for errno ENOENT
strace gives a clue: samba try to remove 'file.txt' in the dst folder but
actually it is not existed yet, and got an errno = ENOENT,

renameat(32, "file.txt", 31, "file.txt") = -1 EXDEV (Invalid cross-device link)
unlinkat(31, "file.txt", 0)             = -1 ENOENT (No such file or directory)

Commit 5c18f074be ("s3: VFS: crossrename. Use real dirfsp for
SMB_VFS_RENAMEAT()") seems unintentionally removed errno ENOENT checking,
so add it back could address 1st issue.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15724

Signed-off-by: Jones Syue <jonessyue@qnap.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-12-17 10:27:34 +00:00
Pavel Filipenský
0a9adc85e7 s3:vfs_crossrename: crossrename_renameat() needs to return 0 if copy_reg() is successful
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15724

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-12-17 10:27:34 +00:00
Pavel Filipenský
0a5da82f75 s3:vfs_crossrename: avoid locking panic in copy_reg()
Use low level backend functions that don't go through the FSA layer.
Done via calling transfer_file() as it was in version before 5c18f07

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15724

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-12-17 10:27:34 +00:00