From: Volker Lendecke Date: Fri, 3 Jun 2022 14:45:41 +0000 (+0200) Subject: vfs: Add struct vfs_open_how.resolve X-Git-Tag: samba-4.17.0rc1~53 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7cd871567615cb54cbefd66dd6a39206191473cc;p=thirdparty%2Fsamba.git vfs: Add struct vfs_open_how.resolve This prepares the later introduction of VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS, which will be used to make use of RESOLVE_NO_SYMLINKS on linux with openat2(). Right now all terminal VFS objects reject any resolve bits with ENOSYS. So we only prepare the vfs layer for now without any real change. But this will make backports to 4.17 much easier. Pair-programmed-with: Stefan Metzmacher Signed-off-by: Volker Lendecke Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Sat Aug 6 02:39:11 UTC 2022 on sn-devel-184 --- diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c index 61c343f5434..a72ba57e1a7 100644 --- a/examples/VFS/skel_opaque.c +++ b/examples/VFS/skel_opaque.c @@ -199,6 +199,11 @@ static int skel_openat(struct vfs_handle_struct *handle, struct files_struct *fsp, const struct vfs_open_how *how) { + if (how->resolve != 0) { + errno = ENOSYS; + return -1; + } + errno = ENOSYS; return -1; } diff --git a/source3/include/vfs.h b/source3/include/vfs.h index e65d857d220..866d2a5f4a8 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -908,6 +908,7 @@ struct vfs_aio_state { struct vfs_open_how { int flags; mode_t mode; + uint64_t resolve; }; /* diff --git a/source3/modules/vfs_aio_pthread.c b/source3/modules/vfs_aio_pthread.c index b4245ee89dc..5d051b4f7da 100644 --- a/source3/modules/vfs_aio_pthread.c +++ b/source3/modules/vfs_aio_pthread.c @@ -457,6 +457,11 @@ static int aio_pthread_openat_fn(vfs_handle_struct *handle, bool aio_allow_open = lp_parm_bool( SNUM(handle->conn), "aio_pthread", "aio open", false); + if (how->resolve != 0) { + errno = ENOSYS; + return -1; + } + if (is_named_stream(smb_fname)) { /* Don't handle stream opens. */ errno = ENOENT; diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index 59747db16c3..2186bfdb2ce 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -409,6 +409,11 @@ static int cephwrap_openat(struct vfs_handle_struct *handle, bool became_root = false; int result = -ENOENT; + if (how->resolve != 0) { + errno = ENOSYS; + return -1; + } + /* * ceph doesn't have openat(). */ diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 6bfda596d8a..9cf70fd84ce 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -701,6 +701,12 @@ static int vfswrap_openat(vfs_handle_struct *handle, START_PROFILE(syscall_openat); + if (how->resolve != 0) { + errno = ENOSYS; + result = -1; + goto out; + } + if (is_named_stream(smb_fname)) { errno = ENOENT; result = -1; diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 737f44eb03f..13033096dc9 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1758,6 +1758,11 @@ static int fruit_openat(vfs_handle_struct *handle, how); } + if (how->resolve != 0) { + errno = ENOSYS; + return -1; + } + SMB_ASSERT(fsp_is_alternate_stream(fsp)); if (is_afpinfo_stream(smb_fname->stream_name)) { diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index 081bc0c7c07..dd05da0f9bb 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -772,6 +772,12 @@ static int vfs_gluster_openat(struct vfs_handle_struct *handle, START_PROFILE(syscall_openat); + if (how->resolve != 0) { + END_PROFILE(syscall_openat); + errno = ENOSYS; + return -1; + } + /* * Looks like glfs API doesn't have openat(). */ diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 0e849d7cc41..a3a6afbc3ac 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -1553,6 +1553,11 @@ static int shadow_copy2_openat(vfs_handle_struct *handle, int ret; bool ok; + if (how.resolve != 0) { + errno = ENOSYS; + return -1; + } + smb_fname = shadow_copy2_openat_name( talloc_tos(), dirfsp, fsp, smb_fname_in); if (smb_fname == NULL) { diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c index 47e3b3605e6..f92e9c8c5fa 100644 --- a/source3/modules/vfs_streams_depot.c +++ b/source3/modules/vfs_streams_depot.c @@ -681,6 +681,11 @@ static int streams_depot_openat(struct vfs_handle_struct *handle, how); } + if (how->resolve != 0) { + errno = ENOSYS; + return -1; + } + SMB_ASSERT(fsp_is_alternate_stream(fsp)); SMB_ASSERT(dirfsp == NULL); SMB_ASSERT(VALID_STAT(fsp->base_fsp->fsp_name->st)); diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index ed03aa3b454..3dfb894a800 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -341,6 +341,11 @@ static int streams_xattr_openat(struct vfs_handle_struct *handle, how); } + if (how->resolve != 0) { + errno = ENOSYS; + return -1; + } + SMB_ASSERT(fsp_is_alternate_stream(fsp)); SMB_ASSERT(dirfsp == NULL);