summaryrefslogtreecommitdiff
path: root/core/opie-login/main.cpp
authorsandman <sandman>2002-12-17 19:41:05 (UTC)
committer sandman <sandman>2002-12-17 19:41:05 (UTC)
commit0e05c298cc4e5a5d509286e31a3a863e78c76456 (patch) (unidiff)
tree2a86553b593ff9690c14e1796c54c707f189fdf3 /core/opie-login/main.cpp
parent98f90f6ed89986485a1413c4325411e30f4c0693 (diff)
downloadopie-0e05c298cc4e5a5d509286e31a3a863e78c76456.zip
opie-0e05c298cc4e5a5d509286e31a3a863e78c76456.tar.gz
opie-0e05c298cc4e5a5d509286e31a3a863e78c76456.tar.bz2
Opie login becomes useable now:
- pre- and post-session scripts (in $OPIEDIR/share/opie-login) to fix things like device ownership to user/root - logging in now doesn't simply mean: execute bin/qpe. instead opie-login * first tries to execute ~/.opie-session * if that doesn't exist $OPIEDIR/share/opie-login/opie-session * if that fails too, execute $OPIEDIR/bin/qpe you can now handle things like ssh-agent on a per-user basis. (I'll commit the scripts later - for now it simply works like before)
Diffstat (limited to 'core/opie-login/main.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/opie-login/main.cpp12
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
61using namespace Opie; 61using namespace Opie;
62 62
63int login_main ( int argc, char **argv, pid_t ppid ); 63int login_main ( int argc, char **argv, pid_t ppid );
64void sigterm ( int sig ); 64void sigterm ( int sig );
65void sigint ( int sig );
65void exit_closelog ( ); 66void exit_closelog ( );
66 67
67static struct option long_options [] = { 68static 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
73int main ( int argc, char **argv ) 74int 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
311namespace Opie { extern int force_appearance; } // HACK to get around the force-style setting
306 312
307 313
308int login_main ( int argc, char **argv, pid_t ppid ) 314int 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)