6

Is there a possibility to create a hard link for an unix socket? I'm creating a jail and symbolic links won't work, so I'm looking for a solution, how to provide an unix socket inside chrootted environment.

The only idea I'm coming across is to use something like netcat but is there any reliable possibility?

  • 3
    I'm not sure why this is marked as a duplicate. The other question just asks about creating listening sockets in the filesystem, this one is about duplicating them. – Will Manley Jul 4 '17 at 8:09
  • 1
    Agreed, if I had the rep I would be casting a reopen vote here. – Peter Green Oct 19 '17 at 14:35
2

Linux at least would allow you to use a bind mount to make either a directory or alternatively a single file available at multiple places. Not tested, but in theory it should work...

  mount -t bind /var/MySQL.sock /chroot/var/MySQL.sock 
  • Bind works only for directories, so it doesn't solve the problem. – eRIZ Apr 17 '14 at 20:26
  • In the words of the man page One can also remount a single file (on a single file), and I have no problems accessing the MySQL daemon through the socket in the bind mount. But I don't have any chroot set up to test more. – HBruijn Apr 18 '14 at 12:57
  • Parameter list consist on two directories. I mean mounting a link directly, without separated directory. Could you provide your command line I can test against? Is this the above you cited? I tried to make it happen but this doesn't work. – eRIZ Apr 18 '14 at 17:56
  • You can also put the socket in a directory created for this purpose, and bind mount that. – Falcon Momot Apr 18 '14 at 18:43
  • @FalconMomot, I know but I want to solve problem. I'm aware of a workaround. [; – eRIZ Apr 18 '14 at 21:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.