]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs: Add VFS_OPEN_HOW_WITH_BACKUP_INTENT
authorVolker Lendecke <vl@samba.org>
Fri, 1 Sep 2023 12:51:47 +0000 (14:51 +0200)
committerRalph Boehme <slow@samba.org>
Thu, 5 Oct 2023 14:00:33 +0000 (14:00 +0000)
Indicate BACKUP_INTENT to vfs_openat(). Why? I have a customer request
who wants to add O_NOATIME in this case to avoid metadata updates when
a backup or virus-checking application comes along.

This does not fully handle BACKUP_INTENT correctly, this would require
become_root() appropriately. We might want to do that later after a
lot of careful security audit, but this patch independently might
already provide some infrastructure for it.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Thu Oct  5 14:00:33 UTC 2023 on atb-devel-224

source3/include/vfs.h
source3/modules/vfs_default.c
source3/smbd/open.c

index 8ada8d8aadfd64bf2417cc3cecf4391da4fab5f5..1e2e88d65cefa03807abbd7871a99305ed1c5516 100644 (file)
@@ -908,6 +908,7 @@ struct vfs_aio_state {
 };
 
 #define VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS 1
+#define VFS_OPEN_HOW_WITH_BACKUP_INTENT 2
 
 struct vfs_open_how {
        int flags;
index 1d4b9b1a8402f056d26153f50d5aecd59b2df401..7fa6872d1716c8c35a4dbf97e8413174b62e41f8 100644 (file)
@@ -664,7 +664,8 @@ static int vfswrap_openat(vfs_handle_struct *handle,
 
        START_PROFILE(syscall_openat);
 
-       if (how->resolve & ~VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS) {
+       if (how->resolve & ~(VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS |
+                            VFS_OPEN_HOW_WITH_BACKUP_INTENT)) {
                errno = ENOSYS;
                result = -1;
                goto out;
index ac3e677d6f581d4e0ae084a2d3500c0220657173..d912acbb409b2f4d0cf049354ca27903d4638551 100644 (file)
@@ -4133,6 +4133,11 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
                        .flags = flags,
                        .mode = unx_mode,
                };
+
+               if (create_options & FILE_OPEN_FOR_BACKUP_INTENT) {
+                       how.resolve |= VFS_OPEN_HOW_WITH_BACKUP_INTENT;
+               }
+
                fsp_open = open_file(req,
                                     parent_dir_fname->fsp,
                                     smb_fname_atname,