rapiz1 / rathole

A lightweight and high-performance reverse proxy for NAT traversal, written in Rust. An alternative to frp and ngrok.
Apache License 2.0
9.8k stars 488 forks source link

About permission lacking of config's parent dir #231

Open oluceps opened 1 year ago

oluceps commented 1 year ago
> rathole -V
rathole 0.4.7

Describe the bug This occurs when I try to start rathole with systemd, It failed to start unexpectedly and has no valid debug information about it:

> journalctl -f -u rathole.service
Mar 16 14:34:09 host systemd[1]: Stopped rathole Daemon.
Mar 16 14:34:09 host systemd[1]: rathole.service: Consumed 12ms CPU time, received 960B IP traffic, sent 9.7K IP traffic.
Mar 16 14:34:09 host systemd[1]: Started rathole Daemon.
Mar 16 14:34:09 host rathole[99122]: Mar 16 14:34:09.370  INFO handle{service=example}: rathole::client: Starting <omitted>
Mar 16 14:34:09 host systemd[1]: rathole.service: Deactivated successfully.

To Reproduce Steps to reproduce the behavior:

  1. Create config dir config, with permission 751 owned by user B.
  2. Start rathole with config file which with full permission and owned by user A, in config dir.

Run rathole by user A:

> RUST_LOG=trace rathole --client config/test.toml
...
Mar 16 14:41:59.500 TRACE config_watcher{path="config/test.toml"}: mio::poll: registering event source with poller: token=Token(0), interests=READABLE    
Mar 16 14:41:59.501  INFO handle{service=ssh_tcp}: rathole::client: Starting <omitted>
Mar 16 14:41:59.501 TRACE mio::poll: deregistering event source from poller   

It exits directly, without reporting any available information related to permission lacking.

Bcz I found this, seems rathole needs read permission of the parent directory?

https://github.com/rapiz1/rathole/blob/9479b9a3a9c426a9ee04175cbd747b49a520d497/src/config_watcher.rs#L165

Is there a way to implement hot-reload without this permission? Or at least report some error messages about the permission lacking...

Environment:

> uname -srm
Linux 6.2.5 x86_64
rapiz1 commented 1 year ago

This is introduced by https://github.com/rapiz1/rathole/pull/122

In short, if only the file is watched, then sometimes vim does not trigger a inotify event.

Can you make a directory seperately for rathole config and set the corresponding permission?

Or at least report some error messages about the permission lacking...

It will be appreciated if you could open a PR for this.