1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
Commit Graph

61988 Commits

Author SHA1 Message Date
Shachar Sharon
aa043a5808 vfs_ceph_new: handle errno properly for 'readdir'
Take special care for readdir errno setting: in case of error, update
errno by libcephfs (and protect from possible over-write by debug
logging); in the case of successful result or end-of-stream restore
errno to its previous value before calling the readdir_fn VFS hook.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>

Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Wed Aug  7 14:20:02 UTC 2024 on atb-devel-224
2024-08-07 14:20:02 +00:00
Shachar Sharon
a7f4e2bd47 vfs_ceph{_new}: do not set errno upon successful call to libcephfs
There is code in Samba that expects errno from a previous system call
to be preserved through a subsequent system call. Thus, avoid setting
"errno = 0" in status_code() and lstatus_code() upon successful return
from libcephfs API call.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-08-07 13:02:34 +00:00
Stefan Metzmacher
5b31b723c0 s3:lib: add winbind_lookup_name_ex() fallback for --without-winbind
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15687

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-08-07 06:18:31 +00:00
Volker Lendecke
2686a189c6 smbd: Assert we have an fsp in smbd_do_setfilepathinfo
With this in the future we can avoid some special cases in our callees

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

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Aug  6 17:37:39 UTC 2024 on atb-devel-224
2024-08-06 17:37:39 +00:00
Volker Lendecke
7e82052ce7 smbd: filename_convert_dirfsp always gives an fsp
We're in setpathinfo, so if there's without an fsp it's
OBJECT_NAME_NOT_FOUND, the last component is missing.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Volker Lendecke
0e8a0f3bd4 smbd: Simplify check_user_ok()
Don't walk the cache at all if we get UID_FIELD_INVALID

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Volker Lendecke
95c031b660 smbd: Make parent_override_delete a bit more readable
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Volker Lendecke
83537703ba smbd: Remove some dead code
We have returned from this function if fsp==NULL above

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Volker Lendecke
fe7b78adb3 smbd: Fix some DBGs
DBG_DEBUG already has the function name prefix

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Volker Lendecke
51262e47af smbd: Modernize a DEBUG
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Volker Lendecke
cfa24f0563 smbd: Fix a comment and an error message
Tested manually, but OBJECT_NAME_NOT_FOUND makes much more sense given
the new semantics of filename_convert_dirfsp.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Volker Lendecke
cb67a70113 smbd: Save a few lines with a "goto done;"
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Volker Lendecke
ec73654323 lib: Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Volker Lendecke
d8271bd937 vfs: Fix a DBG message
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Volker Lendecke
7fe93402f3 smbclient: Modernize a d_printf
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Volker Lendecke
33d517fe13 smbd: Modernize DEBUGs
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Volker Lendecke
230d8efe72 libsmb: Remove cli_posix_chmod
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Volker Lendecke
14d6e7d412 torture3: Use cli_chmod instead of cli_posix_chmod
Show that it works the same even for dangling posix symlinks

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Volker Lendecke
a3fcb5f740 smbclient: Use cli_chmod instead of cli_posix_chmod
Skip the smb1-only SERVER_HAS_UNIX_CIFS(), chmod now also does SMB2

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Volker Lendecke
70da8f7d62 libsmb: Add cli_fchmod for smb311 posix extensions
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Volker Lendecke
773c4641ce libsmb: Add cli_chmod
Go via create/fchmod/close. Only fchmod has to be smb2-specific this way.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Volker Lendecke
ac92f2d34a libsmb: Add cli_fchmod
Do a posix-level fchmod on a fnum. This will be used for smb2 soon as
well which does not have setpathinfo.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Volker Lendecke
3720198d22 libsmb: Add cli_smb2_fnum_is_posix
Will be used in smb311 unix chmod soon: We should only do the special
setsd on real posix handles. Otherwise we would probably destroy a
valid acl.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Volker Lendecke
cd0352a9ca libsmb: Slightly restructure map_smb2_handle_to_fnum
Pass the persistent/volatile handle as uint64's. Why? I found the
talloc_memdup() slightly misleading, and smbXcli handles those 2 id's
separately. map_smb2_handle_to_fnum() is the function to create the
smb2_hnd.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Volker Lendecke
51ce5ce709 smbd: protect check_smb2_posix_chmod_ace against invalid trustees
Found because I got this wrong in new code coming soon

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2024-08-06 16:29:33 +00:00
Anoop C S
de2f76fa47 vfs_ceph_new: Unconditionally use ceph_select_filesystem
Currently we don't have an explicit check for the presence of
ceph_select_filesystem() libcephfs API as it is always found to
be present with the minimum ceph version that is supported with
Samba right now. Therefore under this assumption directly call
ceph_select_filesystem() without any #ifdefs. Please note that
this change is already part of vfs_ceph via ef0068cd.

