Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unable to listen to unix domain socket inside bindfs mount on macOS #132

Closed
slonopotamus opened this issue Jul 10, 2023 · 8 comments
Closed
Labels
fuse-bug Most likely a bug in a FUSE implementation mac-os

Comments

@slonopotamus
Copy link
Contributor

Way to reproduce:

(as root)

  1. macOS Ventura + macFUSE 4.5.0 + bindfs 1.17.3
$ mkdir a
$ mkdir b
$ bindfs a b
$ nc -U b/sock -l
nc: Invalid argument
$ nc -U a/sock -l
<works>
  1. macOS Ventura + fuse-t 1.0.23 + bindfs 1.17.3
$ mkdir a
$ mkdir b
$ bindfs a b
$ nc -U b/sock -l
nc: Input/output error
$ nc -U a/sock -l
<works>

If this issue is not caused by bindfs, my apologies, will report to macFUSE/fuse-t.

@mpartel mpartel added mac-os fuse-bug Most likely a bug in a FUSE implementation labels Jul 11, 2023
@mpartel
Copy link
Owner

mpartel commented Jul 11, 2023

Works on Linux, so appears to be a limitation of MacOS or fuse-t.

@mpartel mpartel closed this as completed Jul 11, 2023
@slonopotamus
Copy link
Contributor Author

slonopotamus commented Jul 11, 2023

Works on Linux

Confirming, btw. Next time I'll first test on Linux before creating an issue :D Sorry for the noise.

Reported to:

@mpartel
Copy link
Owner

mpartel commented Jul 11, 2023

Actually I may have been hasty :)
Some things need MacOS-specific functions. But I just checked and didn't find any obvious API related to domain sockets.

You (sorry, I've no access to a mac at the moment) could check with bindfs -d -f ... what, if any, call nc ends up making into bindfs. If no call is made then it's pretty clearly a fuse problem. Otherwise, perhaps we need an additional special case in mknod or something.

@slonopotamus
Copy link
Contributor Author

slonopotamus commented Jul 11, 2023

Output of bindfs -d -f ... produced during nc -U <path> -l:

With macFUSE:

unique: 2, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 405
getattr /
   unique: 2, success, outsize: 136
unique: 3, opcode: GETXATTR (22), nodeid: 1, insize: 77, pid: 405
getxattr / com.apple.FinderInfo 32 0
   unique: 3, success, outsize: 48
unique: 2, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 111
getattr /
   unique: 2, success, outsize: 136
unique: 3, opcode: LOOKUP (1), nodeid: 1, insize: 45, pid: 698
LOOKUP /sock
getattr /sock
   unique: 3, error: -2 (No such file or directory), outsize: 16
unique: 2, opcode: MKNOD (8), nodeid: 1, insize: 61, pid: 698
mknod /sock 0140755 0x0 umask=0000
   unique: 2, error: -22 (Invalid argument), outsize: 16

With fuse-t:

unique: 39, opcode: STATFS (17), nodeid: 1, insize: 40, pid: 0
statfs_x /
   unique: 39, success, outsize: 96
unique: 40, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 0
getattr /
   unique: 40, success, outsize: 136
unique: 41, opcode: LOOKUP (1), nodeid: 1, insize: 45, pid: 0
LOOKUP /sock
getattr /sock
   unique: 41, error: -2 (No such file or directory), outsize: 16

So, it looks like we have different bugs here?

  1. macFUSE passes mknod call to bindfs, but bindfs fails to handle it
  2. fuse-t doesn't pass mknod to bindfs at all

For the reference, here's how nc -U sock -l through bindfs looks on Linux:

unique: 64, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 16753
getattr[NULL] /
   unique: 64, success, outsize: 120
unique: 66, opcode: LOOKUP (1), nodeid: 1, insize: 45, pid: 16753
LOOKUP /sock
getattr[NULL] /sock
   unique: 66, error: -2 (No such file or directory), outsize: 16
unique: 68, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 16753
getattr[NULL] /
   unique: 68, success, outsize: 120
unique: 70, opcode: LOOKUP (1), nodeid: 1, insize: 45, pid: 16753
LOOKUP /sock
getattr[NULL] /sock
   unique: 70, error: -2 (No such file or directory), outsize: 16
unique: 72, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 16753
getattr[NULL] /
   unique: 72, success, outsize: 120
unique: 74, opcode: MKNOD (8), nodeid: 1, insize: 61, pid: 16753
mknod /sock 0140755 0x0 umask=0022
getattr[NULL] /sock
   NODEID: 3
   unique: 74, success, outsize: 144

@slonopotamus
Copy link
Contributor Author

In macos-fuse-t/fuse-t#31, I was given this link: https://libfuse.github.io/doxygen/example_2passthrough__helpers_8h_source.html. mknod in bindfs doesn't currently have any special handling for S_ISSOCK. Maybe it should?

@slonopotamus slonopotamus changed the title Unable to listen to unix domain socket inside bindfs mount Unable to listen to unix domain socket inside bindfs mount on macOS Jul 12, 2023
@slonopotamus
Copy link
Contributor Author

@mpartel what do you think?

My current understanding is that

  1. There's missing functionality in fuse-t: it doesn't call mknod at all
  2. There's missing support for S_ISSOCK in bindfs mknod implementation
  3. macFUSE works properly

I suggest reopening this issue and will try to fix №2 (and send a PR).

@mpartel
Copy link
Owner

mpartel commented Jul 12, 2023

Yes, that seems likely. Thanks! And apologies, this week it's especially difficult for me to anything mac-related.

@mpartel mpartel reopened this Jul 12, 2023
slonopotamus added a commit to slonopotamus/bindfs that referenced this issue Jul 13, 2023
slonopotamus added a commit to slonopotamus/bindfs that referenced this issue Jul 13, 2023
@slonopotamus
Copy link
Contributor Author

See #133. With those fixes, I'm able to talk with nc over AF_UNIX socket created inside bindfs-mounted dir.

mpartel added a commit that referenced this issue Jul 15, 2023
resolves #132 add support for AF_UNIX bind on macOS
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
fuse-bug Most likely a bug in a FUSE implementation mac-os
Projects
None yet
Development

No branches or pull requests

2 participants