All of lore.kernel.org
 help / color / mirror / Atom feed
From: aq <aquynh@gmail.com>
To: Ian Pratt <m+Ian.Pratt@cl.cam.ac.uk>
Cc: xen-devel <xen-devel@lists.xensource.com>
Subject: Re: execve() in reboot.c ?
Date: Tue, 26 Jul 2005 02:41:31 +0900	[thread overview]
Message-ID: <9cde8bff050725104174d9314b@mail.gmail.com> (raw)
In-Reply-To: <A95E2296287EAD4EB592B5DEEFCE0E9D282767@liverpoolst.ad.cl.cam.ac.uk>

[-- Attachment #1: Type: text/plain, Size: 1441 bytes --]

On 7/25/05, Ian Pratt <m+Ian.Pratt@cl.cam.ac.uk> wrote:
>  > Domain kernel has arch/xen/kernel/reboot.c, which executes
> > shutdown and halt on request. But one problem is that we have
> > the path and command options fixed in the kernel, like this:
> >
> >
> >     static char *restart_argv[]  = { "/sbin/shutdown", "-r",
> > "now", NULL };
> >     static char *poweroff_argv[] = { "/sbin/halt",     "-p",
> >       NULL };
> >
> >
> > That is kind of violating the rule: kernel should never
> > enforce the policy to the user. We can see the problem if for
> > example domU uses busybox instead of sysvinit: busybox doesnt
> > support "halt -p", so "xm shutdown" cannot shutdown the domU.
> 
> Would 'telinit 1' / 'telinit 6' work on busybox ?
> 

Unfortunately telinit is not available in busybox. 

Here are 2 patches (for -testing and -unstable), in which i replaced
shutdown and halt with poweroff and reboot, and executes those without
any options. This patch confirms to work with both sysvinit (on
Ubuntu) and busybox (ttylinux - without these patch i couldnt shutdown
ttylinux with "xm shutdown"). Please apply.


Signed-off-by: Nguyen Anh Quynh <aquynh@gmail.com>


$ diffstat shutdown.testing.patch 
 reboot.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

$ diffstat shutdown.unstable.patch 
 reboot.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

[-- Attachment #2: shutdown.unstable.patch --]
[-- Type: application/octet-stream, Size: 1406 bytes --]

diff -r 48aed1403fe3 linux-2.6-xen-sparse/arch/xen/kernel/reboot.c
--- a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c	Fri Jul 22 16:44:33 2005
+++ b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c	Tue Jul 26 02:22:34 2005
@@ -172,8 +172,8 @@
 {
     static char *envp[] = { "HOME=/", "TERM=linux", 
                             "PATH=/sbin:/usr/sbin:/bin:/usr/bin", NULL };
-    static char *restart_argv[]  = { "/sbin/shutdown", "-r", "now", NULL };
-    static char *poweroff_argv[] = { "/sbin/halt",     "-p",        NULL };
+    static char *restart_argv[]  = { "/sbin/reboot", NULL };
+    static char *poweroff_argv[] = { "/sbin/poweroff", NULL };
 
     extern asmlinkage long sys_reboot(int magic1, int magic2,
                                       unsigned int cmd, void *arg);
@@ -187,7 +187,7 @@
     switch ( shutting_down )
     {
     case CMSG_SHUTDOWN_POWEROFF:
-        if ( execve("/sbin/halt", poweroff_argv, envp) < 0 )
+        if ( execve("/sbin/poweroff", poweroff_argv, envp) < 0 )
         {
             sys_reboot(LINUX_REBOOT_MAGIC1,
                        LINUX_REBOOT_MAGIC2,
@@ -197,7 +197,7 @@
         break;
 
     case CMSG_SHUTDOWN_REBOOT:
-        if ( execve("/sbin/shutdown", restart_argv, envp) < 0 )
+        if ( execve("/sbin/reboot", restart_argv, envp) < 0 )
         {
             sys_reboot(LINUX_REBOOT_MAGIC1,
                        LINUX_REBOOT_MAGIC2,

[-- Attachment #3: shutdown.testing.patch --]
[-- Type: application/octet-stream, Size: 1415 bytes --]

diff -r 026436ebd99c linux-2.6.11-xen-sparse/arch/xen/kernel/reboot.c
--- a/linux-2.6.11-xen-sparse/arch/xen/kernel/reboot.c	Mon Jul 18 07:45:41 2005
+++ b/linux-2.6.11-xen-sparse/arch/xen/kernel/reboot.c	Tue Jul 26 02:24:38 2005
@@ -159,8 +159,8 @@
 {
     static char *envp[] = { "HOME=/", "TERM=linux", 
                             "PATH=/sbin:/usr/sbin:/bin:/usr/bin", NULL };
-    static char *restart_argv[]  = { "/sbin/shutdown", "-r", "now", NULL };
-    static char *poweroff_argv[] = { "/sbin/halt",     "-p",        NULL };
+    static char *restart_argv[]  = { "/sbin/reboot", NULL };
+    static char *poweroff_argv[] = { "/sbin/poweroff", NULL };
 
     extern asmlinkage long sys_reboot(int magic1, int magic2,
                                       unsigned int cmd, void *arg);
@@ -174,7 +174,7 @@
     switch ( shutting_down )
     {
     case CMSG_SHUTDOWN_POWEROFF:
-        if ( execve("/sbin/halt", poweroff_argv, envp) < 0 )
+        if ( execve("/sbin/poweroff", poweroff_argv, envp) < 0 )
         {
             sys_reboot(LINUX_REBOOT_MAGIC1,
                        LINUX_REBOOT_MAGIC2,
@@ -184,7 +184,7 @@
         break;
 
     case CMSG_SHUTDOWN_REBOOT:
-        if ( execve("/sbin/shutdown", restart_argv, envp) < 0 )
+        if ( execve("/sbin/reboot", restart_argv, envp) < 0 )
         {
             sys_reboot(LINUX_REBOOT_MAGIC1,
                        LINUX_REBOOT_MAGIC2,

[-- Attachment #4: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

  reply	other threads:[~2005-07-25 17:41 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-25 11:00 execve() in reboot.c ? Ian Pratt
2005-07-25 17:41 ` aq [this message]
2005-07-25 17:47   ` Mark Williamson
2005-07-25 17:56     ` Jeremy Katz
2005-07-25 18:03       ` Mark Williamson
2005-07-25 18:13         ` Rik van Riel
2005-07-25 18:20           ` Vincent Hanquez
2005-07-25 18:30             ` Anthony Liguori
2005-07-25 19:18             ` Rik van Riel
2005-07-25 18:26           ` Mark Williamson
2005-07-25 18:26         ` aq
2005-07-25 18:29           ` Mark Williamson
2005-07-25 18:31           ` Vincent Hanquez
  -- strict thread matches above, loose matches on Subject: below --
2005-07-25 19:48 Ian Pratt
2005-07-25 20:18 ` Sean Dague
2005-07-25 20:31 ` Philip R Auld
2005-07-26 12:55   ` Gerd Knorr
2005-07-25 20:48 ` Mark Williamson
2005-07-25 20:46   ` Keir Fraser
2005-07-25 20:52   ` Rik van Riel
2005-07-25  8:53 aq

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9cde8bff050725104174d9314b@mail.gmail.com \
    --to=aquynh@gmail.com \
    --cc=m+Ian.Pratt@cl.cam.ac.uk \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.