summaryrefslogtreecommitdiff
path: root/core/opie-login
Unidiff
Diffstat (limited to 'core/opie-login') (more/less context) (ignore whitespace changes)
-rw-r--r--core/opie-login/main.cpp30
-rw-r--r--core/opie-login/opie-login.conffiles1
2 files changed, 24 insertions, 7 deletions
diff --git a/core/opie-login/main.cpp b/core/opie-login/main.cpp
index d95a59b..7dcb5f6 100644
--- a/core/opie-login/main.cpp
+++ b/core/opie-login/main.cpp
@@ -49,16 +49,17 @@
49#include <opie/odevice.h> 49#include <opie/odevice.h>
50 50
51#include <qwindowsystem_qws.h> 51#include <qwindowsystem_qws.h>
52#include <qwsmouse_qws.h> 52#include <qwsmouse_qws.h>
53#include <qmessagebox.h> 53#include <qmessagebox.h>
54#include <qlabel.h> 54#include <qlabel.h>
55#include <qtimer.h> 55#include <qtimer.h>
56#include <qfile.h> 56#include <qfile.h>
57#include <qtextstream.h>
57 58
58#include "loginapplication.h" 59#include "loginapplication.h"
59#include "loginwindowimpl.h" 60#include "loginwindowimpl.h"
60#include "calibrate.h" 61#include "calibrate.h"
61 62
62using namespace Opie; 63using namespace Opie;
63 64
64int login_main ( int argc, char **argv, pid_t ppid ); 65int login_main ( int argc, char **argv, pid_t ppid );
@@ -69,16 +70,17 @@ void exit_closelog ( );
69static struct option long_options [] = { 70static struct option long_options [] = {
70 { "autologin", 1, 0, 'a' }, 71 { "autologin", 1, 0, 'a' },
71 { 0, 0, 0, 0 } 72 { 0, 0, 0, 0 }
72}; 73};
73 74
74 75
75int main ( int argc, char **argv ) 76int main ( int argc, char **argv )
76{ 77{
78 int userExited = 0;
77 pid_t ppid = ::getpid ( ); 79 pid_t ppid = ::getpid ( );
78 80
79 if ( ::geteuid ( ) != 0 ) { 81 if ( ::geteuid ( ) != 0 ) {
80 ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] ); 82 ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] );
81 return 1; 83 return 1;
82 } 84 }
83 if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and 85 if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and
84 ::setuid ( 0 ); // messes up things like config files 86 ::setuid ( 0 ); // messes up things like config files
@@ -132,21 +134,27 @@ int main ( int argc, char **argv )
132 autolog = 0; 134 autolog = 0;
133 } 135 }
134 else { 136 else {
135 ::syslog ( LOG_ERR, "Respawning too fast -- going down\n" ); 137 ::syslog ( LOG_ERR, "Respawning too fast -- going down\n" );
136 break; 138 break;
137 } 139 }
138 } 140 }
139 int killedbysig = 0; 141 int killedbysig = 0;
142 userExited=0;
143 if (WIFEXITED(status)!=0 ) {
144 if (WEXITSTATUS(status)==137) {
145 userExited=1;
146 }
147 }
140 148
141 if ( WIFSIGNALED( status )) { 149 if ( WIFSIGNALED( status )) {
142 switch ( WTERMSIG( status )) { 150 switch ( WTERMSIG( status )) {
143 case SIGINT :
144 case SIGTERM: 151 case SIGTERM:
152 case SIGINT :
145 case SIGKILL: 153 case SIGKILL:
146 break; 154 break;
147 155
148 default : 156 default :
149 killedbysig = WTERMSIG( status ); 157 killedbysig = WTERMSIG( status );
150 break; 158 break;
151 } 159 }
152 } 160 }
@@ -157,47 +165,55 @@ int main ( int argc, char **argv )
157 165
158 QWSServer::setDesktopBackground ( QImage ( )); 166 QWSServer::setDesktopBackground ( QImage ( ));
159 QApplication *app = new QApplication ( argc, argv, QApplication::GuiServer ); 167 QApplication *app = new QApplication ( argc, argv, QApplication::GuiServer );
160 app-> setFont ( QFont ( "Helvetica", 10 )); 168 app-> setFont ( QFont ( "Helvetica", 10 ));
161 app-> setStyle ( new QPEStyle ( )); 169 app-> setStyle ( new QPEStyle ( ));
162 170
163 const char *sig = ::strsignal ( killedbysig ); 171 const char *sig = ::strsignal ( killedbysig );
164 QLabel *l = new QLabel ( 0, "sig", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool ); 172 QLabel *l = new QLabel ( 0, "sig", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool );
165 l-> setText ( LoginWindowImpl::tr( "OPIE was terminated\nby an uncaught signal\n(%1)\n" ). arg ( sig )); 173 l-> setText ( LoginWindowImpl::tr( "Opie was terminated\nby an uncaught signal\n(%1)\n" ). arg ( sig ));
166 l-> setAlignment ( Qt::AlignCenter ); 174 l-> setAlignment ( Qt::AlignCenter );
167 l-> move ( 0, 0 ); 175 l-> move ( 0, 0 );
168 l-> resize ( app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); 176 l-> resize ( app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( ));
169 l-> show ( ); 177 l-> show ( );
170 QTimer::singleShot ( 3000, app, SLOT( quit ( ))); 178 QTimer::singleShot ( 3000, app, SLOT( quit ( )));
171 app-> exec ( ); 179 app-> exec ( );
172 delete app; 180 delete app;
173 qApp = 0; 181 qApp = 0;
174 } 182 }
175 } 183 }
176 else { 184 else {
177 if ( !autolog ) { 185 if ( !autolog ) {
178 Config cfg ( "opie-login" ); 186 QString confFile=QPEApplication::qpeDir() + "/etc/opie-login.conf";
187 Config cfg ( confFile, Config::File );
179 cfg. setGroup ( "General" ); 188 cfg. setGroup ( "General" );
180 QString user = cfg. readEntry ( "AutoLogin" ); 189 QString user = cfg. readEntry ( "AutoLogin" );
181 190
182 if ( !user. isEmpty ( )) 191 if ( !user. isEmpty ( ))
183 autolog = ::strdup ( user. latin1 ( )); 192 autolog = ::strdup ( user. latin1 ( ));
184 } 193 }
185 194
186 if ( autolog ) { 195 if ( autolog && !userExited ) {
187 LoginApplication::setLoginAs ( autolog ); 196
197 QWSServer::setDesktopBackground( QImage() );
198 ODevice::inst ( )-> setDisplayStatus ( true );
199 ODevice::inst ( )-> setSoftSuspend ( false );
200 LoginApplication *app = new LoginApplication ( argc, argv, ppid );
201 LoginApplication::setLoginAs ( autolog );
202
188 203
189 if ( LoginApplication::changeIdentity ( )) 204 if ( LoginApplication::changeIdentity ( ))
190 ::exit ( LoginApplication::login ( )); 205 ::exit ( LoginApplication::login ( ));
191 else 206 else
192 ::exit ( 0 ); 207 ::exit ( 0 );
193 } 208 }
194 else 209 else {
195 ::exit ( login_main ( argc, argv, ppid )); 210 ::exit ( login_main ( argc, argv, ppid ));
211 }
196 } 212 }
197 } 213 }
198 return 0; 214 return 0;
199} 215}
200 216
201void sigterm ( int /*sig*/ ) 217void sigterm ( int /*sig*/ )
202{ 218{
203 ::exit ( 0 ); 219 ::exit ( 0 );
@@ -350,17 +366,17 @@ int login_main ( int argc, char **argv, pid_t ppid )
350 ODevice::inst ( )-> setSoftSuspend ( false ); 366 ODevice::inst ( )-> setSoftSuspend ( false );
351 367
352 if ( app-> loginAs ( )) { 368 if ( app-> loginAs ( )) {
353 if ( app-> changeIdentity ( )) { 369 if ( app-> changeIdentity ( )) {
354 app-> login ( ); 370 app-> login ( );
355 371
356 // if login succeeds, it never comes back 372 // if login succeeds, it never comes back
357 373
358 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not start OPIE." )); 374 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not start Opie." ));
359 rc = 1; 375 rc = 1;
360 } 376 }
361 else { 377 else {
362 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not switch to new user identity" )); 378 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not switch to new user identity" ));
363 rc = 2; 379 rc = 2;
364 } 380 }
365 381
366 } 382 }
diff --git a/core/opie-login/opie-login.conffiles b/core/opie-login/opie-login.conffiles
new file mode 100644
index 0000000..90645ee
--- a/dev/null
+++ b/core/opie-login/opie-login.conffiles
@@ -0,0 +1 @@
/opt/QtPalmtop/etc/opie-login.conf