Two dir's of identical ownership, but `cat > f` produces differently owned files

2

Why do myfile.txt and myotherfile.txt have different ownership?

The first directory, myhandle on my Desktop, was created using sudo chown. The second directory under /run/... was created as a networked file system by keybase.

From my ~/Desktop/myhandle:

$ ls -l ..
total 0
drwx------ 1 me root 126 Nov 23 23:10 myhandle

$ ls -la
total 0
drwx------ 1 me root 126 Nov 23 23:10 .
dr-x------ 1 me root  46 Nov 20 01:50 ..

$ cat > myfile.txt
test

$ ls -la
total 4
drwx------ 1 me root 146 Nov 23 23:11 .
dr-x------ 1 me root  46 Nov 20 01:50 ..
-rw-rw-r-- 1 me me    5 Nov 23 23:11 myfile.txt

From /run/user/1000/keybase/kbfs/private/myhandle

$ ls -l ..
total 1
drwx------ 1 me root 504 Nov 23 23:12 myhandle

$ ls -la
total 0

$ cat > myotherfile.txt
test

$ ls -la
total 1
-rw------- 1 me root 5 Nov 23 23:12 myotherfile.txt

Diagon

Posted 2018-11-24T07:26:37.577

Reputation: 598

Answers

2

The path component kbfs sounds like its contents could be on another filesystem (kbfs is the name of the filesystem keybase uses).

It is not unheard-of for special file systems to not adhere to common expectations about permissions.

See also an old bug in keybase where, in its filesystem, it was reporting completely different permissions than it was actually using: https://github.com/keybase/kbfs/issues/212

Christoph Sommer

Posted 2018-11-24T07:26:37.577

Reputation: 361

Quick search reveals /run/user/1000/keybase/kbfs is indeed a mountpoint for FUSE filesystem and the relevant executable is kbfsfuse.

– Kamil Maciorowski – 2018-11-24T08:55:09.387

I think what's happening - maybe you can tell me if this is right - is that when writing to this filesystem, it is actually keybase that's doing the writing, and keybase itself is running as user myself, but group root. (Is that the way it works, that a running daemon has a user/group under which it runs?) As a result files take on that ownership. – Diagon – 2018-11-24T09:01:49.383

Filesystems are free to report whatever permissions they want and free to use whatever logic to decide who is allowed to do what on the filesystem. Most standard file systems are sticking to established conventions here, so that the user can predict which operations will be successful - but, really, nothing stops a filesystem from telling a user "nobody can write to this file" and, in reality, allowing everybody to do so. – Christoph Sommer – 2018-11-24T09:05:54.490