Your message dated Thu, 23 Jan 2025 18:44:08 +0100
with message-id <z5j_6dpmf-ebn...@per.namespace.at>
and subject line Re: Bug#465520: sysrqd: facility to also orderly shut down a 
remote computer
has caused the Debian Bug report #465520,
regarding sysrqd: facility to also orderly shut down a remote computer
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact ow...@bugs.debian.org
immediately.)


-- 
465520: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=465520
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems
--- Begin Message ---
Package: sysrqd
Version: sysrqd9-2
Severity: wishlist
Tags: patch

Hi,

the appended patch includes an additional, very simple interface to 
the 'shutdown'
command in sysrqd. It allows to shut down or reboot a remote machine by
executing a command like
sysrq> -<shutdown-option><minutes>

where <shutdown-option> is one of the shutdown options '-r', '-h' etc. and
minutes is a mandatory one digit number defining the timeout in minutes.
For example "-h6" causes a shutdown and halt in 6 minutes.

The reason to have such a facility in sysrqd is 

1. that sometimes an orderly shutdown (with proper stopping of network 
connections) 
   is possible after a remount-ro (u)
2. this daemon seems to be the best place (except maybe a remote ssh key
   for root?!) to have some kind of remote shutdown command for a 
   small set of computers which are all booted and shut down at the same
   time.
 
Greetings,

Onno


-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (900, 'stable'), (450, 'testing'), (225, 'unstable')
Architecture: amd64 (x86_64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.22-2-amd64
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
diff --git a/sysrqd.c b/sysrqd.c
index af19f20..00cecf5 100644
--- a/sysrqd.c
+++ b/sysrqd.c
@@ -101,9 +101,27 @@ read_cmd (int sock_client, int fd_sysrq)
       if(buf == '\n')
 	write_prompt (sock_client);
 
-      if((buf >= 48 && buf <= 57) ||
+      if((buf >= 48 && buf <= 57) || /* letter: commands to sysrq */
 	 (buf >= 97 && buf <= 122 ))
 	write(fd_sysrq, &buf, 1);
+      else if (buf=='-') { /* '-' for shutdown/reboot */
+	char act;
+	read(sock_client, &act, 1);
+	if (act!='h' && act!='r' && act!='H' &&
+	    act!='P' && act!='c')
+	  continue;
+
+	if (act!='c') {
+	    /* read delay argument (in minutes) */
+	    read(sock_client, &buf, 1);
+	    if (buf<'0' || buf>'9')
+		continue;
+	} else buf=' ';
+	
+	char cmd[50];
+	snprintf(cmd, 50, SHUTDOWN_CMD, act, buf);
+	system(cmd);
+      }
     }
   while(read (sock_client, &buf, 1) && buf != 'q');
 }
diff --git a/sysrqd.h b/sysrqd.h
index c6fe770..4d52dbf 100644
--- a/sysrqd.h
+++ b/sysrqd.h
@@ -7,5 +7,6 @@
 #define AUTH_FILE "/etc/sysrqd.secret"
 #define BINDIP_FILE "/etc/sysrqd.bind"
 #define PID_FILE "/var/run/sysrqd.pid"
+#define SHUTDOWN_CMD "/bin/bash -c \"/sbin/shutdown -%c %c&\""
 #define SYSRQD_PRIO -19
 #define SYSRQD_LISTEN_PORT 4094

--- End Message ---
--- Begin Message ---
On Mon, Feb 25, 2008 at 03:29:46PM +0100, Julien Danjou wrote:
> I don't feel like I will integrate this upstream because it's not the
> goal of sysrqd to do a such thing IMHO.

Looks like this will never happen, and then we don't need to keep
this bug open for nothing.

--- End Message ---

Reply via email to