ref: https://gitlab.com/samba-team/samba/-/merge_requests/3715
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15686
Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>

Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Mon Aug  5 16:06:47 UTC 2024 on atb-devel-224
2024-08-05 16:06:47 +00:00
Jo Sutton
58b4d988fa s3:libsmb: Return a more sensible error if no interfaces are available
Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2024-08-04 00:32:39 +00:00
Jo Sutton
786265ad7f s3:libsmb: Fix invalid array dereference
If ‘num_addrs’ is equal to zero, name_queries_send() will pass an
invalid address to name_query_send().

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2024-08-04 00:32:39 +00:00
Jo Sutton
d603d8b392 s3:libnet: Fix code spelling
Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2024-08-04 00:32:39 +00:00
Volker Lendecke
a150714cc6 lib: Remove "token" parameter from set_namearray
Not needed anymore

Bug: https://bugzilla.samba.org/show_bug.cgi?id=15688
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-07-31 08:39:29 +00:00
Volker Lendecke
b5169dd717 lib: Remove per-user support from append_to_namearray
This is done in check_user_ok now

Bug: https://bugzilla.samba.org/show_bug.cgi?id=15688
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-07-31 08:39:29 +00:00
Volker Lendecke
17becb5f52 smbd: Respect per-user hide and veto files with parametric options
For my taste this is a nicer configuration syntax than

/../username1/file1/../username2/file2/

Is this too expensive? I don't think so. The scanning only happens an
tcon time, and it only walks the parametric options. If this turns out
to be a performance problem, we should think about smarter data
structures for parametric options instead of just a linked list of
string triples for everything.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=15688
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-07-31 08:39:29 +00:00
Volker Lendecke
fcd595a464 lib: Factor out append_namearray from set_namearray
We'll have to add to an existing namearray soon.

