Subject: [alpine-devel] [Patch] mini_httpd: crash on startup

From: Der Tiger <[email-masked]>
Date: Sat, 24 Mar 2012 21:45:31 +0100

Hi,

mini_httpd is quite picky about the availability of paths to the log and
pid files. If those folders do not exist, e.g. because they point to an
after the system boot empty tmpfs, mini_httpd (as such ACF) will crash.

The patch below ensures the folders are available. Please, consider
integrating it.

Regards, Tiger

--- /etc/init.d/mini_httpd.orig
+++ /etc/init.d/mini_httpd
@@ -6,0 +7 @@
+logfile=/var/log/mini_httpd/${SVCNAME}.log
@@ -14,0 +16,2 @@
+    mkdir -p "$(echo $pidfile | sed 's|/[^/]*$||')"
+    mkdir -p "$(echo $logfile | sed 's|/[^/]*$||')"
@@ -17 +20 @@
-        ${MINI_HTTPD_OPTS:--C /etc/${SVCNAME}.conf -l
/var/log/mini_httpd/${SVCNAME}.log}
+        ${MINI_HTTPD_OPTS:--C /etc/${SVCNAME}.conf -l $logfile}

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Natanael Copa <[email-masked]>
Date: Mon, 26 Mar 2012 20:47:27 +0200

On Sat, 24 Mar 2012 21:45:31 +0100
Der Tiger <[email-masked]> wrote:

> Hi,
> 
> mini_httpd is quite picky about the availability of paths to the log
> and pid files. If those folders do not exist, e.g. because they point
> to an after the system boot empty tmpfs, mini_httpd (as such ACF)
> will crash.

Hi, thanks for the feedback.

> The patch below ensures the folders are available. Please, consider

I get this error when tryin apply it:
fatal: cannot convert from ISO-8859-15 to UTF-8

> +++ /etc/init.d/mini_httpd

openrc has a tool for this. checkpath.

how about something like:

checkpath -d ${pidfile%/*}
checkpath -d ${logfile%/*}

For documentation:
 apk add openrc-doc
 man runscript

We should add how to create dirs for pidfiles to the wiki. And no, we
cannot expect the package create subdirs under /var/run (or /run)
because /var/run could be a tmpfs mount.

---

---

From: Der Tiger <[email-masked]>
Date: Sat, 07 Apr 2012 20:09:40 +0200

ReHi Natanael,

Thank you for your immediate reply! I'm sorry for the delay in answering
your mail!

> fatal: cannot convert from ISO-8859-15 to UTF-8
Well, I'm a bl00dy continental generally using ISO format for e-mailing.
;-) I'll make sure to send future patches in UTF-8 format.

You'll find updated patches modified to your suggestions below.

Regards, Tiger

--- /etc/init.d/mini_httpd
+++ /etc/init.d/mini_httpd
@@ -4,6 +4,7 @@
 # $Header:
/var/cvsroot/gentoo-x86/www-servers/mini_httpd/files/mini_httpd.init,v
1.2 2007/08/26 21:20:21 bangert Exp $

 pidfile=/var/run/mini_httpd/${SVCNAME}.pid
+logfile=/var/log/mini_httpd/${SVCNAME}.log

 depend() {
 	need net
@@ -12,9 +13,11 @@

 start() {
 	ebegin "Starting $SVCNAME"
+	checkpath -d ${pidfile%/*}
+	checkpath -d ${logfile%/*}
 	start-stop-daemon --quiet --start --exec /usr/sbin/mini_httpd \
 		--pidfile $pidfile -- -i $pidfile \
-		${MINI_HTTPD_OPTS:--C /etc/${SVCNAME}.conf -l
/var/log/mini_httpd/${SVCNAME}.log}
+		${MINI_HTTPD_OPTS:--C /etc/${SVCNAME}.conf -l $logfile}
 	eend $?
 }

--- /etc/init.d/dhcpd
+++ /etc/init.d/dhcpd
@@ -73,6 +73,7 @@
 	pidfile="${pidfile:-/var/run/dhcp/dhcpd.pid}"

 	ebegin "Starting ${DHCPD_CHROOT:+chrooted }${SVCNAME}"
+	checkpath -o dhcp:dhcp -d ${pidfile%/*}
 	start-stop-daemon --start --exec /usr/sbin/dhcpd \
 		--pidfile "${DHCPD_CHROOT}/${pidfile}" \
 		-- ${DHCPD_OPTS} -q -pf "${pidfile}" \

---