Stabilize cryptographic card login

Fix some coding style issues
pull/2/head
Timothy Pearson 10 years ago
parent 46d9df235b
commit 9ea6780352

@ -43,6 +43,7 @@
#include <tqlistview.h> #include <tqlistview.h>
#include <tqheader.h> #include <tqheader.h>
#include <tqcheckbox.h> #include <tqcheckbox.h>
#include <tqfile.h>
#include <ctype.h> #include <ctype.h>
#include <unistd.h> #include <unistd.h>
@ -79,7 +80,9 @@ PasswordDlg::PasswordDlg(LockProcess *parent, GreeterPluginHandle *plugin)
: TQDialog(parent, "password dialog", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM))), : TQDialog(parent, "password dialog", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM))),
mPlugin( plugin ), mPlugin( plugin ),
mCapsLocked(-1), mCapsLocked(-1),
mUnlockingFailed(false) mUnlockingFailed(false),
validUserCardInserted(false),
showInfoMessages(true)
{ {
init(plugin); init(plugin);
} }
@ -92,7 +95,8 @@ PasswordDlg::PasswordDlg(LockProcess *parent, GreeterPluginHandle *plugin, TQDat
: TQDialog(parent, "password dialog", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM))), : TQDialog(parent, "password dialog", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM))),
mPlugin( plugin ), mPlugin( plugin ),
mCapsLocked(-1), mCapsLocked(-1),
mUnlockingFailed(false) mUnlockingFailed(false),
showInfoMessages(true)
{ {
m_lockStartDT = lockStartDateTime; m_lockStartDT = lockStartDateTime;
init(plugin); init(plugin);
@ -243,6 +247,7 @@ void PasswordDlg::init(GreeterPluginHandle *plugin)
mTimeoutTimerId = startTimer(PASSDLG_HIDE_TIMEOUT); mTimeoutTimerId = startTimer(PASSDLG_HIDE_TIMEOUT);
connect(tqApp, TQT_SIGNAL(activity()), TQT_SLOT(slotActivity()) ); connect(tqApp, TQT_SIGNAL(activity()), TQT_SLOT(slotActivity()) );
greet->setInfoMessageDisplay(showInfoMessages);
greet->start(); greet->start();
DCOPRef kxkb("kxkb", "kxkb"); DCOPRef kxkb("kxkb", "kxkb");
@ -463,9 +468,27 @@ void PasswordDlg::reapVerify()
if (WIFEXITED(status)) { if (WIFEXITED(status)) {
switch (WEXITSTATUS(status)) { switch (WEXITSTATUS(status)) {
case AuthOk: case AuthOk:
greet->succeeded(); {
accept(); KUser userinfo;
return; TQString fileName = userinfo.homeDir() + "/.tde_card_login_state";
TQFile flagFile(fileName);
if (validUserCardInserted) {
// Card was likely used to log in
if (flagFile.open(IO_WriteOnly)) {
flagFile.writeBlock("1\n", 2);
flagFile.close();
}
}
else {
// Card was not used to log in
flagFile.remove();
}
// Signal success
greet->succeeded();
accept();
return;
}
case AuthBad: case AuthBad:
greet->failed(); greet->failed();
mUnlockingFailed = true; mUnlockingFailed = true;
@ -926,13 +949,22 @@ void PasswordDlg::capsLocked()
} }
void PasswordDlg::attemptCardLogin() { void PasswordDlg::attemptCardLogin() {
// FIXME
// pam_pkcs11 is extremely chatty with no apparent way to disable the unwanted messages
greet->setInfoMessageDisplay(false);
validUserCardInserted = true;
greet->start(); greet->start();
greet->next(); greet->next();
} }
void PasswordDlg::resetCardLogin() { void PasswordDlg::resetCardLogin() {
validUserCardInserted = false;
greet->abort(); greet->abort();
greet->start(); greet->start();
// Restore information message display settings
greet->setInfoMessageDisplay(showInfoMessages);
} }
#include "lockdlg.moc" #include "lockdlg.moc"

@ -94,6 +94,8 @@ class PasswordDlg : public TQDialog, public KGreeterPluginHandler
int mTimeoutTimerId; int mTimeoutTimerId;
int mCapsLocked; int mCapsLocked;
bool mUnlockingFailed; bool mUnlockingFailed;
bool validUserCardInserted;
bool showInfoMessages;
TQStringList layoutsList; TQStringList layoutsList;
TQStringList::iterator currLayout; TQStringList::iterator currLayout;
int sPid, sFd; int sPid, sFd;

@ -176,6 +176,19 @@ SaverEngine::SaverEngine()
cdevice->enableCardMonitoring(true); cdevice->enableCardMonitoring(true);
} }
// Check card login status
KUser userinfo;
TQString fileName = userinfo.homeDir() + "/.tde_card_login_state";
TQFile flagFile(fileName);
if (flagFile.open(IO_ReadOnly)) {
TQTextStream stream(&flagFile);
if (stream.readLine().startsWith("1")) {
// Card was likely used to log in
TQTimer::singleShot(5000, this, SLOT(cardStartupTimeout()));
}
flagFile.close();
}
dBusConnect(); dBusConnect();
} }
@ -204,6 +217,16 @@ SaverEngine::~SaverEngine()
delete m_helperThread; delete m_helperThread;
} }
void SaverEngine::cardStartupTimeout() {
if (!mValidCryptoCardInserted) {
// Restore saver timeout
configure();
// Force lock
lockScreen();
}
}
void SaverEngine::cryptographicCardInserted(TDECryptographicCardDevice* cdevice) { void SaverEngine::cryptographicCardInserted(TDECryptographicCardDevice* cdevice) {
TQString login_name = TQString::null; TQString login_name = TQString::null;
X509CertificatePtrList certList = cdevice->cardX509Certificates(); X509CertificatePtrList certList = cdevice->cardX509Certificates();
@ -224,7 +247,7 @@ void SaverEngine::cryptographicCardInserted(TDECryptographicCardDevice* cdevice)
KUser user; KUser user;
if (login_name == user.loginName()) { if (login_name == user.loginName()) {
mValidCryptoCardInserted = true; mValidCryptoCardInserted = true;
// Disable saver // Disable saver startup
enable(false); enable(false);
} }
} }