This turns one talloc_array() into a set of reallocs. This is slower,
but set_namearray is only used for smb.conf entries where we don't
expect hundreds or more entries to add. I've done this to avoid array
length calculations, but if it turns out to be too slow we can get
smarter again.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=15688
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-07-31 08:39:29 +00:00
Volker Lendecke
89da15756d loadparm: Add lp_wi_scan_share_parametrics
Bug: https://bugzilla.samba.org/show_bug.cgi?id=15688
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-07-31 08:39:29 +00:00
Volker Lendecke
0536ac96e9 loadparm: Factor out lp_wi_scan_parametrics
We'll scan share parametrics soon as well.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=15688
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-07-31 08:39:29 +00:00
Shachar Sharon
3bb6d441bf vfs_ceph_new: common prefix to debug-log messages
Keep logging consistent: add "[CEPH] " prefix to DBG_DEBUG log messages
where missing.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>

Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Mon Jul 29 15:58:15 UTC 2024 on atb-devel-224
2024-07-29 15:58:15 +00:00
Shachar Sharon
d00f20f30f vfs_ceph_new: debug-log upon libcephfs low-level calls
Add developer's debug-logging upon each call to libcephfs' low-level
APIs.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-07-29 14:51:37 +00:00
Shachar Sharon
0a8445e891 vfs_ceph_new: use low-level APIs for xattr ops
Implement extended-attributes operations using libcephfs' low-level
APIs. Whenever possible, use the open file-handle from fsp-extension to
resolve inode-reference and user-permissions. Otherwise, resolve both
on-the-fly.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-07-29 14:51:37 +00:00
Shachar Sharon
e714e5ddc5 vfs_ceph_new: use low-level APIs for mknodat
Implement mknodat operations using libcephfs' low-level APIs. Requires
parent directory to have valid inode-ref associated with its fsp
extension.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-07-29 14:51:37 +00:00
Shachar Sharon
83011357fb vfs_ceph_new: use low-level APIs for renameat
Implement renameat operations using libcephfs' low-level APIs. Requires
both directories to have valid inode-ref associated with their fsp
extension.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-07-29 14:51:37 +00:00
Shachar Sharon
9a70bd6067 vfs_ceph_new: use low-level APIs for linkat
Implement link operations using libcephfs' low-level APIs. Requires two
phase operation: resolve (by-lookup) reference to inode and then do the
actual (hard) link operation using parent dir-inode reference to the
locally-cached inode.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-07-29 14:51:37 +00:00
Shachar Sharon
b536bf1fa8 vfs_ceph_new: use low-level APIs for ftruncate/fallocate
Implement ftruncate/fallocate operations using libcephfs' low-level
APIs. Requires open ceph Fh* associated with fsp (extension).

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-07-29 14:51:37 +00:00
Shachar Sharon
e15586fc60 vfs_ceph_new: use low-level APIs for fsync
Implement fsync operation using libcephfs' low-level APIs. Requires
open ceph Fh* associated with fsp (extension).

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-07-29 14:51:37 +00:00
Shachar Sharon
30c1a613fe vfs_ceph_new: use low-level APIs for lseek
Implement lseek operation using libcephfs' low-level APIs. Requires
open ceph Fh* associated with fsp (extension).

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-07-29 14:51:37 +00:00
Shachar Sharon
29bbe0f52d vfs_ceph_new: use low-level APIs for read/write
Implement read/write IO operations using libcephfs' low-level APIs.
Requires open ceph Fh* associated with fsp (extension) to complete both
pread/pwrite as well as async I/O operations.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-07-29 14:51:37 +00:00
Shachar Sharon
53c9269b21 vfs_ceph_new: use low-level APIs for symlink/readlink
Implement unlinkat using libcephfs low-level APIs. For readlink
operation need to resolve child inode by-lookup and then used the inode
reference for the actual low-level readlink.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-07-29 14:51:37 +00:00
Shachar Sharon
362a7cf866 vfs_ceph_new: use low-level APIs for unlinkat
Implement unlinkat using libcephfs low-level APIs. Operate using parent
directory's open file-handle. When flags has AT_REMOVEDIR bit set call
low-level rmdir; otherwise, do normal unlink.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-07-29 14:51:37 +00:00
Shachar Sharon
20b7d2bfe0 vfs_ceph_new: use low-level APIs for fntimes
Implement fntimes hook using libcephfs' low-level APIs. Convert
smb_file_time to ceph_statx plus proper field mask on-the-fly upon
issuing low-level call to libcephfs.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-07-29 14:51:37 +00:00
Shachar Sharon
cb14d3630d vfs_ceph_new: use low-level APIs for fchown/fchmod
Use libcephfs' low-level APIs to implement 'fchown' and 'fchmod' using
open file-handle. If fsp does not have an open cephfs Fh reference,
set errno to EBADF and return -1 to VFS.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-07-29 14:51:37 +00:00
Shachar Sharon
24a3423949 vfs_ceph_new: proper error handling to readdir
Error handling in the case of 'ceph_readdir' is done by setting 'errno'
deep within libcephfs code. In case of error, emit proper debug message
and re-update errno to avoid possible over-write by logging mechanism.

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

Signed-off-by: Shachar Sharon <ssharon@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-07-29 14:51:37 +00:00