-rw-r--r-- | core/opie-login/main.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/core/opie-login/main.cpp b/core/opie-login/main.cpp index 674829d..81f4d1e 100644 --- a/core/opie-login/main.cpp +++ b/core/opie-login/main.cpp | |||
@@ -59,25 +59,25 @@ | |||
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, pid_t ppid ); | 63 | int login_main ( int argc, char **argv, pid_t ppid ); |
64 | void sigterm ( int sig ); | 64 | void sigterm ( int sig ); |
65 | void sigint ( int sig ); | ||
65 | void exit_closelog ( ); | 66 | void exit_closelog ( ); |
66 | 67 | ||
67 | static struct option long_options [] = { | 68 | static struct option long_options [] = { |
68 | { "autologin", 1, 0, 'a' }, | 69 | { "autologin", 1, 0, 'a' }, |
69 | { 0, 0, 0, 0 } | 70 | { 0, 0, 0, 0 } |
70 | }; | 71 | }; |
71 | 72 | ||
72 | 73 | ||
73 | int main ( int argc, char **argv ) | 74 | int main ( int argc, char **argv ) |
74 | { | 75 | { |
75 | pid_t ppid = ::getpid ( ); | 76 | pid_t ppid = ::getpid ( ); |
76 | 77 | ||
77 | |||
78 | if ( ::geteuid ( ) != 0 ) { | 78 | if ( ::geteuid ( ) != 0 ) { |
79 | ::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] ); |
80 | return 1; | 80 | return 1; |
81 | } | 81 | } |
82 | if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and | 82 | if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and |
83 | ::setuid ( 0 ); // messes up things like config files | 83 | ::setuid ( 0 ); // messes up things like config files |
@@ -101,13 +101,14 @@ int main ( int argc, char **argv ) | |||
101 | //for ( unsigned int i = 0; i < rl. rlim_cur; i++ ) | 101 | //for ( unsigned int i = 0; i < rl. rlim_cur; i++ ) |
102 | // ::close ( i ); | 102 | // ::close ( i ); |
103 | 103 | ||
104 | ::setpgid ( 0, 0 ); | 104 | ::setpgid ( 0, 0 ); |
105 | ::setsid ( ); | 105 | ::setsid ( ); |
106 | 106 | ||
107 | ::signal ( SIGTERM, sigterm ); | 107 | ::signal ( SIGTERM, sigterm ); |
108 | ::signal ( SIGINT, sigterm ); | ||
108 | 109 | ||
109 | ::openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV ); | 110 | ::openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV ); |
110 | ::atexit ( exit_closelog ); | 111 | ::atexit ( exit_closelog ); |
111 | 112 | ||
112 | while ( true ) { | 113 | while ( true ) { |
113 | pid_t child = ::fork ( ); | 114 | pid_t child = ::fork ( ); |
@@ -119,12 +120,14 @@ int main ( int argc, char **argv ) | |||
119 | else if ( child > 0 ) { | 120 | else if ( child > 0 ) { |
120 | int status = 0; | 121 | int status = 0; |
121 | time_t started = ::time ( 0 ); | 122 | time_t started = ::time ( 0 ); |
122 | 123 | ||
123 | while ( ::waitpid ( child, &status, 0 ) < 0 ) { } | 124 | while ( ::waitpid ( child, &status, 0 ) < 0 ) { } |
124 | 125 | ||
126 | LoginApplication::logout ( ); | ||
127 | |||
125 | if (( ::time ( 0 ) - started ) < 3 ) { | 128 | if (( ::time ( 0 ) - started ) < 3 ) { |
126 | if ( autolog ) { | 129 | if ( autolog ) { |
127 | ::syslog ( LOG_ERR, "Respawning too fast -- disabling auto-login\n" ); | 130 | ::syslog ( LOG_ERR, "Respawning too fast -- disabling auto-login\n" ); |
128 | autolog = 0; | 131 | autolog = 0; |
129 | } | 132 | } |
130 | else { | 133 | else { |
@@ -145,12 +148,14 @@ int main ( int argc, char **argv ) | |||
145 | killedbysig = WTERMSIG( status ); | 148 | killedbysig = WTERMSIG( status ); |
146 | break; | 149 | break; |
147 | } | 150 | } |
148 | } | 151 | } |
149 | if ( killedbysig ) { // qpe was killed by an uncaught signal | 152 | if ( killedbysig ) { // qpe was killed by an uncaught signal |
150 | qApp = 0; | 153 | qApp = 0; |
154 | |||
155 | ::syslog ( LOG_ERR, "Opie was killed by a signal #%d", killedbysig ); | ||
151 | 156 | ||
152 | QWSServer::setDesktopBackground ( QImage ( )); | 157 | QWSServer::setDesktopBackground ( QImage ( )); |
153 | QApplication *app = new QApplication ( argc, argv, QApplication::GuiServer ); | 158 | QApplication *app = new QApplication ( argc, argv, QApplication::GuiServer ); |
154 | app-> setFont ( QFont ( "Helvetica", 10 )); | 159 | app-> setFont ( QFont ( "Helvetica", 10 )); |
155 | app-> setStyle ( new QPEStyle ( )); | 160 | app-> setStyle ( new QPEStyle ( )); |
156 | 161 | ||
@@ -300,19 +305,22 @@ private: | |||
300 | 305 | ||
301 | int m_backlight_bright; | 306 | int m_backlight_bright; |
302 | bool m_backlight_forcedoff; | 307 | bool m_backlight_forcedoff; |
303 | }; | 308 | }; |
304 | 309 | ||
305 | 310 | ||
311 | namespace Opie { extern int force_appearance; } // HACK to get around the force-style setting | ||
306 | 312 | ||
307 | 313 | ||
308 | int login_main ( int argc, char **argv, pid_t ppid ) | 314 | int login_main ( int argc, char **argv, pid_t ppid ) |
309 | { | 315 | { |
310 | QWSServer::setDesktopBackground( QImage() ); | 316 | QWSServer::setDesktopBackground( QImage() ); |
311 | LoginApplication *app = new LoginApplication ( argc, argv, ppid ); | 317 | LoginApplication *app = new LoginApplication ( argc, argv, ppid ); |
312 | 318 | ||
319 | Opie::force_appearance = 0; | ||
320 | |||
313 | app-> setFont ( QFont ( "Helvetica", 10 )); | 321 | app-> setFont ( QFont ( "Helvetica", 10 )); |
314 | app-> setStyle ( new QPEStyle ( )); | 322 | app-> setStyle ( new QPEStyle ( )); |
315 | 323 | ||
316 | ODevice::inst ( )-> setSoftSuspend ( true ); | 324 | ODevice::inst ( )-> setSoftSuspend ( true ); |
317 | 325 | ||
318 | #if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 326 | #if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |