Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 9294  / 3 Years ago, fri, june 25, 2021, 1:24:08

I want to have a place on the filesystem that presents a write-only "view" of another folder that I have read-write access to.



I'm picturing something that's similar in behavior to an FTP drop box, where files can be copied into it but not read out of it, e.g.:



$ ls read-write-view/ write-only-view/
read-write-view/:
a b c

write-only-view/:

$ cp d write-only-view/
$ ls read-write-view/ write-only-view/
read-write-view/:
a b c d

write-only-view/:


It's important that this works as in the example — the contents are still visible when accessed through read-write-view/, and both "views" are functional for a single user.



How can I set something like this up? Some clever arrangement of symbolic links, perhaps? Or an unusual configuration of a bind mount?


More From » filesystem

 Answers
6

Use bindfs, which is designed to "mount a directory to another location and alter permission bits."



Start with a normal folder that has both read and write access:



$ mkdir read-write-view && touch read-write-view/{a,b,c}
$ ls read-write-view
a b c


Use bindfs to mount the folder without read access:



$ mkdir write-only-view
$ sudo bindfs --perms=a-r read-write-view write-only-view


Verify that only the contents of the original folder can be listed:



$ ls read-write-view write-only-view
read-write-view:
a b c
ls: cannot open directory write-only-view: Permission denied


Verify that the original folder can be written to through the mount:



$ echo 'Can you read this?' > write-only-view/d
$ cat read-write-view/d
Can you read this?


Verify that files cannot be read through the mount:



$ cat write-only-view/d
cat: write-only-view/d: Permission denied

[#38608] Saturday, June 26, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rillrage

Total Points: 122
Total Questions: 120
Total Answers: 103

Location: Tokelau
Member since Thu, Aug 26, 2021
3 Years ago
rillrage questions
;