@ -143,6 +143,7 @@ private slots:
*/ */
void enableExports(); void enableExports();
void recoverFromHackingAttempt(); void recoverFromHackingAttempt();
void cardStartupTimeout();
bool dBusReconnect(); bool dBusReconnect();

@ -64,12 +64,12 @@ AnyRunningDisplays( void )
for (d = displays; d; d = d->next) for (d = displays; d; d = d->next)
switch (d->status) { switch (d->status) {
case notRunning: case notRunning:
case textMode: case textMode:
case reserve: case reserve:
break; break;
default: default:
return 1; return 1;
} }
return 0; return 0;
} }
@ -79,9 +79,11 @@ AnyReserveDisplays( void )
{ {
struct display *d; struct display *d;
for (d = displays; d; d = d->next) for (d = displays; d; d = d->next) {
if ((d->displayType & d_lifetime) == dReserve) if ((d->displayType & d_lifetime) == dReserve) {
return 1; return 1;
}
}
return 0; return 0;
} }
@ -91,9 +93,11 @@ idleReserveDisplays( void )
struct display *d; struct display *d;
int cnt = 0; int cnt = 0;
for (d = displays; d; d = d->next) for (d = displays; d; d = d->next) {
if (d->status == reserve) if (d->status == reserve) {
cnt++; cnt++;
}
}
return cnt; return cnt;
} }
@ -102,9 +106,11 @@ StartReserveDisplay( int lt )
{ {
struct display *d, *rd; struct display *d, *rd;
for (rd = 0, d = displays; d; d = d->next) for (rd = 0, d = displays; d; d = d->next) {
if (d->status == reserve) if (d->status == reserve) {
rd = d; rd = d;
}
}
if (rd) { if (rd) {
rd->idleTimeout = lt; rd->idleTimeout = lt;
rd->status = notRunning; rd->status = notRunning;
@ -129,8 +135,9 @@ static void
_forEachDisplayRev( struct display *d, void (*f)( struct display * ) ) _forEachDisplayRev( struct display *d, void (*f)( struct display * ) )
{ {
if (d) { if (d) {
if (d->next) if (d->next) {
_forEachDisplayRev( d->next, f ); _forEachDisplayRev(d->next, f);
}
(*f)( d ); (*f)( d );
} }
} }
@ -147,9 +154,11 @@ FindDisplayByName( const char *name )
{ {
struct display *d; struct display *d;
for (d = displays; d; d = d->next) for (d = displays; d; d = d->next) {
if (!strcmp( name, d->name )) if (!strcmp( name, d->name )) {
return d; return d;
}
}
return 0; return 0;
} }
@ -158,9 +167,11 @@ FindDisplayByPid( int pid )
{ {
struct display *d; struct display *d;
for (d = displays; d; d = d->next) for (d = displays; d; d = d->next) {
if (pid == d->pid) if (pid == d->pid) {
return d; return d;
}
}
return 0; return 0;
} }
@ -169,9 +180,11 @@ FindDisplayByServerPid( int serverPid )
{ {
struct display *d; struct display *d;
for (d = displays; d; d = d->next) for (d = displays; d; d = d->next) {
if (serverPid == d->serverPid) if (serverPid == d->serverPid) {
return d; return d;
}
}
return 0; return 0;
} }
@ -182,9 +195,11 @@ FindDisplayBySessionID( CARD32 sessionID )
{ {
struct display *d; struct display *d;
for (d = displays; d; d = d->next) for (d = displays; d; d = d->next) {
if (sessionID == d->sessionID) if (sessionID == d->sessionID) {
return d; return d;
}
}
return 0; return 0;
} }
@ -193,12 +208,14 @@ FindDisplayByAddress( XdmcpNetaddr addr, int addrlen, CARD16 displayNumber )
{ {
struct display *d; struct display *d;
for (d = displays; d; d = d->next) for (d = displays; d; d = d->next) {
if ((d->displayType & d_origin) == dFromXDMCP && if ((d->displayType & d_origin) == dFromXDMCP &&
d->displayNumber == displayNumber && d->displayNumber == displayNumber &&
addressEqual( (XdmcpNetaddr)d->from.data, d->from.length, addressEqual( (XdmcpNetaddr)d->from.data, d->from.length,
addr, addrlen )) addr, addrlen )) {
return d; return d;
}
}
return 0; return 0;
} }
@ -207,37 +224,38 @@ FindDisplayByAddress( XdmcpNetaddr addr, int addrlen, CARD16 displayNumber )
#define IfFree(x) if (x) free( (char *)x ) #define IfFree(x) if (x) free( (char *)x )
void void
RemoveDisplay( struct display *old ) RemoveDisplay(struct display *old)
{ {
struct display *d, **dp; struct display *d, **dp;
int i; int i;
for (dp = &displays; (d = *dp); dp = &(*dp)->next) { for (dp = &displays; (d = *dp); dp = &(*dp)->next) {
if (d == old) { if (d == old) {
Debug( "Removing display %s\n", d->name ); Debug("Removing display %s\n", d->name);
*dp = d->next; *dp = d->next;
IfFree( d->class2 ); IfFree(d->class2);
IfFree( d->cfg.data ); IfFree(d->cfg.data);
delStr( d->cfg.dep.name ); delStr(d->cfg.dep.name);
#ifdef XDMCP #ifdef XDMCP
IfFree( d->remoteHost ); IfFree(d->remoteHost);
#endif #endif
if (d->authorizations) { if (d->authorizations) {
for (i = 0; i < d->authNum; i++) for (i = 0; i < d->authNum; i++) {
XauDisposeAuth( d->authorizations[i] ); XauDisposeAuth(d->authorizations[i]);
free( (char *)d->authorizations ); }
free((char *)d->authorizations);
} }
if (d->authFile) { if (d->authFile) {
(void)unlink( d->authFile ); (void)unlink(d->authFile);
free( d->authFile ); free(d->authFile);
} }
IfFree( d->authNameLens ); IfFree(d->authNameLens);
#ifdef XDMCP #ifdef XDMCP
XdmcpDisposeARRAY8( &d->peer ); XdmcpDisposeARRAY8(&d->peer);
XdmcpDisposeARRAY8( &d->from ); XdmcpDisposeARRAY8(&d->from);
XdmcpDisposeARRAY8( &d->clientAddr ); XdmcpDisposeARRAY8(&d->clientAddr);
#endif #endif
free( (char *)d ); free((char *)d);
break; break;
} }
} }
@ -270,8 +288,9 @@ NewDisplay( const char *name )
hstent->next = disphist; disphist = hstent; hstent->next = disphist; disphist = hstent;
} }
if (!(d = (struct display *)Calloc( 1, sizeof(*d) ))) if (!(d = (struct display *)Calloc( 1, sizeof(*d) ))) {
return 0; return 0;
}
d->next = displays; d->next = displays;
d->hstent = hstent; d->hstent = hstent;
d->name = hstent->name; d->name = hstent->name;
@ -289,6 +308,6 @@ NewDisplay( const char *name )
d->xdmcpFd = -1; d->xdmcpFd = -1;
#endif #endif
displays = d; displays = d;
Debug( "created new display %s\n", d->name ); Debug("created new display %s\n", d->name);
return d; return d;
} }

@ -178,28 +178,28 @@ StartServerTimeout()
{ {
struct display *d = startingServer; struct display *d = startingServer;
switch (d->serverStatus) { switch (d->serverStatus) {
case ignore: case ignore:
case awaiting: case awaiting:
break; /* cannot happen */ break; /* cannot happen */
case starting: case starting:
LogError( "X server startup timeout, terminating\n" ); LogError( "X server startup timeout, terminating\n" );
kill( d->serverPid, d->termSignal ); kill( d->serverPid, d->termSignal );
d->serverStatus = d->termSignal == SIGKILL ? killed : terminated; d->serverStatus = d->termSignal == SIGKILL ? killed : terminated;
serverTimeout = d->serverTimeout + now; serverTimeout = d->serverTimeout + now;
break; break;
case terminated: case terminated:
LogInfo( "X server termination timeout, killing\n" ); LogInfo( "X server termination timeout, killing\n" );
kill( d->serverPid, SIGKILL ); kill( d->serverPid, SIGKILL );
d->serverStatus = killed; d->serverStatus = killed;
serverTimeout = 10 + now; serverTimeout = 10 + now;
break; break;
case killed: case killed:
LogInfo( "X server is stuck in D state; leaving it alone\n" ); LogInfo( "X server is stuck in D state; leaving it alone\n" );
StartServerFailed(); StartServerFailed();
break; break;
case pausing: case pausing:
StartServerOnce(); StartServerOnce();
break; break;
} }
} }

@ -565,18 +565,22 @@ ListSessions( int flags, struct display *d, void *ctx,
STRUCTUTMP *ut; STRUCTUTMP *ut;
#endif #endif
for (di = displays; di; di = di->next) for (di = displays; di; di = di->next) {
if (((flags & lstRemote) || (di->displayType & d_location) == dLocal) && if (((flags & lstRemote) || (di->displayType & d_location) == dLocal) &&
(di->status == remoteLogin || (di->status == remoteLogin ||
((flags & lstPassive) ? di->status == running : di->userSess >= 0))) ((flags & lstPassive) ? di->status == running : di->userSess >= 0))) {
emitXSess( di, d, ctx ); emitXSess(di, d, ctx);
}
}
if (!(flags & lstTTY)) if (!(flags & lstTTY)) {
return; return;
}
#ifdef BSD_UTMP #ifdef BSD_UTMP
if ((fd = open( UTMP_FILE, O_RDONLY )) < 0) if ((fd = open( UTMP_FILE, O_RDONLY )) < 0) {
return; return;
}
while (Reader( fd, ut, sizeof(ut[0]) ) == sizeof(ut[0])) { while (Reader( fd, ut, sizeof(ut[0]) ) == sizeof(ut[0])) {
if (*ut->ut_user) { /* no idea how to list passive TTYs on BSD */ if (*ut->ut_user) { /* no idea how to list passive TTYs on BSD */
#else #else
@ -590,40 +594,43 @@ ListSessions( int flags, struct display *d, void *ctx,
{ {
#endif #endif
if (*ut->ut_host) { /* from remote or x */ if (*ut->ut_host) { /* from remote or x */
if (!(flags & lstRemote)) if (!(flags & lstRemote)) {
continue; continue;
} else { }
}
else {
/* hack around broken konsole which does not set ut_host. */ /* hack around broken konsole which does not set ut_host. */
/* this check is probably linux-specific. */ /* this check is probably linux-specific. */
/* alternatively we could open the device and try VT_OPENQRY. */ /* alternatively we could open the device and try VT_OPENQRY. */
if (memcmp( ut->ut_line, "tty", 3 ) || if (memcmp( ut->ut_line, "tty", 3 ) || !isdigit( ut->ut_line[3] )) {
!isdigit( ut->ut_line[3] ))
continue; continue;
}
} }
if (StrNChrCnt( ut->ut_line, sizeof(ut->ut_line), ':' )) if (StrNChrCnt( ut->ut_line, sizeof(ut->ut_line), ':' )) {
continue; /* x login */ continue; /* x login */
}
switch (StrNChrCnt( ut->ut_host, sizeof(ut->ut_host), ':' )) { switch (StrNChrCnt( ut->ut_host, sizeof(ut->ut_host), ':' )) {
case 1: /* x terminal */ case 1: /* x terminal */
continue; continue;
default: default:
#ifdef IP6_MAGIC #ifdef IP6_MAGIC
/* unknown - IPv6 makes things complicated */ /* unknown - IPv6 makes things complicated */
le = StrNLen( ut->ut_host, sizeof(ut->ut_host) ); le = StrNLen( ut->ut_host, sizeof(ut->ut_host) );
/* cut off screen number */ /* cut off screen number */
for (dot = le; ut->ut_host[--dot] != ':'; ) for (dot = le; ut->ut_host[--dot] != ':'; )
if (ut->ut_host[dot] == '.') { if (ut->ut_host[dot] == '.') {
le = dot; le = dot;
break; break;
} }
for (di = displays; di; di = di->next) for (di = displays; di; di = di->next)
if (!memcmp( di->name, ut->ut_host, le ) && !di->name[le]) if (!memcmp( di->name, ut->ut_host, le ) && !di->name[le])
goto cont; /* x terminal */ goto cont; /* x terminal */
break; break;
cont: cont:
continue; continue;
case 0: /* no x terminal */ case 0: /* no x terminal */
#endif #endif
break; break;
} }
emitTTYSess( ut, d, ctx ); emitTTYSess( ut, d, ctx );
} }

@ -34,6 +34,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#endif #endif
#include "sakdlg.h" #include "sakdlg.h"
#include <kuser.h>
#include <kprocess.h> #include <kprocess.h>
#include <tdecmdlineargs.h> #include <tdecmdlineargs.h>
#include <kcrash.h> #include <kcrash.h>
@ -342,6 +343,7 @@ kg_main( const char *argv0 )
XSetIOErrorHandler( xIOErr ); XSetIOErrorHandler( xIOErr );
TQString login_user; TQString login_user;
TQString login_card_user;
TQString login_session_wm; TQString login_session_wm;
Display *dpy = tqt_xdisplay(); Display *dpy = tqt_xdisplay();
@ -499,6 +501,7 @@ kg_main( const char *argv0 )
Debug( "left event loop\n" ); Debug( "left event loop\n" );
login_user = static_cast<KGreeter*>(dialog)->curUser; login_user = static_cast<KGreeter*>(dialog)->curUser;
login_card_user = static_cast<KGreeter*>(dialog)->cardLoginUser;
login_session_wm = static_cast<KGreeter*>(dialog)->curWMSession; login_session_wm = static_cast<KGreeter*>(dialog)->curWMSession;
if (rslt != ex_greet) { if (rslt != ex_greet) {
@ -522,6 +525,24 @@ kg_main( const char *argv0 )
KGVerify::done(); KGVerify::done();
KUser userinfo(login_user);
if (userinfo.isValid()) {
TQString fileName = userinfo.homeDir() + "/.tde_card_login_state";
TQFile flagFile(fileName);
if ((login_card_user != TQString::null) && (login_user == login_card_user)) {
// Card was likely used to log in
if (flagFile.open(IO_WriteOnly)) {
flagFile.writeBlock("1\n", 2);
fchown(flagFile.handle(), userinfo.uid(), userinfo.gid());
flagFile.close();
}
}
else {
// Card was not used to log in
flagFile.remove();
}
}
if (kbdl) { if (kbdl) {
kbdl->closeStdin(); kbdl->closeStdin();
kbdl->detach(); kbdl->detach();

@ -192,6 +192,7 @@ KGreeter::KGreeter( bool framed )
, prevValid( true ) , prevValid( true )
, needLoad( false ) , needLoad( false )
, themed( framed ) , themed( framed )
, showInfoMessages( true )
, closingDown( false ) , closingDown( false )
{ {
stsFile = new KSimpleConfig( _stsFile ); stsFile = new KSimpleConfig( _stsFile );
@ -242,6 +243,8 @@ KGreeter::~KGreeter()
} }
void KGreeter::cryptographicCardWatcherSetup() { void KGreeter::cryptographicCardWatcherSetup() {
cardLoginUser = TQString::null;
// Initialize SmartCard readers // Initialize SmartCard readers
TDEGenericDevice *hwdevice; TDEGenericDevice *hwdevice;
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices(); TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
@ -892,15 +895,24 @@ void KGreeter::cryptographicCardInserted(TDECryptographicCardDevice* cdevice) {
verifySetUser(login_name); verifySetUser(login_name);
verify->lockUserEntry(true); verify->lockUserEntry(true);
// FIXME
// pam_pkcs11 is extremely chatty with no apparent way to disable the unwanted messages
verify->setInfoMessageDisplay(false);
// Initiate login // Initiate login
cardLoginUser = login_name;
verify->accept(); verify->accept();
} }
} }
} }
void KGreeter::cryptographicCardRemoved(TDECryptographicCardDevice* cdevice) { void KGreeter::cryptographicCardRemoved(TDECryptographicCardDevice* cdevice) {
cardLoginUser = TQString::null;
verify->lockUserEntry(false); verify->lockUserEntry(false);
verify->requestAbort(); verify->requestAbort();
// Restore information message display settings
verify->setInfoMessageDisplay(showInfoMessages);
} }
KStdGreeter::KStdGreeter() KStdGreeter::KStdGreeter()
@ -1048,6 +1060,7 @@ KStdGreeter::KStdGreeter()
pluginSetup(); pluginSetup();
verify->setInfoMessageDisplay(showInfoMessages);
verify->start(); verify->start();
TQTimer::singleShot(0, this, SLOT(cryptographicCardWatcherSetup())); TQTimer::singleShot(0, this, SLOT(cryptographicCardWatcherSetup()));
@ -1197,6 +1210,7 @@ KThemedGreeter::KThemedGreeter()
pluginSetup(); pluginSetup();
verify->setInfoMessageDisplay(showInfoMessages);
verify->start(); verify->start();
TQTimer::singleShot(0, this, SLOT(cryptographicCardWatcherSetup())); TQTimer::singleShot(0, this, SLOT(cryptographicCardWatcherSetup()));

@ -110,7 +110,7 @@ class KGreeter : public KGDialog, public KGVerifyHandler {
void processInputPipeCommand(TQString command); void processInputPipeCommand(TQString command);
public: public:
TQString curUser, curWMSession, dName; TQString curUser, cardLoginUser, curWMSession, dName;
protected slots: protected slots:
void cryptographicCardWatcherSetup(); void cryptographicCardWatcherSetup();
@ -137,6 +137,7 @@ class KGreeter : public KGDialog, public KGVerifyHandler {
bool prevValid; bool prevValid;
bool needLoad; bool needLoad;
bool themed; bool themed;
bool showInfoMessages;
static int curPlugin; static int curPlugin;
static PluginList pluginList; static PluginList pluginList;

@ -286,6 +286,14 @@ KGVerify::setPassword( const TQString &pass )
gplugActivity(); gplugActivity();
} }
void
KGVerify::setInfoMessageDisplay(bool on)
{
// assert( fixedEntity.isEmpty() );
Debug( "%s->setInfoMessageDisplay(%\"s)\n", pName.data(), on );
greet->setInfoMessageDisplay(on);
}
void void
KGVerify::start() KGVerify::start()
{ {
@ -383,6 +391,7 @@ KGVerify::doReject( bool initial )
void // not a slot - called manually by greeter void // not a slot - called manually by greeter
KGVerify::reject() KGVerify::reject()
{ {
inGreeterPlugin = false;
doReject( true ); doReject( true );
} }

@ -102,6 +102,7 @@ class KGVerify : public TQObject, public KGreeterPluginHandler {
void setUser( const TQString &user ); void setUser( const TQString &user );
void lockUserEntry( const bool lock ); void lockUserEntry( const bool lock );
void setPassword( const TQString &pass ); void setPassword( const TQString &pass );
void setInfoMessageDisplay( bool on );
/* virtual */ void selectPlugin( int id ); /* virtual */ void selectPlugin( int id );
bool entitiesLocal() const; bool entitiesLocal() const;
bool entitiesFielded() const; bool entitiesFielded() const;

@ -39,27 +39,33 @@ public:
DM(); DM();
~DM(); ~DM();
enum { Unknown, NoDM, NewTDM, OldTDM, GDM }; enum {
Unknown,
NoDM,
NewTDM,
OldTDM,
GDM
};
bool canShutdown(); bool canShutdown();
void shutdown( TDEApplication::ShutdownType shutdownType, void shutdown(TDEApplication::ShutdownType shutdownType,
TDEApplication::ShutdownMode shutdownMode, TDEApplication::ShutdownMode shutdownMode,
const TQString &bootOption = TQString::null ); const TQString &bootOption = TQString::null);
void setLock( bool on ); void setLock(bool on);
bool isSwitchable(); bool isSwitchable();
int numReserve(); int numReserve();
void startReserve(); void startReserve();
bool localSessions( SessList &list ); bool localSessions(SessList &list);
bool switchVT( int vt ); bool switchVT(int vt);
void lockSwitchVT( int vt ); void lockSwitchVT(int vt);
int activeVT(); int activeVT();
bool bootOptions( TQStringList &opts, int &dflt, int &curr ); bool bootOptions(TQStringList &opts, int &dflt, int &curr);
static TQString sess2Str( const SessEnt &se ); static TQString sess2Str(const SessEnt &se);
static void sess2Str2( const SessEnt &se, TQString &user, TQString &loc ); static void sess2Str2(const SessEnt &se, TQString &user, TQString &loc);
int type(); int type();

@ -66,7 +66,8 @@ KClassicGreeter::KClassicGreeter( KGreeterPluginHandler *_handler,
ctx( _ctx ), ctx( _ctx ),
exp( -1 ), exp( -1 ),
pExp( -1 ), pExp( -1 ),
running( false ) running( false ),
suppressInfoMsg(false)
{ {
KdmItem *user_entry = 0, *pw_entry = 0; KdmItem *user_entry = 0, *pw_entry = 0;
grid = 0; grid = 0;
@ -246,6 +247,10 @@ KClassicGreeter::setEnabled( bool enable )
passwdEdit->setFocus(); passwdEdit->setFocus();
} }
void KClassicGreeter::setInfoMessageDisplay(bool enable) {
suppressInfoMsg = !enable;
}
void // private void // private
KClassicGreeter::returnData() KClassicGreeter::returnData()
{ {
@ -276,8 +281,18 @@ bool // virtual
KClassicGreeter::textMessage( const char *text, bool err ) KClassicGreeter::textMessage( const char *text, bool err )
{ {
if (!err && if (!err &&
TQString( text ).find( TQRegExp( "^Changing password for [^ ]+$" ) ) >= 0) TQString( text ).find( TQRegExp( "^Changing password for [^ ]+$" ) ) >= 0) {
return true;
}
if (!err && suppressInfoMsg) {
return true; return true;
}
if (!err && ((TQString(text).lower().find("smartcard") >= 0) || (TQString(text).lower().find("smart card") >= 0))) {
// FIXME
// pam_pkcs11 is extremely chatty, even with no card inserted,
// and there is no apparent way to disable the unwanted messages!
return true;
}
return false; return false;
} }

@ -53,6 +53,7 @@ class KClassicGreeter : public TQObject, public KGreeterPlugin {
virtual void lockUserEntry( const bool lock ); virtual void lockUserEntry( const bool lock );
virtual void setPassword( const TQString &pass ); virtual void setPassword( const TQString &pass );
virtual void setEnabled( bool on ); virtual void setEnabled( bool on );
virtual void setInfoMessageDisplay( bool on );
virtual bool textMessage( const char *message, bool error ); virtual bool textMessage( const char *message, bool error );
virtual void textPrompt( const char *prompt, bool echo, bool nonBlocking ); virtual void textPrompt( const char *prompt, bool echo, bool nonBlocking );
virtual bool binaryPrompt( const char *prompt, bool nonBlocking ); virtual bool binaryPrompt( const char *prompt, bool nonBlocking );
@ -85,7 +86,7 @@ class KClassicGreeter : public TQObject, public KGreeterPlugin {
Context ctx; Context ctx;
TQGridLayout* grid; TQGridLayout* grid;
int exp, pExp, has; int exp, pExp, has;
bool running, authTok; bool running, authTok, suppressInfoMsg;
}; };
#endif /* KGREET_CLASSIC_H */ #endif /* KGREET_CLASSIC_H */

@ -88,7 +88,8 @@ KPamGreeter::KPamGreeter( KGreeterPluginHandler *_handler,
ctx( _ctx ), ctx( _ctx ),
exp( -1 ), exp( -1 ),
pExp( -1 ), pExp( -1 ),
running( false ) running( false ),
suppressInfoMsg(false)
{ {
ctx = Login; ctx = Login;
@ -287,6 +288,10 @@ KPamGreeter::setEnabled(bool enable)
authEdit[0]->setFocus(); authEdit[0]->setFocus();
} }
void KPamGreeter::setInfoMessageDisplay(bool enable) {
suppressInfoMsg = !enable;
}
void // private void // private
KPamGreeter::returnData() KPamGreeter::returnData()
{ {
@ -319,17 +324,22 @@ KPamGreeter::returnData()
bool // virtual bool // virtual
KPamGreeter::textMessage( const char *text, bool err ) KPamGreeter::textMessage( const char *text, bool err )
{ {
kg_debug(" ************** textMessage(%s, %d)\n", text, err); kg_debug(" ************** textMessage(%s, %d)\n", text, err);
if (!authEdit.size()) if (!authEdit.size()) {
return false; return false;
}
if (getLayoutItem()) { if (!err && suppressInfoMsg) {
TQLabel* label = new TQLabel(TQString::fromUtf8(text), m_parentWidget); return true;
getLayoutItem()->addWidget(label, state+1, 0, 0); }
}
return true; if (getLayoutItem()) {
TQLabel* label = new TQLabel(TQString::fromUtf8(text), m_parentWidget);
getLayoutItem()->addWidget(label, state+1, 0, 0);
}
return true;
} }
void // virtual void // virtual

@ -53,6 +53,7 @@ class KPamGreeter : public TQObject, public KGreeterPlugin {
virtual void lockUserEntry( const bool lock ); virtual void lockUserEntry( const bool lock );
virtual void setPassword( const TQString &pass ); virtual void setPassword( const TQString &pass );
virtual void setEnabled( bool on ); virtual void setEnabled( bool on );
virtual void setInfoMessageDisplay( bool on );
virtual bool textMessage( const char *message, bool error ); virtual bool textMessage( const char *message, bool error );
virtual void textPrompt( const char *prompt, bool echo, bool nonBlocking ); virtual void textPrompt( const char *prompt, bool echo, bool nonBlocking );
virtual bool binaryPrompt( const char *prompt, bool nonBlocking ); virtual bool binaryPrompt( const char *prompt, bool nonBlocking );
@ -89,7 +90,7 @@ class KPamGreeter : public TQObject, public KGreeterPlugin {
Context ctx; Context ctx;
int exp, pExp, has; int exp, pExp, has;
unsigned state; unsigned state;
bool running, authTok; bool running, authTok, suppressInfoMsg;
}; };
#endif /* KGREET_CLASSIC_H */ #endif /* KGREET_CLASSIC_H */

@ -74,7 +74,8 @@ KWinbindGreeter::KWinbindGreeter( KGreeterPluginHandler *_handler,
ctx( _ctx ), ctx( _ctx ),
exp( -1 ), exp( -1 ),
pExp( -1 ), pExp( -1 ),
running( false ) running( false ),
suppressInfoMsg(false)
{ {
KdmItem *user_entry = 0, *pw_entry = 0, *domain_entry = 0; KdmItem *user_entry = 0, *pw_entry = 0, *domain_entry = 0;
TQGridLayout *grid = 0; TQGridLayout *grid = 0;
@ -323,6 +324,10 @@ KWinbindGreeter::setEnabled( bool enable )
passwdEdit->setFocus(); passwdEdit->setFocus();
} }
void KWinbindGreeter::setInfoMessageDisplay(bool enable) {
suppressInfoMsg = !enable;
}
void // private void // private
KWinbindGreeter::returnData() KWinbindGreeter::returnData()
{ {
@ -352,8 +357,12 @@ bool // virtual
KWinbindGreeter::textMessage( const char *text, bool err ) KWinbindGreeter::textMessage( const char *text, bool err )
{ {
if (!err && if (!err &&
TQString( text ).find( TQRegExp( "^Changing password for [^ ]+$" ) ) >= 0) TQString( text ).find( TQRegExp( "^Changing password for [^ ]+$" ) ) >= 0) {
return true; return true;
}
if (!err && suppressInfoMsg) {
return true;
}
return false; return false;
} }

@ -57,6 +57,7 @@ class KWinbindGreeter : public TQObject, public KGreeterPlugin {
virtual void lockUserEntry( const bool lock ); virtual void lockUserEntry( const bool lock );
virtual void setPassword( const TQString &pass ); virtual void setPassword( const TQString &pass );
virtual void setEnabled( bool on ); virtual void setEnabled( bool on );
virtual void setInfoMessageDisplay( bool on );
virtual bool textMessage( const char *message, bool error ); virtual bool textMessage( const char *message, bool error );
virtual void textPrompt( const char *prompt, bool echo, bool nonBlocking ); virtual void textPrompt( const char *prompt, bool echo, bool nonBlocking );
virtual bool binaryPrompt( const char *prompt, bool nonBlocking ); virtual bool binaryPrompt( const char *prompt, bool nonBlocking );
@ -96,7 +97,7 @@ class KWinbindGreeter : public TQObject, public KGreeterPlugin {
Function func; Function func;
Context ctx; Context ctx;
int exp, pExp, has; int exp, pExp, has;
bool running, authTok; bool running, authTok, suppressInfoMsg;
}; };
#endif /* KGREET_WINBIND_H */ #endif /* KGREET_WINBIND_H */

@ -170,6 +170,13 @@ public:
*/ */
virtual void setEnabled( bool on ) = 0; virtual void setEnabled( bool on ) = 0;
/**
* En-/disable display of informational messages
* The default is to display all informational messages
* @param on the state to set
*/
virtual void setInfoMessageDisplay( bool on ) = 0;
/** /**
* Called when a message from the authentication backend arrives. * Called when a message from the authentication backend arrives.
* @param message the message received from the backend * @param message the message received from the backend

Loading…
Cancel
Save