stunnel: create PID directory before alt_config_file return
authorJoshua Klinesmith <redacted>
Mon, 30 Mar 2026 19:52:39 +0000 (15:52 -0400)
committerFlorian Eckert <redacted>
Wed, 1 Apr 2026 06:47:47 +0000 (08:47 +0200)
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 <redacted>
Co-Authored-By: Claude Opus 4.6 (1M context) <redacted>
net/stunnel/Makefile
net/stunnel/files/stunnel.init

index 2553625dcde50e205762fb4f22906537ead4337c..9ce9188712234b68a8ec0535ae91e0fdb820af78 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=stunnel
 PKG_VERSION:=5.75
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_LICENSE:=GPL-2.0-or-later
 PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de>
index 6e364600d1faab1b769c3c95eac6c6341c2b94f7..875681d5c9f4f7704bb2f4e66b8c6ef2c5bd2fb7 100644 (file)
@@ -338,6 +338,11 @@ global_defs() {
        # If the first globals section has alt_config_file, don't process any more globals
        [ -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
        [ -z "$alt_config_file" ] || [ -n "$CONF_FILE_CREATED" ] || {
                # Symlink "alt_config_file" since it's a bit easier and safer
@@ -349,11 +354,6 @@ global_defs() {
                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
        print_global_options
        validate_service_options globals "$1" print_service_options
git clone https://git.99rst.org/PROJECT