1

I've run into a strange permissions issue;

A shared folder shows one set of permissions in Windows, and totally different ones when accessed in Linux via VirtualBox.

The shared folder is my XAMPP htdocs/ directory, as I want the ability to work on the same repositories/sites from 2 different environments - so I can't move the folder.

My current setup

  • Windows 7 (Host), with Ubuntu running inside VirtualBox (Guest)
  • I've set up the folder as a Shared location, and can access it via Ubuntu's terminal under /media/sf_<myfolder>.
  • The shared folder is set to automount and be permanent in VirtualBox's settings.
  • My user is part of the vboxsf user group, and I've confirmed it via checking /etc/group.
  • I've installed vitrualbox-guest-additions-iso. Shared clipboards are working fine.
  • I'm using cygwin for my Windows terminal

How the permissions appear

Windows (from cygwin terminal), using $ ls -alF

me@my-server /cygdrive/c/xampp/htdocs/my-website$ ls -alF
total 61313
drwxrwxr-x+ 1 me Domain Users        0 Sep  6 12:12 ./
drwxrwx---+ 1 me Domain Users        0 Sep  8 16:22 ../
drwxrwxr-x+ 1 me Domain Users        0 Sep  8 15:57 .git/
drwxrwxr-x+ 1 me Domain Users        0 Sep  6 12:06 bal/
-rw-rw-r--+ 1 me Domain Users     1065 Sep  6 12:06 .csslintrc
-rw-rw-r--+ 1 me Domain Users      367 Sep  6 12:06 .editorconfig

Ubuntu terminal (VirtualBox), using $ ls -alF

me@my-server:/media/sf_htdocs/my-website$ ls -alF
total 61256
drwxrwx--- 1 root vboxsf    12288 Sep  6 12:12 ./
drwxrwx--- 1 root vboxsf     4096 Sep  8 16:22 ../
drwxrwx--- 1 root vboxsf     4096 Sep  8 15:57 .git/
drwxrwx--- 1 root vboxsf        0 Sep  6 12:06 bal/
-rwxrwx--- 1 root vboxsf     1065 Sep  6 12:06 .csslintrc*
-rwxrwx--- 1 root vboxsf      367 Sep  6 12:06 .editorconfig*

Windows, using $ stat

me@my-server /cygdrive/c/xampp/htdocs/my-website$ stat .csslintrc
  File: .csslintrc
  Size: 1065            Blocks: 4          IO Block: 65536  regular file
Device: bcd2ece6h/3167939814d   Inode: 4222124651673917  Links: 1
Access: (0664/-rw-rw-r--)  Uid: (1051198/me)   Gid: (1049089/Domain Users)
Access: 2017-09-06 12:06:15.578083600 +1000
Modify: 2017-09-06 12:06:15.578583700 +1000
Change: 2017-09-06 12:06:15.578583700 +1000
 Birth: 2017-09-06 12:06:15.578083600 +1000

Ubuntu, using $ stat

me@my-server:/media/sf_htdocs/my-website$ stat .csslintrc 
  File: '.csslintrc'
  Size: 1065        Blocks: 3          IO Block: 4096   regular file
Device: 29h/41d Inode: 14          Links: 1
Access: (0770/-rwxrwx---)  Uid: (    0/    root)   Gid: (  999/  vboxsf)
Access: 2017-09-06 12:06:15.578083600 +1000
Modify: 2017-09-06 12:06:15.578583700 +1000
Change: 2017-09-06 12:06:15.578583700 +1000
 Birth: -

I also created a file from both systems, to inspect the default permissions. I did the same with test directories, and both files + folders show exactly the same permissions.

Windows

-rwxrwxr-x+ 1 Administrators Domain Users        0 Sep 11 08:52 .test-from-linux-vm*
-rw-rw-r--+ 1 me      Domain Users        0 Sep 11 08:52 .test-from-windows

UbuntuVM

-rwxrwx--- 1 root vboxsf        0 Sep 11 08:52 .test-from-linux-vm*
-rwxrwx--- 1 root vboxsf        0 Sep 11 08:52 .test-from-windows*

What I've noticed

  • I cannot change file/folder permissions in Ubuntu, even with sudo chmod <permissions> <file>
  • While I can change permissions in Windows, those changes are not reflected in Ubuntu:

Windows; updated web.config from 664 to 755

-rwxr-xr-x+ 1 me      Domain Users     4555 Sep  6 12:06 web.config*

Ubuntu

-rwxrwx--- 1 root vboxsf     4555 Sep  6 12:06 web.config*

I've already tried...

  • Restarting the VM (many times ;D)
  • Confirming the shared directory is one and the same from both Windows and Linux, via creating test files in one and checking they appear in the other.
  • The suggestions suggestions in this question

My questions:

  • Why do the permission sets differ between systems?
  • Are they being assigned at an OS level, not a file level?

Any help would be awesome!

Timmah
  • 115

1 Answers1

1

Short answer: You are using incompatible environments and software; Windows, Cygwin and VirtualBox all implement non-backwards-compatible implementations of POSIX standards, hence why changes in one are not reflected in the others.

In general: storing a group and a user of a file as a string would be way too wasteful. Not only would it take a bunch of additional disk space, but would also require O(n) of processing time in the worst case to check whether you have permissions to a single file!

Instead those attributes are stored as a number, which would always require just O(1) to check permissions. You can see them using e.g. stat command:

$ stat r600_state_common.c 
  File: r600_state_common.c
  Size: 90718           Blocks: 184        IO Block: 4096   regular file
Device: 26h/38d Inode: 70588       Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/constantine)   Gid: ( 1000/constantine)
Access: 2017-09-08 00:18:26.243828226 +0300
Modify: 2017-09-07 10:52:33.387136858 +0300
Change: 2017-09-07 10:52:33.387136858 +0300
 Birth: -

So, in your system UID of the file matches user root. In the other system it's Domain.

In case of cross-working with Windows systems there's more to it. Despite that POSIX standard have not had any really fundamental changes, Microsoft programmers have always struggled with it. Over the course from Windows NT to Windows 10 there have been three non-backward compatible rewrites of the implementation. So for compatibility, Cygwin is using its own implementation of mapping Windows security descriptors to POSIX permissions.

On top of it you are trying to access a Windows file system through VirtualBox. VirtualBox of course have implemented its own mapping too, and this mapping doesn't work very well (as you can see by changing permissions through chmod, and not seeing the changes reflected).

So, right now, you have got 3 implementations on your system, incompatible with each other. This is the reason of you seeing the problems.

FTR: VirtualBox is open source, so if you're really feel keen to it, you could rewrite it to be compatible with Cygwin (as their implementation is the only back-compatible POSIX implementation on Windows as far as I know).

NB: using a system as a root is a very bad practice! Especially given you're a developer. Consider using a usual user instead.

Timmah
  • 115
Hi-Angel
  • 4,810