author | sandman <sandman> | 2002-10-29 19:33:49 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-29 19:33:49 (UTC) |
commit | 7c340d2a08601f4d27f6d2a407fc0de437b8efad (patch) (side-by-side diff) | |
tree | c6a01ef4e7623ea1da758030e691531f0476885e | |
parent | 2957aae1073f4c41dd6783c41d1199be71cd9f4a (diff) | |
download | opie-7c340d2a08601f4d27f6d2a407fc0de437b8efad.zip opie-7c340d2a08601f4d27f6d2a407fc0de437b8efad.tar.gz opie-7c340d2a08601f4d27f6d2a407fc0de437b8efad.tar.bz2 |
when quitting opie-login, don't kill the process id returned by getppid(),
but use the previously saved "real" parent pid.
-rw-r--r-- | core/opie-login/loginapplication.cpp | 5 | ||||
-rw-r--r-- | core/opie-login/loginapplication.h | 5 | ||||
-rw-r--r-- | core/opie-login/main.cpp | 11 |
3 files changed, 14 insertions, 7 deletions
diff --git a/core/opie-login/loginapplication.cpp b/core/opie-login/loginapplication.cpp index 103d63b..8d86a71 100644 --- a/core/opie-login/loginapplication.cpp +++ b/core/opie-login/loginapplication.cpp @@ -41,16 +41,17 @@ extern "C" { #endif #include "loginapplication.h" LoginApplication *lApp; -LoginApplication::LoginApplication ( int &argc, char **argv ) +LoginApplication::LoginApplication ( int &argc, char **argv, pid_t parentpid ) : QPEApplication ( argc, argv, GuiServer ) { lApp = this; + m_parentpid = parentpid; } const char *LoginApplication::s_username = 0; #ifdef USEPAM @@ -213,8 +214,8 @@ QStringList LoginApplication::allUsers ( ) return sl; } void LoginApplication::quitToConsole ( ) { QPEApplication::quit ( ); - ::kill ( ::getppid ( ), SIGTERM ); + ::kill ( m_parentpid, SIGTERM ); } diff --git a/core/opie-login/loginapplication.h b/core/opie-login/loginapplication.h index 062c088..4e7cf79 100644 --- a/core/opie-login/loginapplication.h +++ b/core/opie-login/loginapplication.h @@ -36,13 +36,13 @@ struct pam_message; struct pam_response; #endif class LoginApplication : public QPEApplication { public: - LoginApplication ( int &argc, char **argv ); + LoginApplication ( int &argc, char **argv, pid_t parentpid ); static bool checkPassword ( const char *user, const char *password ); static const char *loginAs ( ); static void setLoginAs ( const char *user ); @@ -57,11 +57,14 @@ private: static const char *s_username; #ifdef USEPAM static int pam_helper ( int num_msg, const struct pam_message **msg, struct pam_response **resp, void * ); static const char *s_pam_password; #endif + +private: + pid_t m_parentpid; }; extern LoginApplication *lApp; #endif diff --git a/core/opie-login/main.cpp b/core/opie-login/main.cpp index 579a93a..674829d 100644 --- a/core/opie-login/main.cpp +++ b/core/opie-login/main.cpp @@ -57,24 +57,27 @@ #include "loginapplication.h" #include "loginwindowimpl.h" #include "calibrate.h" using namespace Opie; -int login_main ( int argc, char **argv ); +int login_main ( int argc, char **argv, pid_t ppid ); void sigterm ( int sig ); void exit_closelog ( ); static struct option long_options [] = { { "autologin", 1, 0, 'a' }, { 0, 0, 0, 0 } }; int main ( int argc, char **argv ) { + pid_t ppid = ::getpid ( ); + + if ( ::geteuid ( ) != 0 ) { ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] ); return 1; } if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and ::setuid ( 0 ); // messes up things like config files @@ -180,13 +183,13 @@ int main ( int argc, char **argv ) if ( LoginApplication::changeIdentity ( )) ::exit ( LoginApplication::login ( )); else ::exit ( 0 ); } else - ::exit ( login_main ( argc, argv )); + ::exit ( login_main ( argc, argv, ppid )); } } return 0; } void sigterm ( int /*sig*/ ) @@ -299,16 +302,16 @@ private: bool m_backlight_forcedoff; }; -int login_main ( int argc, char **argv ) +int login_main ( int argc, char **argv, pid_t ppid ) { QWSServer::setDesktopBackground( QImage() ); - LoginApplication *app = new LoginApplication ( argc, argv ); + LoginApplication *app = new LoginApplication ( argc, argv, ppid ); app-> setFont ( QFont ( "Helvetica", 10 )); app-> setStyle ( new QPEStyle ( )); ODevice::inst ( )-> setSoftSuspend ( true ); |