aboutsummaryrefslogtreecommitdiff
path: root/net/stunnel/files
diff options
context:
space:
mode:
authorFlorian Eckert <fe@dev.tdt.de>2018-01-23 11:35:30 +0100
committerFlorian Eckert <fe@dev.tdt.de>2018-01-23 14:37:02 +0100
commit68f6fc25a0268efadf78cad531507be1d2dc481d (patch)
tree5dc1019dcb05b7540d201d55d37e48d7e16ad5b8 /net/stunnel/files
parent66349b4cd97b5cb5096dd8fbf88e4ef26b859f34 (diff)
net/stunnel: check if service section is configured to prevent crash loop
If a service section is not presented in the configuration then stunnel will always start anyway. This ends in a crash loop because the configuration is not valid. Checking in "uci" mode if a service section is presented and only then start the stunnel service will solve this issue. Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Diffstat (limited to 'net/stunnel/files')
-rw-r--r--net/stunnel/files/stunnel.init22
1 files changed, 14 insertions, 8 deletions
diff --git a/net/stunnel/files/stunnel.init b/net/stunnel/files/stunnel.init
index 79e391e78..a1772e159 100644
--- a/net/stunnel/files/stunnel.init
+++ b/net/stunnel/files/stunnel.init
@@ -7,6 +7,7 @@ USE_PROCD=1
PID_FILE="/var/run/stunnel.pid"
CONF_FILE="/tmp/stunnel.conf"
BIN="/usr/bin/stunnel"
+SERVICE_SECTION_FOUND=0
global_defs() {
local debug compression
@@ -86,6 +87,7 @@ service_section() {
config_get_bool enabled "$cfg" 'enabled' '1'
[ ${enabled} -gt 0 ] || return 0
+ SERVICE_SECTION_FOUND=1
printf "\n" >> "$CONF_FILE"
printf "[%s]\n" "$cfg" >> "$CONF_FILE"
@@ -150,6 +152,8 @@ process_config() {
rm -f "$CONF_FILE"
# Symlink "alt_config_file" since it's a bit easier and safer
ln -s "$alt_config_file" "$CONF_FILE"
+ # Set section found to start service user hopfully knows what you does
+ SERVICE_SECTION_FOUND=1
return 0
}
@@ -161,14 +165,16 @@ service_triggers() {
}
start_service() {
- procd_open_instance
- procd_set_param command "$BIN"
- procd_append_param command "$CONF_FILE"
-
process_config
- # set auto respawn behavior
- procd_set_param respawn
- procd_set_param file "$CONF_FILE"
- procd_close_instance
+ if [ "$SERVICE_SECTION_FOUND" = 1 ]; then
+ procd_open_instance
+ procd_set_param command "$BIN"
+ procd_append_param command "$CONF_FILE"
+ procd_set_param respawn
+ procd_set_param file "$CONF_FILE"
+ procd_close_instance
+ else
+ logger -t stunnel -p daemon.info "No uci service section enabled or found!"
+ fi
}