virtualbox.org

#18737 (Linux guests: open(filename, O_CREAT|..., mode) fails inside shared folder => fixed in SVN/6.0.x x>10) – Oracle VirtualBox

#18737 closed defect (fixed)

Reported by: Owned by: paulson
Component: shared folders Version: VirtualBox 6.0.8
Keywords: file create shared permissions Cc:
Guest type: Linux Host type: Linux

The following C code produces a simple executable which will attempt to create and open a read only test file in a single operation.

Expected behaviour when run:

  • A newly created file called test.txt is created on disk with read only permissions
  • A read-write file-handle for the file is returned by the open call
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
int main() {
  int fd = open("test.txt", O_CREAT | O_EXCL | O_RDWR, 0444);
  if (fd < 0) {
    perror("Could not create file: ");
    return -fd;
  }
  return 0;
}

When run on other file systems this works correctly but when run on a virtualbox shared folder the file is created correctly but the program exits with the error message:

Could not create file: : Permission denied

This can be bypassed by running the command with sudo, in which case it succeeds normally.

This is not a purely hypothetical problem, since the same error occurs when attempting to use any programme that makes this system call, such as a git clone.

Attachments (1)

Change History (10)

Owner: set to paulson
Status: newaccepted
Summary: Open system call to create and open read only file fails on shared folderLinux guests: open(filename, O_CREAT|..., mode) fails inside shared folder
Resolution: fixed
Status: acceptedclosed
Summary: Linux guests: open(filename, O_CREAT|..., mode) fails inside shared folderLinux guests: open(filename, O_CREAT|..., mode) fails inside shared folder => fixed in SVN/6.0.x x>10

Note: See TracTickets for help on using tickets.