summaryrefslogtreecommitdiff
authorsandman <sandman>2002-08-01 14:05:32 (UTC)
committer sandman <sandman>2002-08-01 14:05:32 (UTC)
commit66c4051568427ae3ffd5d8707e1cc91ce8ffbe62 (patch) (side-by-side diff)
treeefeb6b333374349c4e08fbd8c3c16acc727f394b
parent32b7fdb0e9e5ec6cb6f791962efe68c40564b178 (diff)
downloadopie-66c4051568427ae3ffd5d8707e1cc91ce8ffbe62.zip
opie-66c4051568427ae3ffd5d8707e1cc91ce8ffbe62.tar.gz
opie-66c4051568427ae3ffd5d8707e1cc91ce8ffbe62.tar.bz2
Revert the non-gcc3-fix part of the gcc3-fix from Harlekin
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/opie-login/loginwindowimpl.cpp1
-rw-r--r--core/opie-login/opie-login.pro4
2 files changed, 2 insertions, 3 deletions
diff --git a/core/opie-login/loginwindowimpl.cpp b/core/opie-login/loginwindowimpl.cpp
index 26d9225..3265b46 100644
--- a/core/opie-login/loginwindowimpl.cpp
+++ b/core/opie-login/loginwindowimpl.cpp
@@ -1,216 +1,215 @@
#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 <qpe/qcopenvelope_qws.h>
#include <opie/odevice.h>
#include <stdio.h>
#include <pwd.h>
#include <grp.h>
#include <unistd.h>
#include <stdlib.h>
-#undef USEPAM // FOR my toolchain
#ifdef USEPAM
extern "C" {
#include <security/pam_appl.h>
}
#else
#include <crypt.h>
#include <shadow.h>
#endif
#include "loginwindowimpl.h"
#include "inputmethods.h"
LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_Customize | WStyle_NoBorder | WDestructiveClose )
{
QPopupMenu *pop = new QPopupMenu ( this );
pop-> insertItem ( tr( "Restart" ), this, SLOT( restart ( )));
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 ( getAllUsers ( ));
QTimer::singleShot ( 0, this, SLOT( showIM ( )));
QString opiedir = ::getenv ( "OPIEDIR" );
QPixmap bgpix ( opiedir + "/pics/launcher/opie-background.jpg" );
if ( !bgpix. isNull ( ))
setBackgroundPixmap ( bgpix );
m_caption-> setText ( m_caption-> text ( ) + tr( "<center><h1><u>%1 %2</u></h1></center>" ). arg ( ODevice::inst ( )-> systemString ( )). arg ( ODevice::inst ( )-> systemVersionString ( )));
}
LoginWindowImpl::~LoginWindowImpl ( )
{
}
void LoginWindowImpl::keyPressEvent ( QKeyEvent *e )
{
switch ( e-> key ( )) {
case Key_F34: suspend ( );
break;
case Key_F35: backlight ( );
break;
default : e-> ignore ( );
break;
}
LoginWindow::keyPressEvent ( e );
}
void LoginWindowImpl::toggleEchoMode ( bool t )
{
m_password-> setEchoMode ( t ? QLineEdit::Normal : QLineEdit::Password );
}
QStringList LoginWindowImpl::getAllUsers ( )
{
struct passwd *pwd;
QStringList sl;
while (( pwd = getpwent ( ))) {
if (( pwd-> pw_uid == 0 ) || ( pwd-> pw_uid >= 500 && pwd-> pw_uid < 65534 ))
sl << QString ( pwd-> pw_name );
}
endpwent ( );
return sl;
}
void LoginWindowImpl::showIM ( )
{
m_input-> showInputMethod ( );
}
void LoginWindowImpl::restart ( )
{
qApp-> quit ( );
}
void LoginWindowImpl::suspend ( )
{
system ( "apm -s" );
usleep ( 1 * 1000 * 1000 );
{
QCopEnvelope e("QPE/System", "setBacklight(int)");
e << -3; // Force on
}
}
void LoginWindowImpl::backlight ( )
{
{
QCopEnvelope e("QPE/System", "setBacklight(int)");
e << -2; // toggle
}
}
#ifdef USEPAM
static const char *_PAM_SERVICE = "xdm";
static const char *PAM_password;
typedef const struct pam_message pam_message_type;
static int PAM_conv( int, pam_message_type **, struct pam_response **, void * );
static struct pam_conv PAM_conversation = {
&PAM_conv,
NULL
};
//----------------------------------------------------------------------------
static char *COPY_STRING( const char * s ) {
return (s) ? strdup(s) : (char *)NULL;
}
#define GET_MEM if (reply) realloc(reply, size);\
else reply = (struct pam_response *)malloc(size); \
if (!reply) return PAM_CONV_ERR; \
size += sizeof(struct pam_response)
static int PAM_conv( int num_msg, pam_message_type **msg,
struct pam_response **resp, void *)
{
int count = 0, replies = 0;
struct pam_response *reply = NULL;
int size = sizeof(struct pam_response);
for( count = 0; count < num_msg; count++ ) {
switch (msg[count]->msg_style) {
case PAM_PROMPT_ECHO_ON:
/* user name given to PAM already */
return PAM_CONV_ERR;
case PAM_PROMPT_ECHO_OFF:
/* wants password */
GET_MEM;
reply[replies].resp_retcode = PAM_SUCCESS;
reply[replies].resp = COPY_STRING(PAM_password);
replies++;
/* PAM frees resp */
break;
case PAM_TEXT_INFO:
break;
default:
/* unknown or PAM_ERROR_MSG */
if (reply) free (reply);
return PAM_CONV_ERR;
}
}
if (reply) *resp = reply;
return PAM_SUCCESS;
}
static bool pwcheck_PAM( const char *user, const char *password )
{
bool pw_correct = false;
int pam_error;
int pam_return = 0;
pam_handle_t *pamh = 0;
PAM_password = password;
pam_error = pam_start( _PAM_SERVICE, user, &PAM_conversation, &pamh );
if( pam_error == PAM_SUCCESS ) {
pam_error = pam_authenticate( pamh, 0 );
if( pam_error == PAM_SUCCESS ) {
//-- password correct
pw_correct = true;
pam_return = PAM_SUCCESS;
} else {
pam_return = pam_error;
}
} else {
// cerr << "PAM error: " << pam_strerror( pamh, pam_error ) << endl;
}
pam_end( pamh, pam_return );
return pw_correct;
}
#else
diff --git a/core/opie-login/opie-login.pro b/core/opie-login/opie-login.pro
index ef449ab..35c1ed0 100644
--- a/core/opie-login/opie-login.pro
+++ b/core/opie-login/opie-login.pro
@@ -1,25 +1,25 @@
TEMPLATE = app
CONFIG = qt warn_on debug usepam
HEADERS = loginwindowimpl.h \
../launcher/inputmethods.h \
../apps/calibrate/calibrate.h
SOURCES = loginwindowimpl.cpp \
../launcher/inputmethods.cpp \
../apps/calibrate/calibrate.cpp \
main.cpp
INTERFACES = loginwindow.ui
INCLUDEPATH += $(OPIEDIR)/include ../launcher ../apps/calibrate
DEPENDPATH += $(OPIEDIR)/include ../launcher ../apps/calibrate
LIBS += -lqpe -lopie
-#usepam:LIBS += -lpam
-#usepam:DEFINES += USEPAM
+usepam:LIBS += -lpam
+usepam:DEFINES += USEPAM
DESTDIR = $(OPIEDIR)/bin
TARGET = opie-login