shadowsocks-rust: [Bug] `sslocal` cannot daemonize when a plugin is specified via config file
Bug description
sslocal cannot daemonize using the -d or --daemonize flag when the config file specifies a plugin.
I am not entirely sure that this is 100% the real issue here, but I have tested on two different OSes (RHEL8 & Arch) and observed the same behavior, so let’s just say I am reasonably confident.
To replicate
Here I will use simple-tls as an example, but the choice of plugin seems irrelevant. On a Linux x64 machine:
- Get required binaries - sslocal v1.11.2 (latest stable at the time of writing), simple-tls or any other plugin
- Get the config files: configs.zip
- Verify that when
-dis not used,sslocalruns correctly
# Both should run fine
sslocal -v -c ss.json
sslocal -v -c ss-plugin.json # you might have to edit plugin path
- Verify that when
-dis used without a plugin,sslocaldaemonizes correctly
sslocal -v -c ss.json -d --daemonize-pid ss.pid
ps aux | grep sslocal # expect sslocal is running
- Verify that when
-dis used with a plugin,sslocalno longer daemonizes
sslocal -v -c ss-plugin.json -d --daemonize-pid ss-plugin.pid
ps aux | grep sslocal # expect no sslocal process
Environment & versions
uname -msr
Linux 4.18.0-305.19.1.el8_4.x86_64 x86_64
sslocal --version
shadowsocks 1.11.2
whoami
root
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20 (11 by maintainers)
Commits related to this issue
- remove chroot when daemonizing (#640) — committed to shadowsocks/shadowsocks-rust by zonyitoo 3 years ago
- Revert "remove chroot when daemonizing (#640)" This reverts commit 862a8a78b74759636cb902d2196e5c988d6c8a79. — committed to shadowsocks/shadowsocks-rust by zonyitoo 3 years ago
- daemon starts in pwd (#640) This is the default behavior when not daemonizing. — committed to shadowsocks/shadowsocks-rust by spyophobia 3 years ago
By the way, you may wish to include a compatibility note on this in the next release, as I am concerned that this “fix” could break some people’s configs.
In the original implementation, since
Daemonize::working_directorywas not called, the working directory defaults to/. So if someone has a plugin with path/opt/ss-plugins/my-plugin, but has set the"plugin"field in their config file asopt/ss-plugins/my-plugin(and assuming$(pwd)is not/), this change will break their config.Admittedly, a path like this would be considered an “erroneous” config. Nevertheless this change breaks bug-compatibility so I think it’s worth a mention.