author | sandman <sandman> | 2002-10-29 19:33:49 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-29 19:33:49 (UTC) |
commit | 7c340d2a08601f4d27f6d2a407fc0de437b8efad (patch) (unidiff) | |
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 | |||
@@ -35,28 +35,29 @@ | |||
35 | extern "C" { | 35 | extern "C" { |
36 | #include <security/pam_appl.h> | 36 | #include <security/pam_appl.h> |
37 | } | 37 | } |
38 | #else | 38 | #else |
39 | #include <crypt.h> | 39 | #include <crypt.h> |
40 | #include <shadow.h> | 40 | #include <shadow.h> |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | #include "loginapplication.h" | 43 | #include "loginapplication.h" |
44 | 44 | ||
45 | LoginApplication *lApp; | 45 | LoginApplication *lApp; |
46 | 46 | ||
47 | LoginApplication::LoginApplication ( int &argc, char **argv ) | 47 | LoginApplication::LoginApplication ( int &argc, char **argv, pid_t parentpid ) |
48 | : QPEApplication ( argc, argv, GuiServer ) | 48 | : QPEApplication ( argc, argv, GuiServer ) |
49 | { | 49 | { |
50 | lApp = this; | 50 | lApp = this; |
51 | m_parentpid = parentpid; | ||
51 | } | 52 | } |
52 | 53 | ||
53 | const char *LoginApplication::s_username = 0; | 54 | const char *LoginApplication::s_username = 0; |
54 | 55 | ||
55 | #ifdef USEPAM | 56 | #ifdef USEPAM |
56 | 57 | ||
57 | const char *LoginApplication::s_pam_password = 0; | 58 | const char *LoginApplication::s_pam_password = 0; |
58 | 59 | ||
59 | int LoginApplication::pam_helper ( int num_msg, const struct pam_message **msg, struct pam_response **resp, void * ) | 60 | int LoginApplication::pam_helper ( int num_msg, const struct pam_message **msg, struct pam_response **resp, void * ) |
60 | { | 61 | { |
61 | int replies = 0; | 62 | int replies = 0; |
62 | struct pam_response *reply = 0; | 63 | struct pam_response *reply = 0; |
@@ -207,14 +208,14 @@ QStringList LoginApplication::allUsers ( ) | |||
207 | if (( pwd-> pw_uid == 0 ) || ( pwd-> pw_uid >= 500 && pwd-> pw_uid < 65534 )) | 208 | if (( pwd-> pw_uid == 0 ) || ( pwd-> pw_uid >= 500 && pwd-> pw_uid < 65534 )) |
208 | sl << QString ( pwd-> pw_name ); | 209 | sl << QString ( pwd-> pw_name ); |
209 | } | 210 | } |
210 | 211 | ||
211 | ::endpwent ( ); | 212 | ::endpwent ( ); |
212 | 213 | ||
213 | return sl; | 214 | return sl; |
214 | } | 215 | } |
215 | 216 | ||
216 | void LoginApplication::quitToConsole ( ) | 217 | void LoginApplication::quitToConsole ( ) |
217 | { | 218 | { |
218 | QPEApplication::quit ( ); | 219 | QPEApplication::quit ( ); |
219 | ::kill ( ::getppid ( ), SIGTERM ); | 220 | ::kill ( m_parentpid, SIGTERM ); |
220 | } | 221 | } |
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 | |||
@@ -30,38 +30,41 @@ | |||
30 | 30 | ||
31 | #include <qstringlist.h> | 31 | #include <qstringlist.h> |
32 | 32 | ||
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | 34 | ||
35 | #ifdef USEPAM | 35 | #ifdef USEPAM |
36 | struct pam_message; | 36 | struct pam_message; |
37 | struct pam_response; | 37 | struct pam_response; |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | class LoginApplication : public QPEApplication { | 40 | class LoginApplication : public QPEApplication { |
41 | public: | 41 | public: |
42 | LoginApplication ( int &argc, char **argv ); | 42 | LoginApplication ( int &argc, char **argv, pid_t parentpid ); |
43 | 43 | ||
44 | static bool checkPassword ( const char *user, const char *password ); | 44 | static bool checkPassword ( const char *user, const char *password ); |
45 | 45 | ||
46 | static const char *loginAs ( ); | 46 | static const char *loginAs ( ); |
47 | static void setLoginAs ( const char *user ); | 47 | static void setLoginAs ( const char *user ); |
48 | 48 | ||
49 | static bool changeIdentity ( ); | 49 | static bool changeIdentity ( ); |
50 | static bool login ( ); | 50 | static bool login ( ); |
51 | 51 | ||
52 | static QStringList allUsers ( ); | 52 | static QStringList allUsers ( ); |
53 | 53 | ||
54 | void quitToConsole ( ); | 54 | void quitToConsole ( ); |
55 | 55 | ||
56 | private: | 56 | private: |
57 | static const char *s_username; | 57 | static const char *s_username; |
58 | 58 | ||
59 | #ifdef USEPAM | 59 | #ifdef USEPAM |
60 | static int pam_helper ( int num_msg, const struct pam_message **msg, struct pam_response **resp, void * ); | 60 | static int pam_helper ( int num_msg, const struct pam_message **msg, struct pam_response **resp, void * ); |
61 | static const char *s_pam_password; | 61 | static const char *s_pam_password; |
62 | #endif | 62 | #endif |
63 | |||
64 | private: | ||
65 | pid_t m_parentpid; | ||
63 | }; | 66 | }; |
64 | 67 | ||
65 | extern LoginApplication *lApp; | 68 | extern LoginApplication *lApp; |
66 | 69 | ||
67 | #endif | 70 | #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 | |||
@@ -51,36 +51,39 @@ | |||
51 | #include <qwindowsystem_qws.h> | 51 | #include <qwindowsystem_qws.h> |
52 | #include <qmessagebox.h> | 52 | #include <qmessagebox.h> |
53 | #include <qlabel.h> | 53 | #include <qlabel.h> |
54 | #include <qtimer.h> | 54 | #include <qtimer.h> |
55 | #include <qfile.h> | 55 | #include <qfile.h> |
56 | 56 | ||
57 | #include "loginapplication.h" | 57 | #include "loginapplication.h" |
58 | #include "loginwindowimpl.h" | 58 | #include "loginwindowimpl.h" |
59 | #include "calibrate.h" | 59 | #include "calibrate.h" |
60 | 60 | ||
61 | using namespace Opie; | 61 | using namespace Opie; |
62 | 62 | ||
63 | int login_main ( int argc, char **argv ); | 63 | int login_main ( int argc, char **argv, pid_t ppid ); |
64 | void sigterm ( int sig ); | 64 | void sigterm ( int sig ); |
65 | void exit_closelog ( ); | 65 | void exit_closelog ( ); |
66 | 66 | ||
67 | static struct option long_options [] = { | 67 | static struct option long_options [] = { |
68 | { "autologin", 1, 0, 'a' }, | 68 | { "autologin", 1, 0, 'a' }, |
69 | { 0, 0, 0, 0 } | 69 | { 0, 0, 0, 0 } |
70 | }; | 70 | }; |
71 | 71 | ||
72 | 72 | ||
73 | int main ( int argc, char **argv ) | 73 | int main ( int argc, char **argv ) |
74 | { | 74 | { |
75 | pid_t ppid = ::getpid ( ); | ||
76 | |||
77 | |||
75 | if ( ::geteuid ( ) != 0 ) { | 78 | if ( ::geteuid ( ) != 0 ) { |
76 | ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] ); | 79 | ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] ); |
77 | return 1; | 80 | return 1; |
78 | } | 81 | } |
79 | if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and | 82 | if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and |
80 | ::setuid ( 0 ); // messes up things like config files | 83 | ::setuid ( 0 ); // messes up things like config files |
81 | 84 | ||
82 | char *autolog = 0; | 85 | char *autolog = 0; |
83 | int c; | 86 | int c; |
84 | while (( c = ::getopt_long ( argc, argv, "a:", long_options, 0 )) != -1 ) { | 87 | while (( c = ::getopt_long ( argc, argv, "a:", long_options, 0 )) != -1 ) { |
85 | switch ( c ) { | 88 | switch ( c ) { |
86 | case 'a': | 89 | case 'a': |
@@ -174,25 +177,25 @@ int main ( int argc, char **argv ) | |||
174 | autolog = ::strdup ( user. latin1 ( )); | 177 | autolog = ::strdup ( user. latin1 ( )); |
175 | } | 178 | } |
176 | 179 | ||
177 | if ( autolog ) { | 180 | if ( autolog ) { |
178 | LoginApplication::setLoginAs ( autolog ); | 181 | LoginApplication::setLoginAs ( autolog ); |
179 | 182 | ||
180 | if ( LoginApplication::changeIdentity ( )) | 183 | if ( LoginApplication::changeIdentity ( )) |
181 | ::exit ( LoginApplication::login ( )); | 184 | ::exit ( LoginApplication::login ( )); |
182 | else | 185 | else |
183 | ::exit ( 0 ); | 186 | ::exit ( 0 ); |
184 | } | 187 | } |
185 | else | 188 | else |
186 | ::exit ( login_main ( argc, argv )); | 189 | ::exit ( login_main ( argc, argv, ppid )); |
187 | } | 190 | } |
188 | } | 191 | } |
189 | return 0; | 192 | return 0; |
190 | } | 193 | } |
191 | 194 | ||
192 | void sigterm ( int /*sig*/ ) | 195 | void sigterm ( int /*sig*/ ) |
193 | { | 196 | { |
194 | ::exit ( 0 ); | 197 | ::exit ( 0 ); |
195 | } | 198 | } |
196 | 199 | ||
197 | 200 | ||
198 | void exit_closelog ( ) | 201 | void exit_closelog ( ) |
@@ -293,28 +296,28 @@ public: | |||
293 | } | 296 | } |
294 | 297 | ||
295 | private: | 298 | private: |
296 | bool m_lcd_status; | 299 | bool m_lcd_status; |
297 | 300 | ||
298 | int m_backlight_bright; | 301 | int m_backlight_bright; |
299 | bool m_backlight_forcedoff; | 302 | bool m_backlight_forcedoff; |
300 | }; | 303 | }; |
301 | 304 | ||
302 | 305 | ||
303 | 306 | ||
304 | 307 | ||
305 | int login_main ( int argc, char **argv ) | 308 | int login_main ( int argc, char **argv, pid_t ppid ) |
306 | { | 309 | { |
307 | QWSServer::setDesktopBackground( QImage() ); | 310 | QWSServer::setDesktopBackground( QImage() ); |
308 | LoginApplication *app = new LoginApplication ( argc, argv ); | 311 | LoginApplication *app = new LoginApplication ( argc, argv, ppid ); |
309 | 312 | ||
310 | app-> setFont ( QFont ( "Helvetica", 10 )); | 313 | app-> setFont ( QFont ( "Helvetica", 10 )); |
311 | app-> setStyle ( new QPEStyle ( )); | 314 | app-> setStyle ( new QPEStyle ( )); |
312 | 315 | ||
313 | ODevice::inst ( )-> setSoftSuspend ( true ); | 316 | ODevice::inst ( )-> setSoftSuspend ( true ); |
314 | 317 | ||
315 | #if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 318 | #if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
316 | if ( !QFile::exists ( "/etc/pointercal" )) { | 319 | if ( !QFile::exists ( "/etc/pointercal" )) { |
317 | // Make sure calibration widget starts on top. | 320 | // Make sure calibration widget starts on top. |
318 | Calibrate *cal = new Calibrate; | 321 | Calibrate *cal = new Calibrate; |
319 | cal-> exec ( ); | 322 | cal-> exec ( ); |
320 | delete cal; | 323 | delete cal; |