File: 0004-consider-initd-shebangs.patch

package info (click to toggle)
openrc 0.63-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,412 kB
  • sloc: ansic: 16,255; sh: 2,225; perl: 28; makefile: 26
file content (34 lines) | stat: -rw-r--r-- 937 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From: Gabriele Giacone <1o5g4r8o@gmail.com>
Date: Wed, 4 Jan 2017 21:42:01 +0900
Subject: consider-initd-shebangs

Description: Allow non-sh shebang in init.d scripts.
 If /bin/sh is not detected in initscript shebang, to avoid for instance
 bashisms /bin/sh can't understand, runscript re-runs itself with non-sh
 shell. This workarounds failures starting non-sh initscript.
---
 sh/openrc-run.sh.in | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/sh/openrc-run.sh.in b/sh/openrc-run.sh.in
index 62487c3..13b4fb8 100644
--- a/sh/openrc-run.sh.in
+++ b/sh/openrc-run.sh.in
@@ -361,7 +361,16 @@ if [ "$1" = depend ]; then
 
 	return 0
 elif [ -n "${lsbh}" ]; then
-	. "${RC_SERVICE}"
+	read -r shebang < "${RC_SERVICE}"
+	case "${shebang}" in
+	*runscript*|*openrc-run*)
+		. "${RC_SERVICE}"
+		;;
+	*)
+		. /etc/profile # Reset to vanilla PATH
+		exec "${RC_SERVICE}" $*
+		;;
+	esac
 	shift
 
 	return 0