]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_widelinks: implement SMB_VFS_OPENAT()
authorRalph Boehme <slow@samba.org>
Wed, 20 May 2020 21:03:30 +0000 (23:03 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 21 May 2020 20:38:33 +0000 (20:38 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_widelinks.c

index 9f5661b84ae70ce9b17259183161197e53bccdae..5267c8b218eea16cf9bdc6bda89e3eac6fbe1525 100644 (file)
@@ -388,6 +388,39 @@ static int widelinks_open(vfs_handle_struct *handle,
                        mode);
 }
 
+static int widelinks_openat(vfs_handle_struct *handle,
+                           const struct files_struct *dirfsp,
+                           const struct smb_filename *smb_fname,
+                           files_struct *fsp,
+                           int flags,
+                           mode_t mode)
+{
+       struct widelinks_config *config = NULL;
+
+       SMB_VFS_HANDLE_GET_DATA(handle,
+                               config,
+                               struct widelinks_config,
+                               return -1);
+
+       if (config->active &&
+           (config->cwd != NULL) &&
+           !(smb_fname->flags & SMB_FILENAME_POSIX_PATH))
+       {
+               /*
+                * Module active, openat after chdir (see note 1b above) and not
+                * a POSIX open (POSIX sees symlinks), so remove O_NOFOLLOW.
+                */
+               flags = (flags & ~O_NOFOLLOW);
+       }
+
+       return SMB_VFS_NEXT_OPENAT(handle,
+                                  dirfsp,
+                                  smb_fname,
+                                  fsp,
+                                  flags,
+                                  mode);
+}
+
 static struct dirent *widelinks_readdir(vfs_handle_struct *handle,
                        DIR *dirp,
                        SMB_STRUCT_STAT *sbuf)
@@ -425,6 +458,7 @@ static struct vfs_fn_pointers vfs_widelinks_fns = {
        .connect_fn = widelinks_connect,
 
        .open_fn = widelinks_open,
+       .openat_fn = widelinks_openat,
        .lstat_fn = widelinks_lstat,
        /*
         * NB. We don't need an lchown function as this