stunnel: create PID directory before alt_config_file return

When alt_config_file is set, global_defs() returns before creating
the PID file directory. stunnel then fails to start because it
cannot write its PID file to the nonexistent directory.

Move the PID directory creation and ownership setup above the
alt_config_file early return so it runs regardless of config mode.

Fixes: openwrt/openwrt#28982
Signed-off-by: Joshua Klinesmith <joshuaklinesmith@gmail.com>

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Joshua Klinesmith
2026-03-30 15:52:39 -04:00
committed by Florian Eckert
parent 0f729f36b2
commit 9e3c668211
2 changed files with 6 additions and 6 deletions

View File

@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=stunnel PKG_NAME:=stunnel
PKG_VERSION:=5.75 PKG_VERSION:=5.75
PKG_RELEASE:=1 PKG_RELEASE:=2
PKG_LICENSE:=GPL-2.0-or-later PKG_LICENSE:=GPL-2.0-or-later
PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de> PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de>

View File

@@ -338,6 +338,11 @@ global_defs() {
# If the first globals section has alt_config_file, don't process any more globals # If the first globals section has alt_config_file, don't process any more globals
[ -z "$HAVE_ALT_CONF_FILE" ] || return 0 [ -z "$HAVE_ALT_CONF_FILE" ] || return 0
pid_dir="$(dirname "$PID_FILE")"
mkdir -p "$pid_dir"
[ -z "$setuid" ] || chown "$setuid" "$pid_dir"
[ -z "$setgid" ] || chown ":$setgid" "$pid_dir"
# If "alt_config_file" specified in the first globals section, use that instead # If "alt_config_file" specified in the first globals section, use that instead
[ -z "$alt_config_file" ] || [ -n "$CONF_FILE_CREATED" ] || { [ -z "$alt_config_file" ] || [ -n "$CONF_FILE_CREATED" ] || {
# Symlink "alt_config_file" since it's a bit easier and safer # Symlink "alt_config_file" since it's a bit easier and safer
@@ -349,11 +354,6 @@ global_defs() {
return 0 return 0
} }
pid_dir="$(dirname "$PID_FILE")"
mkdir -p "$pid_dir"
[ -z "$setuid" ] || chown "$setuid" "$pid_dir"
[ -z "$setgid" ] || chown ":$setgid" "$pid_dir"
create_conf_file create_conf_file
print_global_options print_global_options
validate_service_options globals "$1" print_service_options validate_service_options globals "$1" print_service_options