summaryrefslogtreecommitdiff
authorerik <erik>2007-01-29 21:38:26 (UTC)
committer erik <erik>2007-01-29 21:38:26 (UTC)
commit597643805ce89c1237035e7f38ec953cfc0d080f (patch) (unidiff)
tree9ec8465a1a1c34346e7ee9c40c2d810910f66162
parent777cace646507cf4222f0a6d5beb2cd44ec45a0a (diff)
downloadopie-597643805ce89c1237035e7f38ec953cfc0d080f.zip
opie-597643805ce89c1237035e7f38ec953cfc0d080f.tar.gz
opie-597643805ce89c1237035e7f38ec953cfc0d080f.tar.bz2
Reformat according to current Opie style.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/opie-login/main.cpp48
1 files changed, 25 insertions, 23 deletions
diff --git a/core/opie-login/main.cpp b/core/opie-login/main.cpp
index 3f1077c..b76d2c7 100644
--- a/core/opie-login/main.cpp
+++ b/core/opie-login/main.cpp
@@ -72,14 +72,17 @@ int main ( int argc, char **argv )
72 ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)\n", argv [0] ); 72 ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)\n", argv [0] );
73 return 1; 73 return 1;
74 } 74 }
75 if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and 75 /*!
76 ::setuid ( 0 ); // messes up things like config files 76 * @bug
77 77 * Qte does not really like being set UID root. This is
78 //struct rlimit rl; 78 * largely because we do almost everything on config files
79 //::getrlimit ( RLIMIT_NOFILE, &rl ); 79 * in root context. So if you even want to use opie-login
80 80 * you are in for a world of hurt unless someone at least
81 //for ( unsigned int i = 0; i < rl. rlim_cur; i++ ) 81 * scrubs the settings area and the PIM apps to make sure that
82 // ::close ( i ); 82 * they are covered regarding perms and users.
83 */
84 if ( ::getuid ( ) != 0 )
85 ::setuid ( 0 );
83 86
84 ::setpgid ( 0, 0 ); 87 ::setpgid ( 0, 0 );
85 ::setsid ( ); 88 ::setsid ( );
@@ -94,7 +97,8 @@ int main ( int argc, char **argv )
94 Config c( "opie-login" ); 97 Config c( "opie-login" );
95 c.setGroup( "autologin" ); 98 c.setGroup( "autologin" );
96 QString entry = c.readEntry( "user", "" ); 99 QString entry = c.readEntry( "user", "" );
97 if ( !entry.isEmpty() ) autolog = ::strdup( (const char*) entry ); 100 if ( !entry.isEmpty() )
101 autolog = ::strdup( (const char*) entry );
98 102
99 while ( true ) { 103 while ( true ) {
100 pid_t child = ::fork ( ); 104 pid_t child = ::fork ( );
@@ -107,7 +111,8 @@ int main ( int argc, char **argv )
107 int status = 0; 111 int status = 0;
108 time_t started = ::time ( 0 ); 112 time_t started = ::time ( 0 );
109 113
110 while ( ::waitpid ( child, &status, 0 ) < 0 ) { } 114 while ( ::waitpid ( child, &status, 0 ) < 0 )
115 ;
111 116
112 LoginApplication::logout ( ); 117 LoginApplication::logout ( );
113 118
@@ -180,13 +185,11 @@ int main ( int argc, char **argv )
180 } 185 }
181 186
182 if ( autolog && !userExited ) { 187 if ( autolog && !userExited ) {
183
184 QWSServer::setDesktopBackground( QImage() ); 188 QWSServer::setDesktopBackground( QImage() );
185 ODevice::inst()->setDisplayStatus( true ); 189 ODevice::inst()->setDisplayStatus( true );
186 LoginApplication *app = new LoginApplication ( argc, argv, ppid ); 190 LoginApplication *app = new LoginApplication ( argc, argv, ppid );
187 LoginApplication::setLoginAs( autolog ); 191 LoginApplication::setLoginAs( autolog );
188 192
189
190 if ( LoginApplication::changeIdentity ( )) 193 if ( LoginApplication::changeIdentity ( ))
191 ::exit ( LoginApplication::login ( )); 194 ::exit ( LoginApplication::login ( ));
192 else 195 else
@@ -245,6 +248,7 @@ public:
245 return true; 248 return true;
246 break; 249 break;
247 case 2: 250 case 2:
251 default:
248 // We're going to suspend the whole machine 252 // We're going to suspend the whole machine
249 if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) { 253 if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) {
250 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 254 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
@@ -255,8 +259,6 @@ public:
255 return false; 259 return false;
256 } 260 }
257 261
258private:
259public:
260 void setIntervals( int i1 = 30, int i2 = 20, int i3 = 60 ) 262 void setIntervals( int i1 = 30, int i2 = 20, int i3 = 60 )
261 { 263 {
262 int v [4]; 264 int v [4];
@@ -289,6 +291,7 @@ public:
289 } 291 }
290 if ( m_backlight_forcedoff && bright != -2 ) 292 if ( m_backlight_forcedoff && bright != -2 )
291 return ; 293 return ;
294
292 if ( bright == -2 ) { 295 if ( bright == -2 ) {
293 // Toggle between off and on 296 // Toggle between off and on
294 bright = m_backlight_bright ? 0 : -1; 297 bright = m_backlight_bright ? 0 : -1;
@@ -305,7 +308,6 @@ public:
305 308
306private: 309private:
307 bool m_lcd_status; 310 bool m_lcd_status;
308
309 int m_backlight_bright; 311 int m_backlight_bright;
310 bool m_backlight_forcedoff; 312 bool m_backlight_forcedoff;
311}; 313};
@@ -320,7 +322,8 @@ int login_main ( int argc, char **argv, pid_t ppid )
320 app-> setStyle ( new QPEStyle ( )); 322 app-> setStyle ( new QPEStyle ( ));
321 323
322 if ( QWSServer::mouseHandler() && 324 if ( QWSServer::mouseHandler() &&
323 QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { 325 QWSServer::mouseHandler()-> inherits("QCalibratedMouseHandler") )
326 {
324 if ( !QFile::exists ( "/etc/pointercal" )) { 327 if ( !QFile::exists ( "/etc/pointercal" )) {
325 // Make sure calibration widget starts on top. 328 // Make sure calibration widget starts on top.
326 Calibrate *cal = new Calibrate; 329 Calibrate *cal = new Calibrate;
@@ -335,10 +338,10 @@ int login_main ( int argc, char **argv, pid_t ppid )
335 QWSServer::setScreenSaver ( saver ); 338 QWSServer::setScreenSaver ( saver );
336 saver-> restore ( ); 339 saver-> restore ( );
337 340
338
339 LoginWindowImpl *lw = new LoginWindowImpl ( ); 341 LoginWindowImpl *lw = new LoginWindowImpl ( );
340 app-> setMainWidget ( lw ); 342 app-> setMainWidget ( lw );
341 lw-> setGeometry ( 0, 0, app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); 343 lw-> setGeometry ( 0, 0, app-> desktop ( )-> width ( ),
344 app-> desktop ( )-> height ( ));
342 lw-> show ( ); 345 lw-> show ( );
343 346
344 int rc = app-> exec ( ); 347 int rc = app-> exec ( );
@@ -346,17 +349,16 @@ int login_main ( int argc, char **argv, pid_t ppid )
346 if ( app-> loginAs ( )) { 349 if ( app-> loginAs ( )) {
347 if ( app-> changeIdentity ( )) { 350 if ( app-> changeIdentity ( )) {
348 app-> login ( ); 351 app-> login ( );
349
350 // if login succeeds, it never comes back 352 // if login succeeds, it never comes back
351 353 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ),
352 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not start Opie." )); 354 LoginWindowImpl::tr( "Could not start Opie." ));
353 rc = 1; 355 rc = 1;
354 } 356 }
355 else { 357 else {
356 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not switch to new user identity" )); 358 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ),
359 LoginWindowImpl::tr( "Could not switch to new user identity" ));
357 rc = 2; 360 rc = 2;
358 } 361 }
359
360 } 362 }
361 return rc; 363 return rc;
362} 364}