]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
error_inject: Enable returning EROFS for O_CREAT
authorVolker Lendecke <vl@samba.org>
Mon, 26 Jun 2023 11:17:19 +0000 (13:17 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 26 Jun 2023 15:53:36 +0000 (15:53 +0000)
Bug: https://bugzilla.samba.org/show_bug.cgi?id=15402
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_error_inject.c

index 4ecff3f7bde1c232a83315989b6b34fb06a9e2a7..edb7c64a92a7bf94d9d914fa39cd295c78037de1 100644 (file)
@@ -116,6 +116,7 @@ static int vfs_error_inject_openat(struct vfs_handle_struct *handle,
                                   const struct vfs_open_how *how)
 {
        int error = inject_unix_error("openat", handle);
+       int create_error = inject_unix_error("openat_create", handle);
        int dirfsp_flags = (O_NOFOLLOW|O_DIRECTORY);
        bool return_error;
 
@@ -127,6 +128,24 @@ static int vfs_error_inject_openat(struct vfs_handle_struct *handle,
 #endif
 #endif
 
+       if ((create_error != 0) && (how->flags & O_CREAT)) {
+               struct stat_ex st = {
+                       .st_ex_nlink = 0,
+               };
+               int ret;
+
+               ret = SMB_VFS_FSTATAT(handle->conn,
+                                     dirfsp,
+                                     smb_fname,
+                                     &st,
+                                     AT_SYMLINK_NOFOLLOW);
+
+               if ((ret == -1) && (errno == ENOENT)) {
+                       errno = create_error;
+                       return -1;
+               }
+       }
+
        return_error = (error != 0);
        return_error &= !fsp->fsp_flags.is_pathref;
        return_error &= ((how->flags & dirfsp_flags) != dirfsp_flags);