hypercore-protocol / hyperdrive-daemon

Hyperdrive, batteries included.
MIT License
156 stars 23 forks source link

hyperdrive-daemon looks for config file in root directory #7

Closed ameba23 closed 5 years ago

ameba23 commented 5 years ago

this line in lib/metadata.js grabs the path for the config file using os.homedir(). But when running as sudo (on arch linux) this resolves to /root when the config file is actually located at ~/.hyperdrive/config.json:

beetroot ~ $ hyperdrive fs mount /hyperdrive
Could not mount the drive:
Error: Could not configure fuse: You need to be root
beetroot ~ $ sudo hyperdrive fs mount /hyperdrive
Could not mount the drive:
Error: ENOENT: no such file or directory, open '/root/.hyperdrive/config.json'

a possible workaround could be to allow specifiying the path of the config.json as a command line option.

andrewosh commented 5 years ago

Hey @ameba23, thanks for the issue.

The issue here (and we should print better error messages for this scenario!) is that FUSE needs to be configured prior to running any other hypedrive fs commands, like mount.

The hyperdrive fs mount command doesn't require sudo, since that's just going to send an RPC message to the daemon, which also should not be running as root. If the daemon is running as your user, then the config file check will succeed.

The fix here is to first run hyperdrive setup -- this will prompt you for sudo, and it will install all the dependencies necessary to run subsequent FUSE-related commands without any additional root access (that's the only command that should ever prompt for root access).

Hope that helps! If you hit bugs running those commands, they won't involve searching for a config file in /root, so I'm gonna close this one.