-rw-r--r-- | core/opie-login/main.cpp | 10 |
1 files changed, 9 insertions, 1 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 | |||
@@ -53,37 +53,37 @@ | |||
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, 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 |
84 | 84 | ||
85 | char *autolog = 0; | 85 | char *autolog = 0; |
86 | int c; | 86 | int c; |
87 | while (( c = ::getopt_long ( argc, argv, "a:", long_options, 0 )) != -1 ) { | 87 | while (( c = ::getopt_long ( argc, argv, "a:", long_options, 0 )) != -1 ) { |
88 | switch ( c ) { | 88 | switch ( c ) { |
89 | case 'a': | 89 | case 'a': |
@@ -96,41 +96,44 @@ int main ( int argc, char **argv ) | |||
96 | } | 96 | } |
97 | 97 | ||
98 | //struct rlimit rl; | 98 | //struct rlimit rl; |
99 | //::getrlimit ( RLIMIT_NOFILE, &rl ); | 99 | //::getrlimit ( RLIMIT_NOFILE, &rl ); |
100 | 100 | ||
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 ( ); |
114 | 115 | ||
115 | if ( child < 0 ) { | 116 | if ( child < 0 ) { |
116 | ::syslog ( LOG_ERR, "Could not fork GUI process\n" ); | 117 | ::syslog ( LOG_ERR, "Could not fork GUI process\n" ); |
117 | break; | 118 | break; |
118 | } | 119 | } |
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 { |
131 | ::syslog ( LOG_ERR, "Respawning too fast -- going down\n" ); | 134 | ::syslog ( LOG_ERR, "Respawning too fast -- going down\n" ); |
132 | break; | 135 | break; |
133 | } | 136 | } |
134 | } | 137 | } |
135 | int killedbysig = 0; | 138 | int killedbysig = 0; |
136 | 139 | ||
@@ -140,24 +143,26 @@ int main ( int argc, char **argv ) | |||
140 | case SIGTERM: | 143 | case SIGTERM: |
141 | case SIGKILL: | 144 | case SIGKILL: |
142 | break; | 145 | break; |
143 | 146 | ||
144 | default : | 147 | default : |
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; |
151 | 154 | ||
155 | ::syslog ( LOG_ERR, "Opie was killed by a signal #%d", killedbysig ); | ||
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 | ||
157 | const char *sig = ::strsignal ( killedbysig ); | 162 | const char *sig = ::strsignal ( killedbysig ); |
158 | QLabel *l = new QLabel ( 0, "sig", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool ); | 163 | QLabel *l = new QLabel ( 0, "sig", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool ); |
159 | l-> setText ( LoginWindowImpl::tr( "OPIE was terminated\nby an uncaught signal\n(%1)\n" ). arg ( sig )); | 164 | l-> setText ( LoginWindowImpl::tr( "OPIE was terminated\nby an uncaught signal\n(%1)\n" ). arg ( sig )); |
160 | l-> setAlignment ( Qt::AlignCenter ); | 165 | l-> setAlignment ( Qt::AlignCenter ); |
161 | l-> move ( 0, 0 ); | 166 | l-> move ( 0, 0 ); |
162 | l-> resize ( app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); | 167 | l-> resize ( app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); |
163 | l-> show ( ); | 168 | l-> show ( ); |
@@ -294,31 +299,34 @@ public: | |||
294 | 299 | ||
295 | m_backlight_bright = bright; | 300 | m_backlight_bright = bright; |
296 | } | 301 | } |
297 | 302 | ||
298 | private: | 303 | private: |
299 | bool m_lcd_status; | 304 | bool m_lcd_status; |
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) |
319 | if ( !QFile::exists ( "/etc/pointercal" )) { | 327 | if ( !QFile::exists ( "/etc/pointercal" )) { |
320 | // Make sure calibration widget starts on top. | 328 | // Make sure calibration widget starts on top. |
321 | Calibrate *cal = new Calibrate; | 329 | Calibrate *cal = new Calibrate; |
322 | cal-> exec ( ); | 330 | cal-> exec ( ); |
323 | delete cal; | 331 | delete cal; |
324 | } | 332 | } |