[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#140963: Patch



OoO Peu avant le  début de l'après-midi  du mardi 02 avril  2002, vers
13:56,  "Federico    'Derfel'    Stella" <derfel@alessandria.linux.it>
disait:

> --- /var/lib/dpkg/info/ssh.postinst	Sun Mar 24 15:04:21 2002
[...]

Since there is no answer, here is another patch :

--- /etc/init.d/ssh	2003-11-15 17:21:31.000000000 -0800
+++ ssh	2003-12-27 10:52:28.432934272 -0800
@@ -11,10 +11,15 @@
 fi
 
 check_for_no_start() {
-    # forget it if we're trying to start, and /etc/ssh/sshd_not_to_be_run exists
-    if [ -e /etc/ssh/sshd_not_to_be_run ]; then 
-	echo "OpenBSD Secure Shell server not in use (/etc/ssh/sshd_not_to_be_run)"
-	exit 0
+    invocation=$(basename $0)
+    # if the script is invoked as Sxx* or Kxx*, we should respect the presence
+    # of /etc/ssh/sshd_not_to_be_run. Otherwise, the user is trying to execute
+    # it by hand and sshd should be run.
+    if echo $invocation | grep -E -q '^(S|K)[0-9][0-9]'; then
+	if [ -e /etc/ssh/sshd_not_to_be_run ]; then 
+	    echo "OpenBSD Secure Shell server not in use (/etc/ssh/sshd_not_to_be_run)"
+	    exit 0
+	fi
     fi
 }
 
--- /var/lib/dpkg/info/ssh.postinst	2003-11-15 17:21:55.000000000 -0800
+++ ssh.postinst	2003-12-27 10:59:08.380133056 -0800
@@ -300,7 +300,9 @@
 setup_init() {
 	if [ -e /etc/init.d/ssh ]; then
 		update-rc.d ssh defaults >/dev/null
-		/etc/init.d/ssh restart
+		if [ ! -e /etc/ssh/sshd_not_to_be_run ]; then
+		    /etc/init.d/ssh restart
+		fi
 	fi
 }
 
Another approach is to use force-start to force the server to start :

--- /etc/init.d/ssh	2003-11-15 17:21:31.000000000 -0800
+++ ssh	2003-12-27 11:13:24.517980320 -0800
@@ -12,8 +12,12 @@
 
 check_for_no_start() {
     # forget it if we're trying to start, and /etc/ssh/sshd_not_to_be_run exists
-    if [ -e /etc/ssh/sshd_not_to_be_run ]; then 
+    if [ -z "$NOCHECK" -a -e /etc/ssh/sshd_not_to_be_run ]; then 
+	if [ $1 == "restart" ]; then
+	    echo
+	fi
 	echo "OpenBSD Secure Shell server not in use (/etc/ssh/sshd_not_to_be_run)"
+	echo "Use \"force-$1\" instead of \"$1\" if you really want to use it"
 	exit 0
     fi
 }
@@ -36,7 +40,7 @@
 
 case "$1" in
   start)
-	check_for_no_start
+	check_for_no_start $1
 	check_privsep_dir
         echo -n "Starting OpenBSD Secure Shell server: sshd"
 	start-stop-daemon --start --quiet --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS
@@ -48,8 +52,8 @@
         echo "."
 	;;
 
-  reload|force-reload)
-	check_for_no_start
+  reload)
+	check_for_no_start $1
 	check_config
         echo -n "Reloading OpenBSD Secure Shell server's configuration"
 	start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd
@@ -60,12 +64,17 @@
 	check_config
         echo -n "Restarting OpenBSD Secure Shell server: sshd"
 	start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile /var/run/sshd.pid
-	check_for_no_start
+	check_for_no_start $1
 	check_privsep_dir
 	start-stop-daemon --start --quiet --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS
 	echo "."
 	;;
 
+  force-*)
+	export NOCHECK=1
+	$0 $(echo "$1" | sed 's/^force-//')
+	;;
+
   *)
 	echo "Usage: /etc/init.d/ssh {start|stop|reload|force-reload|restart}"
 	exit 1
-- 
IT DOES NOT SUCK TO BE YOU
IT DOES NOT SUCK TO BE YOU
IT DOES NOT SUCK TO BE YOU
-+- Bart Simpson on chalkboard in episode AABF13

Attachment: pgpWsA_VP4hej.pgp
Description: PGP signature


Reply to: