From 4f483f13e3c624a0ce6161e6ddd6923b4d101f0e Mon Sep 17 00:00:00 2001 From: kergoth Date: Fri, 14 Mar 2003 19:22:43 +0000 Subject: Two bugs fixed: 1) We werent checking for failure on execlp() of shutdown 2) We assumed that /sbin was in the PATH, as otherwise one cannot execute shutdown. This is a flawed assumption, particularly in the case of running Opie as a nonroot user. In the case of OZ 3.1rc3.1, /etc/profile no longer puts the sbin dirs in the PATH (it never should have in the first place), and opie doesnt source $HOME/.profile in its startup script, which resulted in the shutdown app failing to reboot or shutdown. Fixed by using execle rather than execlp, and specifying /sbin and /usr/sbin as the executed path for shutdown. --- diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 03a23dc..4c239a6 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp @@ -18,6 +18,8 @@ ** **********************************************************************/ +#include + #include "desktop.h" #include "info.h" #include "launcher.h" @@ -738,12 +740,20 @@ void DesktopApplication::shutdown() void DesktopApplication::shutdown( ShutdownImpl::Type t ) { + + char *opt = 0; + switch ( t ) { case ShutdownImpl::ShutdownSystem: - execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 ); - break; + opt = "-h"; + // fall through case ShutdownImpl::RebootSystem: - execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 ); + if ( opt == 0 ) + opt = "-r"; + + if ( execle( "shutdown", "shutdown", opt, "now", ( void* ) 0, "/sbin", "/usr/sbin", ( void* ) 0 ) < 0 ) + ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); + break; case ShutdownImpl::RestartDesktop: restart(); -- cgit v0.9.0.2