summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/opie-login/loginapplication.cpp27
-rw-r--r--core/opie-login/loginapplication.h27
-rw-r--r--core/opie-login/loginwindowimpl.cpp29
-rw-r--r--core/opie-login/loginwindowimpl.h27
-rw-r--r--core/opie-login/main.cpp27
5 files changed, 136 insertions, 1 deletions
diff --git a/core/opie-login/loginapplication.cpp b/core/opie-login/loginapplication.cpp
index cd58c47..103d63b 100644
--- a/core/opie-login/loginapplication.cpp
+++ b/core/opie-login/loginapplication.cpp
@@ -1,48 +1,75 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
+           .>+-=
+ _;:,     .>    :=|. This file is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This file is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
+..}^=.=       =       ; Public License for more details.
+++=   -.     .`     .:
+ :     =  ...= . :.=- You should have received a copy of the GNU
+ -.   .:....=;==+<; General Public License along with this file;
+  -_. . .   )=.  = see the file COPYING. If not, write to the
+    --        :-=` Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
#include <pwd.h>
#include <grp.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#ifdef USEPAM
extern "C" {
#include <security/pam_appl.h>
}
#else
#include <crypt.h>
#include <shadow.h>
#endif
#include "loginapplication.h"
LoginApplication *lApp;
LoginApplication::LoginApplication ( int &argc, char **argv )
: QPEApplication ( argc, argv, GuiServer )
{
lApp = this;
}
const char *LoginApplication::s_username = 0;
#ifdef USEPAM
const char *LoginApplication::s_pam_password = 0;
int LoginApplication::pam_helper ( int num_msg, const struct pam_message **msg, struct pam_response **resp, void * )
{
int replies = 0;
struct pam_response *reply = 0;
int size = sizeof( struct pam_response );
for ( int i = 0; i < num_msg; i++ ) {
switch ( msg [i]-> msg_style ) {
case PAM_PROMPT_ECHO_ON: // user name given to PAM already
return PAM_CONV_ERR;
case PAM_PROMPT_ECHO_OFF: // wants password
reply = (struct pam_response *) ::realloc ( reply, size );
if ( !reply )
return PAM_CONV_ERR;
size += sizeof( struct pam_response );
diff --git a/core/opie-login/loginapplication.h b/core/opie-login/loginapplication.h
index a709c5b..062c088 100644
--- a/core/opie-login/loginapplication.h
+++ b/core/opie-login/loginapplication.h
@@ -1,40 +1,67 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
+           .>+-=
+ _;:,     .>    :=|. This file is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This file is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
+..}^=.=       =       ; Public License for more details.
+++=   -.     .`     .:
+ :     =  ...= . :.=- You should have received a copy of the GNU
+ -.   .:....=;==+<; General Public License along with this file;
+  -_. . .   )=.  = see the file COPYING. If not, write to the
+    --        :-=` Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
#ifndef __OPIE_LOGINAPPLICATION_H__
#define __OPIE_LOGINAPPLICATION_H__
#include <qstringlist.h>
#include <qpe/qpeapplication.h>
#ifdef USEPAM
struct pam_message;
struct pam_response;
#endif
class LoginApplication : public QPEApplication {
public:
LoginApplication ( int &argc, char **argv );
static bool checkPassword ( const char *user, const char *password );
static const char *loginAs ( );
static void setLoginAs ( const char *user );
static bool changeIdentity ( );
static bool login ( );
static QStringList allUsers ( );
void quitToConsole ( );
private:
static const char *s_username;
#ifdef USEPAM
static int pam_helper ( int num_msg, const struct pam_message **msg, struct pam_response **resp, void * );
static const char *s_pam_password;
#endif
};
extern LoginApplication *lApp;
#endif
diff --git a/core/opie-login/loginwindowimpl.cpp b/core/opie-login/loginwindowimpl.cpp
index 3694513..fe2906a 100644
--- a/core/opie-login/loginwindowimpl.cpp
+++ b/core/opie-login/loginwindowimpl.cpp
@@ -1,48 +1,75 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
+           .>+-=
+ _;:,     .>    :=|. This file is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This file is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
+..}^=.=       =       ; Public License for more details.
+++=   -.     .`     .:
+ :     =  ...= . :.=- You should have received a copy of the GNU
+ -.   .:....=;==+<; General Public License along with this file;
+  -_. . .   )=.  = see the file COPYING. If not, write to the
+    --        :-=` Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
#include <qapplication.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qframe.h>
#include <qlineedit.h>
#include <qtimer.h>
#include <qcombobox.h>
#include <qpixmap.h>
#include <qlabel.h>
#include <qpopupmenu.h>
#include <qmessagebox.h>
#include <qimage.h>
#include <qpe/resource.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/config.h>
#include <opie/odevice.h>
#include <stdio.h>
#include <stdlib.h>
#include "loginwindowimpl.h"
#include "loginapplication.h"
#include "inputmethods.h"
using namespace Opie;
LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_Customize | WStyle_NoBorder | WDestructiveClose )
{
QPopupMenu *pop = new QPopupMenu ( this );
pop-> insertItem ( tr( "Restart" ), this, SLOT( restart ( )));
pop-> insertItem ( tr( "Quit" ), this, SLOT( quit ( )));
m_menu-> setPopup ( pop );
QHBoxLayout *lay = new QHBoxLayout ( m_taskbar, 4, 4 );
m_input = new InputMethods ( m_taskbar );
lay-> addWidget ( m_input );
lay-> addStretch ( 10 );
setActiveWindow ( );
m_password-> setFocus ( );
m_user-> insertStringList ( lApp-> allUsers ( ));
QTimer::singleShot ( 0, this, SLOT( showIM ( )));
@@ -80,97 +107,97 @@ void LoginWindowImpl::keyPressEvent ( QKeyEvent *e )
}
void LoginWindowImpl::toggleEchoMode ( bool t )
{
m_password-> setEchoMode ( t ? QLineEdit::Normal : QLineEdit::Password );
}
void LoginWindowImpl::showIM ( )
{
m_input-> showInputMethod ( );
}
void LoginWindowImpl::restart ( )
{
qApp-> quit ( );
}
void LoginWindowImpl::quit ( )
{
lApp-> quitToConsole ( );
}
void LoginWindowImpl::suspend ( )
{
ODevice::inst ( )-> suspend ( );
QCopEnvelope e("QPE/System", "setBacklight(int)");
e << -3; // Force on
}
void LoginWindowImpl::backlight ( )
{
QCopEnvelope e("QPE/System", "setBacklight(int)");
e << -2; // toggle
}
class WaitLogo : public QLabel {
public:
WaitLogo ( ) : QLabel ( 0, "wait hack!", WStyle_Customize | WStyle_NoBorder | WStyle_Tool )
{
QImage img = Resource::loadImage ( "launcher/new_wait" );
QPixmap pix;
pix. convertFromImage ( img );
setPixmap ( pix );
setAlignment ( AlignCenter );
move ( 0, 0 );
resize ( qApp-> desktop ( )-> width ( ), qApp-> desktop ( )-> height ( ));
-
+
m_visible = false;
show ( );
}
virtual void showEvent ( QShowEvent *e )
{
QLabel::showEvent ( e );
m_visible = true;
}
virtual void paintEvent ( QPaintEvent *e )
{
QLabel::paintEvent ( e );
if ( m_visible )
qApp-> quit ( );
}
private:
bool m_visible;
};
void LoginWindowImpl::login ( )
{
const char *user = ::strdup ( m_user-> currentText ( ). local8Bit ( ));
const char *pass = ::strdup ( m_password-> text ( ). local8Bit ( ));
if ( !user || !user [0] )
return;
if ( !pass )
pass = "";
if ( lApp-> checkPassword ( user, pass )) {
Config cfg ( "opie-login" );
cfg. setGroup ( "General" );
cfg. writeEntry ( "LastLogin", user );
cfg. write ( );
lApp-> setLoginAs ( user );
// Draw a big wait icon, the image can be altered in later revisions
m_input-> hideInputMethod ( );
new WaitLogo ( );
// WaitLogo::showEvent() calls qApp-> quit()
}
else {
QMessageBox::warning ( this, tr( "Wrong password" ), tr( "The given password is incorrect." ));
m_password-> clear ( );
}
diff --git a/core/opie-login/loginwindowimpl.h b/core/opie-login/loginwindowimpl.h
index 2e2ba0d..e769b03 100644
--- a/core/opie-login/loginwindowimpl.h
+++ b/core/opie-login/loginwindowimpl.h
@@ -1,34 +1,61 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
+           .>+-=
+ _;:,     .>    :=|. This file is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This file is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
+..}^=.=       =       ; Public License for more details.
+++=   -.     .`     .:
+ :     =  ...= . :.=- You should have received a copy of the GNU
+ -.   .:....=;==+<; General Public License along with this file;
+  -_. . .   )=.  = see the file COPYING. If not, write to the
+    --        :-=` Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
#ifndef __OPIE_LOGINWINDOW_IMPL_H__
#define __OPIE_LOGINWINDOW_IMPL_H__
#include "loginwindow.h"
class InputMethods;
class LoginWindowImpl : public LoginWindow {
Q_OBJECT
public:
LoginWindowImpl ( );
virtual ~LoginWindowImpl ( );
protected slots:
void restart ( );
void quit ( );
void showIM ( );
void suspend ( );
void backlight ( );
void login ( );
void toggleEchoMode ( bool );
protected:
virtual void keyPressEvent ( QKeyEvent *e );
QStringList getAllUsers ( );
bool changeIdentity ( const char *user );
private:
InputMethods *m_input;
};
#endif
diff --git a/core/opie-login/main.cpp b/core/opie-login/main.cpp
index 91610af..2c10f77 100644
--- a/core/opie-login/main.cpp
+++ b/core/opie-login/main.cpp
@@ -1,48 +1,75 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
+           .>+-=
+ _;:,     .>    :=|. This file is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This file is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
+..}^=.=       =       ; Public License for more details.
+++=   -.     .`     .:
+ :     =  ...= . :.=- You should have received a copy of the GNU
+ -.   .:....=;==+<; General Public License along with this file;
+  -_. . .   )=.  = see the file COPYING. If not, write to the
+    --        :-=` Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
#define _GNU_SOURCE
#include <sys/types.h>
#include <time.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
#include <syslog.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <getopt.h>
#include <string.h>
#include <qpe/qpeapplication.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpestyle.h>
#include <qpe/power.h>
#include <opie/odevice.h>
#include <qwindowsystem_qws.h>
#include <qmessagebox.h>
#include <qlabel.h>
#include <qtimer.h>
#include "loginapplication.h"
#include "loginwindowimpl.h"
#include "calibrate.h"
using namespace Opie;
int login_main ( int argc, char **argv );
void sigterm ( int sig );
void exit_closelog ( );
static struct option long_options [] = {
{ "autologin", 1, 0, 'a' },
{ 0, 0, 0, 0 }
};
int main ( int argc, char **argv )
{
if ( ::geteuid ( ) != 0 ) {
::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] );
return 1;