Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 436268 - net-misc/stunnel-4.44-r1 stunnel fails to start: Cannot create pid file /var/run/stunnel.pid
Summary: net-misc/stunnel-4.44-r1 stunnel fails to start: Cannot create pid file /var/...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Lance Albertson (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-26 01:19 UTC by Emmanuel Rosa
Modified: 2012-12-25 04:26 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
stunnel.initd-start-stop-daemon (stunnel.initd-start-stop-daemon,1.14 KB, text/plain)
2012-12-22 21:03 UTC, Marcel Pennewiß
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Emmanuel Rosa 2012-09-26 01:19:21 UTC
stunnel fails to start because it doesn't have permissions to create the file /var/run/stunnel/stunnel.pid. This is what the error messages look like in the everything log:

everything/log-2012-09-26-00:46:04:Sep 25 20:34:19 [stunnel] LOG3[1280:1077577984]: Cannot create pid file /var/run/stunnel.pid
everything/log-2012-09-26-00:46:04:Sep 25 20:34:19 [stunnel] LOG3[1280:1077577984]: create: Permission denied (13)


Reproducible: Always

Steps to Reproduce:
1.Install and configure stunnel.
2.Run rc-add stunnel default.
3.Reboot.
4.Run rc-status.
Actual Results:  
# rc-status
Runlevel: default
 stunnel                                                           [  crashed  ]

Expected Results:  
# rc-status
Runlevel: default
 stunnel                                                           [  started  ]

I fixed the problem by making a code change to /etc/init.d/stunnel:

...
start() {
    get_config || return 1
        ebegin "Starting ${SVCNAME}"
        if [ ! -e "${PIDFILE}" ] ; then
        PIDFILEDIR=${PIDFILE%/*}
        if [ ! -e "${PIDFILEDIR}" ] ; then
        mkdir -p "${PIDFILEDIR}"
        chown stunnel:stunnel "${PIDFILEDIR}"
        fi
        fi
        start-stop-daemon --start --pidfile "${PIDFILE}" ${CHROOT} \
                    --exec /usr/bin/stunnel -- ${STUNNEL_CONFIGFILE} ${STUNNEL_OPTIONS}
        eend $? "Failed to start ${SVCNAME}"
}
...


The directory /var/run/stunnel doesn't stay between reboots, so my code change created it if it's missing and makes the stunnel user the owner.
Comment 1 Timothy Messier 2012-11-23 04:23:19 UTC
I experienced the same issue. Your fix worked as a work-around. This seems to be due to /var/run now being a sym-link to /run which is a tmpfs.
Comment 2 gentoolinux 2012-12-02 13:20:35 UTC
Same problem here after updating to openrc-0.11.5. I solved it by simply adding "mkdir -p /var/run/stunnel && chown stunnel:stunnel /var/run/stunnel" at the beginning of the start() block in /etc/init.d/stunnel.
Comment 3 Marcel Pennewiß 2012-12-22 21:02:50 UTC
Just use checkpath...

start() {
    get_config || return 1
    checkpath -d -m 0755 -o stunnel:stunnel -q $(dirname ${PIDFILE})
    ...
}
Comment 4 Marcel Pennewiß 2012-12-22 21:03:44 UTC
Created attachment 333074 [details]
stunnel.initd-start-stop-daemon

init-script using checkpath
Comment 5 Lance Albertson (RETIRED) gentoo-dev 2012-12-25 04:26:07 UTC
Fixed and pushed to the tree. Thanks for the patch!