summaryrefslogtreecommitdiffstats
path: root/tdmlib
diff options
context:
space:
mode:
Diffstat (limited to 'tdmlib')
-rw-r--r--tdmlib/CMakeLists.txt4
-rw-r--r--tdmlib/dmctl.cpp88
-rw-r--r--tdmlib/dmctl.h28
-rw-r--r--tdmlib/kgreet_classic.cpp157
-rw-r--r--tdmlib/kgreet_classic.h8
-rw-r--r--tdmlib/kgreet_pam.cpp67
-rw-r--r--tdmlib/kgreet_pam.h5
-rw-r--r--tdmlib/kgreet_winbind.cpp52
-rw-r--r--tdmlib/kgreet_winbind.h5
-rw-r--r--tdmlib/kgreeterplugin.h21
-rw-r--r--tdmlib/tdmtsak.cpp94
11 files changed, 408 insertions, 121 deletions
diff --git a/tdmlib/CMakeLists.txt b/tdmlib/CMakeLists.txt
index 3341e9157..7f6fbbbcc 100644
--- a/tdmlib/CMakeLists.txt
+++ b/tdmlib/CMakeLists.txt
@@ -67,7 +67,7 @@ if( BUILD_KICKER OR BUILD_KDESKTOP OR BUILD_TDM OR
tde_add_library( dmctl STATIC_PIC
SOURCES dmctl.cpp
- LINK Xau
+ LINK tdecore-shared Xau
)
endif( )
@@ -77,7 +77,7 @@ endif( )
if( BUILD_TSAK )
tde_add_executable( tdmtsak
SOURCES tdmtsak.cpp
- LINK ${TQT_LIBRARIES}
+ LINK ${TQT_LIBRARIES} dmctl-static
DESTINATION ${BIN_INSTALL_DIR}
SETUID
DESCRIPTION "Secure Attention Key interface for TDM"
diff --git a/tdmlib/dmctl.cpp b/tdmlib/dmctl.cpp
index 75e88fc6e..00c3cb489 100644
--- a/tdmlib/dmctl.cpp
+++ b/tdmlib/dmctl.cpp
@@ -25,6 +25,7 @@
#include <dcopclient.h>
#include <tqregexp.h>
+#include <tqfile.h>
#include <X11/Xauth.h>
#include <X11/Xlib.h>
@@ -37,8 +38,34 @@
#include <fcntl.h>
#include <errno.h>
+#include <config.h>
+
+static TQString readcfg(const char *cfg_file) {
+ TQString ctl = "/var/run/xdmctl";
+
+ TQStringList lines;
+ TQFile file(cfg_file);
+ if ( file.open( IO_ReadOnly ) ) {
+ TQTextStream stream(&file);
+ TQString line;
+ while ( !stream.atEnd() ) {
+ line = stream.readLine();
+ TQStringList keyvaluepair = TQStringList::split("=", line, false);
+ if (keyvaluepair.count() > 1) {
+ if (keyvaluepair[0].lower() == "FifoDir") {
+ ctl = keyvaluepair[1];
+ }
+ }
+ }
+ file.close();
+ }
+
+ return ctl;
+}
+
static int DMType = DM::Unknown;
-static const char *ctl, *dpy;
+static const char *dpy;
+static TQString ctl;
DM::DM() : fd( -1 )
{
@@ -46,16 +73,27 @@ DM::DM() : fd( -1 )
struct sockaddr_un sa;
if (DMType == Unknown) {
- if (!(dpy = ::getenv( "DISPLAY" )))
- DMType = NoDM;
- else if ((ctl = ::getenv( "DM_CONTROL" )))
+ if (!(dpy = ::getenv( "DISPLAY" ))) {
+ // Try to read TDM control file
+ if ((ctl = readcfg(KDE_CONFDIR "/tdm/tdmrc")) != TQString::null) {
+ DMType = NewTDM;
+ }
+ else {
+ DMType = NoDM;
+ }
+ }
+ else if ((ctl = ::getenv( "DM_CONTROL" )) != TQString::null) {
DMType = NewTDM;
- else if ((ctl = ::getenv( "XDM_MANAGED" )) && ctl[0] == '/')
+ }
+ else if (((ctl = ::getenv( "XDM_MANAGED" )) != TQString::null) && ctl[0] == '/') {
DMType = OldTDM;
- else if (::getenv( "GDMSESSION" ))
+ }
+ else if (::getenv( "GDMSESSION" )) {
DMType = GDM;
- else
+ }
+ else {
DMType = NoDM;
+ }
}
switch (DMType) {
default:
@@ -76,12 +114,17 @@ DM::DM() : fd( -1 )
}
}
GDMAuthenticate();
- } else {
- if ((ptr = const_cast<char*>(strchr( dpy, ':' ))))
- ptr = strchr( ptr, '.' );
- snprintf( sa.sun_path, sizeof(sa.sun_path),
- "%s/dmctl-%.*s/socket",
- ctl, ptr ? int(ptr - dpy) : 512, dpy );
+ }
+ else {
+ if (!dpy) {
+ snprintf( sa.sun_path, sizeof(sa.sun_path), "%s/dmctl/socket", ctl.ascii() );
+ }
+ else {
+ if ((ptr = const_cast<char*>(strchr( dpy, ':' )))) {
+ ptr = strchr( ptr, '.' );
+ }
+ snprintf( sa.sun_path, sizeof(sa.sun_path), "%s/dmctl-%.*s/socket", ctl.ascii(), ptr ? int(ptr - dpy) : 512, dpy );
+ }
if (::connect( fd, (struct sockaddr *)&sa, sizeof(sa) )) {
::close( fd );
fd = -1;
@@ -100,8 +143,9 @@ DM::DM() : fd( -1 )
DM::~DM()
{
- if (fd >= 0)
+ if (fd >= 0) {
close( fd );
+ }
}
bool
@@ -172,13 +216,15 @@ DM::exec( const char *cmd, TQCString &buf )
bool
DM::canShutdown()
{
- if (DMType == OldTDM)
- return strstr( ctl, ",maysd" ) != 0;
+ if (DMType == OldTDM) {
+ return strstr( ctl.ascii(), ",maysd" ) != 0;
+ }
TQCString re;
- if (DMType == GDM)
+ if (DMType == GDM) {
return exec( "QUERY_LOGOUT_ACTION\n", re ) && re.find("HALT") >= 0;
+ }
return exec( "caps\n", re ) && re.find( "\tshutdown" ) >= 0;
}
@@ -282,7 +328,7 @@ DM::numReserve()
return 1; /* Bleh */
if (DMType == OldTDM)
- return strstr( ctl, ",rsvd" ) ? 1 : -1;
+ return strstr( ctl.ascii(), ",rsvd" ) ? 1 : -1;
TQCString re;
int p;
@@ -304,8 +350,9 @@ DM::startReserve()
bool
DM::localSessions( SessList &list )
{
- if (DMType == OldTDM)
+ if (DMType == OldTDM) {
return false;
+ }
TQCString re;
@@ -325,8 +372,9 @@ DM::localSessions( SessList &list )
list.append( se );
}
} else {
- if (!exec( "list\talllocal\n", re ))
+ if (!exec( "list\talllocal\n", re )) {
return false;
+ }
TQStringList sess = TQStringList::split( TQChar('\t'), re.data() + 3 );
for (TQStringList::ConstIterator it = sess.begin(); it != sess.end(); ++it) {
TQStringList ts = TQStringList::split( TQChar(','), *it, true );
diff --git a/tdmlib/dmctl.h b/tdmlib/dmctl.h
index 90928e2e3..e0cdc966c 100644
--- a/tdmlib/dmctl.h
+++ b/tdmlib/dmctl.h
@@ -39,27 +39,33 @@ public:
DM();
~DM();
- enum { Unknown, NoDM, NewTDM, OldTDM, GDM };
+ enum {
+ Unknown,
+ NoDM,
+ NewTDM,
+ OldTDM,
+ GDM
+ };
bool canShutdown();
- void shutdown( TDEApplication::ShutdownType shutdownType,
- TDEApplication::ShutdownMode shutdownMode,
- const TQString &bootOption = TQString::null );
+ void shutdown(TDEApplication::ShutdownType shutdownType,
+ TDEApplication::ShutdownMode shutdownMode,
+ const TQString &bootOption = TQString::null);
- void setLock( bool on );
+ void setLock(bool on);
bool isSwitchable();
int numReserve();
void startReserve();
- bool localSessions( SessList &list );
- bool switchVT( int vt );
- void lockSwitchVT( int vt );
+ bool localSessions(SessList &list);
+ bool switchVT(int vt);
+ void lockSwitchVT(int vt);
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 void sess2Str2( const SessEnt &se, TQString &user, TQString &loc );
+ static TQString sess2Str(const SessEnt &se);
+ static void sess2Str2(const SessEnt &se, TQString &user, TQString &loc);
int type();
diff --git a/tdmlib/kgreet_classic.cpp b/tdmlib/kgreet_classic.cpp
index 3d1cedc19..d22f6979f 100644
--- a/tdmlib/kgreet_classic.cpp
+++ b/tdmlib/kgreet_classic.cpp
@@ -45,6 +45,15 @@ protected:
static int echoMode;
+TQString KClassicGreeter::passwordPrompt() {
+ if (func == Authenticate) {
+ return i18n("&Password:");
+ }
+ else {
+ return i18n("Current &password:");
+ }
+}
+
KClassicGreeter::KClassicGreeter( KGreeterPluginHandler *_handler,
KdmThemer *themer,
TQWidget *parent, TQWidget *pred,
@@ -57,10 +66,12 @@ KClassicGreeter::KClassicGreeter( KGreeterPluginHandler *_handler,
ctx( _ctx ),
exp( -1 ),
pExp( -1 ),
- running( false )
+ running( false ),
+ userEntryLocked(false),
+ suppressInfoMsg(false)
{
KdmItem *user_entry = 0, *pw_entry = 0;
- TQGridLayout *grid = 0;
+ grid = 0;
int line = 0;
layoutItem = 0;
@@ -120,11 +131,7 @@ KClassicGreeter::KClassicGreeter( KGreeterPluginHandler *_handler,
passwdEdit->adjustSize();
pw_entry->setWidget( passwdEdit );
} else {
- passwdLabel = new TQLabel( passwdEdit,
- func == Authenticate ?
- i18n("&Password:") :
- i18n("Current &password:"),
- parent );
+ passwdLabel = new TQLabel( passwdEdit, passwordPrompt(), parent );
grid->addWidget( passwdLabel, line, 0 );
grid->addWidget( passwdEdit, line++, 1 );
}
@@ -217,6 +224,11 @@ KClassicGreeter::setUser( const TQString &user )
passwdEdit->selectAll();
}
+void KClassicGreeter::lockUserEntry( const bool lock ) {
+ userEntryLocked = lock;
+ loginEdit->setEnabled(!lock);
+}
+
void // virtual
KClassicGreeter::setPassword( const TQString &pass )
{
@@ -237,6 +249,27 @@ KClassicGreeter::setEnabled( bool enable )
passwdEdit->setFocus();
}
+void KClassicGreeter::setInfoMessageDisplay(bool enable) {
+ suppressInfoMsg = !enable;
+}
+
+void KClassicGreeter::setPasswordPrompt(const TQString &prompt) {
+ if (passwdLabel) {
+ passwdPromptCustomString = prompt;
+
+ if (prompt != TQString::null) {
+ passwdLabel->setText(prompt);
+ }
+ else {
+ passwdLabel->setText(passwordPrompt());
+ }
+ if (grid) {
+ grid->invalidate();
+ grid->activate();
+ }
+ }
+}
+
void // private
KClassicGreeter::returnData()
{
@@ -267,8 +300,19 @@ bool // virtual
KClassicGreeter::textMessage( const char *text, bool 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;
+ }
+ if ((!err && ((TQString(text).lower().find("smartcard") >= 0) || (TQString(text).lower().find("smart card") >= 0)))
+ || (err && (TQString(text).lower().find(" 2306:") >= 0)) || (err && (TQString(text).lower().find("PKINIT") >= 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;
}
@@ -276,13 +320,30 @@ void // virtual
KClassicGreeter::textPrompt( const char *prompt, bool echo, bool nonBlocking )
{
pExp = exp;
- if (echo)
+ if (echo) {
exp = 0;
- else if (!authTok)
+ }
+ else if (!authTok) {
exp = 1;
+ if (passwdLabel) {
+ if (prompt && (prompt[0] != 0)) {
+ passwdLabel->setText(prompt);
+ }
+ else {
+ if (passwdPromptCustomString == TQString::null) {
+ passwdLabel->setText(passwordPrompt());
+ }
+ }
+ if (grid) {
+ grid->invalidate();
+ grid->activate();
+ }
+ }
+ }
else {
TQString pr( prompt );
- if (pr.find( TQRegExp( "\\bpassword\\b", false ) ) >= 0) {
+ if ((pr.find( TQRegExp( "\\bpassword\\b", false ) ) >= 0)
+ || (pr.find( TQRegExp( "\\bPIN\\b", false ) ) >= 0)) {
if (pr.find( TQRegExp( "\\b(re-?(enter|type)|again|confirm|repeat)\\b",
false ) ) >= 0)
exp = 3;
@@ -294,7 +355,8 @@ KClassicGreeter::textPrompt( const char *prompt, bool echo, bool nonBlocking )
KGreeterPluginHandler::IsSecret );
return;
}
- } else {
+ }
+ else {
handler->gplugMsgBox( TQMessageBox::Critical,
i18n("Unrecognized prompt \"%1\"")
.arg( prompt ) );
@@ -309,8 +371,9 @@ KClassicGreeter::textPrompt( const char *prompt, bool echo, bool nonBlocking )
has = -1;
}
- if (has >= exp || nonBlocking)
+ if (has >= exp || nonBlocking) {
returnData();
+ }
}
bool // virtual
@@ -392,6 +455,15 @@ KClassicGreeter::succeeded()
void // virtual
KClassicGreeter::failed()
{
+ if (passwdLabel && (passwdPromptCustomString == TQString::null)) {
+ // reset password prompt
+ passwdLabel->setText(passwordPrompt());
+ if (grid) {
+ grid->invalidate();
+ grid->activate();
+ }
+ }
+
// assert( running || timed_login );
setActive( false );
setActive2( false );
@@ -402,22 +474,41 @@ KClassicGreeter::failed()
void // virtual
KClassicGreeter::revive()
{
- // assert( !running );
- setActive2( true );
+ if (passwdLabel && (passwdPromptCustomString == TQString::null)) {
+ // reset password prompt
+ passwdLabel->setText(passwordPrompt());
+ if (grid) {
+ grid->invalidate();
+ grid->activate();
+ }
+ }
+
+ // assert(!running);
+ setActive2(true);
if (authTok) {
- passwd1Edit->erase();
- passwd2Edit->erase();
- passwd1Edit->setFocus();
- } else {
+ if (passwd1Edit) {
+ passwd1Edit->erase();
+ }
+ if (passwd2Edit) {
+ passwd2Edit->erase();
+ }
+ if (passwd1Edit) {
+ passwd1Edit->setFocus();
+ }
+ }
+ else {
passwdEdit->erase();
- if (loginEdit && loginEdit->isEnabled())
+ if (loginEdit && loginEdit->isEnabled()) {
passwdEdit->setEnabled( true );
+ }
else {
setActive( true );
- if (loginEdit && loginEdit->text().isEmpty())
+ if (loginEdit && loginEdit->text().isEmpty()) {
loginEdit->setFocus();
- else
+ }
+ else {
passwdEdit->setFocus();
+ }
}
}
}
@@ -425,6 +516,15 @@ KClassicGreeter::revive()
void // virtual
KClassicGreeter::clear()
{
+ if (passwdLabel && (passwdPromptCustomString == TQString::null)) {
+ // reset password prompt
+ passwdLabel->setText(passwordPrompt());
+ if (grid) {
+ grid->invalidate();
+ grid->activate();
+ }
+ }
+
// assert( !running && !passwd1Edit );
passwdEdit->erase();
if (loginEdit) {
@@ -441,10 +541,17 @@ KClassicGreeter::clear()
void
KClassicGreeter::setActive( bool enable )
{
- if (loginEdit)
- loginEdit->setEnabled( enable );
- if (passwdEdit)
+ if (loginEdit) {
+ if (userEntryLocked) {
+ loginEdit->setEnabled( false );
+ }
+ else {
+ loginEdit->setEnabled( enable );
+ }
+ }
+ if (passwdEdit) {
passwdEdit->setEnabled( enable );
+ }
}
void
diff --git a/tdmlib/kgreet_classic.h b/tdmlib/kgreet_classic.h
index 1f467a528..3f36d5000 100644
--- a/tdmlib/kgreet_classic.h
+++ b/tdmlib/kgreet_classic.h
@@ -50,8 +50,11 @@ class KClassicGreeter : public TQObject, public KGreeterPlugin {
virtual void presetEntity( const TQString &entity, int field );
virtual TQString getEntity() const;
virtual void setUser( const TQString &user );
+ virtual void lockUserEntry( const bool lock );
virtual void setPassword( const TQString &pass );
+ virtual void setPasswordPrompt( const TQString &prompt );
virtual void setEnabled( bool on );
+ virtual void setInfoMessageDisplay( bool on );
virtual bool textMessage( const char *message, bool error );
virtual void textPrompt( const char *prompt, bool echo, bool nonBlocking );
virtual bool binaryPrompt( const char *prompt, bool nonBlocking );
@@ -70,6 +73,7 @@ class KClassicGreeter : public TQObject, public KGreeterPlugin {
void slotActivity();
private:
+ TQString passwordPrompt();
void setActive( bool enable );
void setActive2( bool enable );
void returnData();
@@ -81,8 +85,10 @@ class KClassicGreeter : public TQObject, public KGreeterPlugin {
TQString fixedUser, curUser;
Function func;
Context ctx;
+ TQGridLayout* grid;
int exp, pExp, has;
- bool running, authTok;
+ bool running, authTok, userEntryLocked, suppressInfoMsg;
+ TQString passwdPromptCustomString;
};
#endif /* KGREET_CLASSIC_H */
diff --git a/tdmlib/kgreet_pam.cpp b/tdmlib/kgreet_pam.cpp
index b16dfb440..2aea2ae04 100644
--- a/tdmlib/kgreet_pam.cpp
+++ b/tdmlib/kgreet_pam.cpp
@@ -88,7 +88,9 @@ KPamGreeter::KPamGreeter( KGreeterPluginHandler *_handler,
ctx( _ctx ),
exp( -1 ),
pExp( -1 ),
- running( false )
+ running( false ),
+ userEntryLocked(false),
+ suppressInfoMsg(false)
{
ctx = Login;
@@ -263,6 +265,11 @@ KPamGreeter::setUser( const TQString &user )
}
}
+void KPamGreeter::lockUserEntry( const bool lock ) {
+ userEntryLocked = lock;
+ loginEdit->setEnabled(!lock);
+}
+
void // virtual
KPamGreeter::setPassword( const TQString &pass )
{
@@ -279,9 +286,31 @@ KPamGreeter::setEnabled(bool enable)
// loginLabel->setEnabled( enable );
authEdit[0]->setEnabled( enable );
setActive( enable );
- if (enable)
+ if (enable) {
authEdit[0]->setFocus();
+ }
+ }
+
+void KPamGreeter::setInfoMessageDisplay(bool enable) {
+ suppressInfoMsg = !enable;
+}
+
+void KPamGreeter::setPasswordPrompt(const TQString &prompt) {
+#if 0
+ if (passwdLabel) {
+ if (prompt != TQString::null) {
+ passwdLabel->setText(prompt);
+ }
+ else {
+ passwdLabel->setText(passwordPrompt());
+ }
+ if (grid) {
+ grid->invalidate();
+ grid->activate();
+ }
}
+#endif
+}
void // private
KPamGreeter::returnData()
@@ -315,17 +344,22 @@ KPamGreeter::returnData()
bool // virtual
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())
- return false;
+ if (!authEdit.size()) {
+ return false;
+ }
- if (getLayoutItem()) {
- TQLabel* label = new TQLabel(TQString::fromUtf8(text), m_parentWidget);
- getLayoutItem()->addWidget(label, state+1, 0, 0);
- }
+ if (!err && suppressInfoMsg) {
+ return true;
+ }
- return true;
+ if (getLayoutItem()) {
+ TQLabel* label = new TQLabel(TQString::fromUtf8(text), m_parentWidget);
+ getLayoutItem()->addWidget(label, state+1, 0, 0);
+ }
+
+ return true;
}
void // virtual
@@ -335,8 +369,9 @@ KPamGreeter::textPrompt( const char *prompt, bool echo, bool nonBlocking )
kg_debug("state is %d, authEdit.size is %d\n", state, authEdit.size());
if (state == 0 && echo) {
- if (loginLabel)
+ if (loginLabel) {
loginLabel->setText(TQString::fromUtf8(prompt));
+ }
else if (m_themer) {
KdmLabel *tdmlabel = static_cast<KdmLabel*>(m_themer->findNode("user-label"));
if (tdmlabel) {
@@ -598,8 +633,14 @@ KPamGreeter::clear()
void
KPamGreeter::setActive( bool enable )
{
- if (loginEdit)
- loginEdit->setEnabled( enable );
+ if (loginEdit) {
+ if (userEntryLocked) {
+ loginEdit->setEnabled( false );
+ }
+ else {
+ loginEdit->setEnabled( enable );
+ }
+ }
}
void
diff --git a/tdmlib/kgreet_pam.h b/tdmlib/kgreet_pam.h
index 03c404c1e..f579f9522 100644
--- a/tdmlib/kgreet_pam.h
+++ b/tdmlib/kgreet_pam.h
@@ -50,8 +50,11 @@ class KPamGreeter : public TQObject, public KGreeterPlugin {
virtual void presetEntity( const TQString &entity, int field );
virtual TQString getEntity() const;
virtual void setUser( const TQString &user );
+ virtual void lockUserEntry( const bool lock );
virtual void setPassword( const TQString &pass );
+ virtual void setPasswordPrompt( const TQString &prompt );
virtual void setEnabled( bool on );
+ virtual void setInfoMessageDisplay( bool on );
virtual bool textMessage( const char *message, bool error );
virtual void textPrompt( const char *prompt, bool echo, bool nonBlocking );
virtual bool binaryPrompt( const char *prompt, bool nonBlocking );
@@ -88,7 +91,7 @@ class KPamGreeter : public TQObject, public KGreeterPlugin {
Context ctx;
int exp, pExp, has;
unsigned state;
- bool running, authTok;
+ bool running, authTok, userEntryLocked, suppressInfoMsg;
};
#endif /* KGREET_CLASSIC_H */
diff --git a/tdmlib/kgreet_winbind.cpp b/tdmlib/kgreet_winbind.cpp
index aa7e39b18..cddb2866b 100644
--- a/tdmlib/kgreet_winbind.cpp
+++ b/tdmlib/kgreet_winbind.cpp
@@ -74,7 +74,9 @@ KWinbindGreeter::KWinbindGreeter( KGreeterPluginHandler *_handler,
ctx( _ctx ),
exp( -1 ),
pExp( -1 ),
- running( false )
+ running( false ),
+ userEntryLocked(false),
+ suppressInfoMsg(false)
{
KdmItem *user_entry = 0, *pw_entry = 0, *domain_entry = 0;
TQGridLayout *grid = 0;
@@ -297,6 +299,11 @@ KWinbindGreeter::setUser( const TQString &user )
passwdEdit->selectAll();
}
+void KWinbindGreeter::lockUserEntry( const bool lock ) {
+ userEntryLocked = lock;
+ loginEdit->setEnabled(!lock);
+}
+
void // virtual
KWinbindGreeter::setPassword( const TQString &pass )
{
@@ -319,6 +326,27 @@ KWinbindGreeter::setEnabled( bool enable )
passwdEdit->setFocus();
}
+void KWinbindGreeter::setInfoMessageDisplay(bool enable) {
+ suppressInfoMsg = !enable;
+}
+
+void KWinbindGreeter::setPasswordPrompt(const TQString &prompt) {
+#if 0
+ if (passwdLabel) {
+ if (prompt != TQString::null) {
+ passwdLabel->setText(prompt);
+ }
+ else {
+ passwdLabel->setText(passwordPrompt());
+ }
+ if (grid) {
+ grid->invalidate();
+ grid->activate();
+ }
+ }
+#endif
+}
+
void // private
KWinbindGreeter::returnData()
{
@@ -348,8 +376,12 @@ bool // virtual
KWinbindGreeter::textMessage( const char *text, bool 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 false;
}
@@ -524,12 +556,20 @@ KWinbindGreeter::clear()
void
KWinbindGreeter::setActive( bool enable )
{
- if (domainCombo)
+ if (domainCombo) {
domainCombo->setEnabled( enable );
- if (loginEdit)
- loginEdit->setEnabled( enable );
- if (passwdEdit)
+ }
+ if (loginEdit) {
+ if (userEntryLocked) {
+ loginEdit->setEnabled( false );
+ }
+ else {
+ loginEdit->setEnabled( enable );
+ }
+ }
+ if (passwdEdit) {
passwdEdit->setEnabled( enable );
+ }
}
void
diff --git a/tdmlib/kgreet_winbind.h b/tdmlib/kgreet_winbind.h
index 54f2653fc..85565628e 100644
--- a/tdmlib/kgreet_winbind.h
+++ b/tdmlib/kgreet_winbind.h
@@ -54,8 +54,11 @@ class KWinbindGreeter : public TQObject, public KGreeterPlugin {
virtual void presetEntity( const TQString &entity, int field );
virtual TQString getEntity() const;
virtual void setUser( const TQString &user );
+ virtual void lockUserEntry( const bool lock );
virtual void setPassword( const TQString &pass );
+ virtual void setPasswordPrompt( const TQString &prompt );
virtual void setEnabled( bool on );
+ virtual void setInfoMessageDisplay( bool on );
virtual bool textMessage( const char *message, bool error );
virtual void textPrompt( const char *prompt, bool echo, bool nonBlocking );
virtual bool binaryPrompt( const char *prompt, bool nonBlocking );
@@ -95,7 +98,7 @@ class KWinbindGreeter : public TQObject, public KGreeterPlugin {
Function func;
Context ctx;
int exp, pExp, has;
- bool running, authTok;
+ bool running, authTok, userEntryLocked, suppressInfoMsg;
};
#endif /* KGREET_WINBIND_H */
diff --git a/tdmlib/kgreeterplugin.h b/tdmlib/kgreeterplugin.h
index 925828455..1dcd0233b 100644
--- a/tdmlib/kgreeterplugin.h
+++ b/tdmlib/kgreeterplugin.h
@@ -152,12 +152,24 @@ public:
virtual void setUser( const TQString &user ) = 0;
/**
+ * Lock or unlock editing of the username entry field
+ * @param lock true to lock, false to unlock
+ */
+ virtual void lockUserEntry( const bool lock ) = 0;
+
+ /**
* "Push" a password into the talker.
* @param pass the password to set.
*/
virtual void setPassword( const TQString &pass ) = 0;
/**
+ * Set the talker's password prompt to a custom string
+ * @param prompt the password prompt to set, or TQString::null for default
+ */
+ virtual void setPasswordPrompt( const TQString &prompt ) = 0;
+
+ /**
* En-/disable any widgets contained in the talker.
* Will be called only when not running.
* @param on the state to set
@@ -165,6 +177,13 @@ public:
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.
* @param message the message received from the backend
* @param error if true, @p message is an error message, otherwise it's
@@ -183,7 +202,7 @@ public:
/**
* Prompt the user for data. Reply by calling handler->gplugReturnText().
- * @param propmt the prompt to display. It may be null, in which case
+ * @param prompt the prompt to display. It may be null, in which case
* "Username"/"Password" should be shown and the replies should be tagged
* with the respective Is* flag.
* @param echo if true, a normal input widget can be used, otherwise one that
diff --git a/tdmlib/tdmtsak.cpp b/tdmlib/tdmtsak.cpp
index c893f86ec..768bcda80 100644
--- a/tdmlib/tdmtsak.cpp
+++ b/tdmlib/tdmtsak.cpp
@@ -1,6 +1,6 @@
/*
This file is part of the TDE project
- Copyright (C) 2011 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+ Copyright (C) 2011 - 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -18,10 +18,12 @@
Boston, MA 02110-1301, USA.
*/
-#include "tdmtsak.h"
-
#include <tqstringlist.h>
+#include "dmctl.h"
+
+#include "tdmtsak.h"
+
#define FIFO_FILE "/tmp/tdesocket-global/tsak"
TQString exec(const char * cmd) {
@@ -44,15 +46,17 @@ bool is_vt_local() {
return false;
}
else {
- TQString cvtName = "";
- TQString output = exec("tdmctl list");
- TQStringList sessionList = TQStringList::split('\t', output, false);
- // See if the current session is local
- for ( TQStringList::Iterator it = sessionList.begin(); it != sessionList.end(); ++it ) {
- TQStringList sessionInfoList = TQStringList::split(',', *it, true);
- if ((*(sessionInfoList.at(0))).startsWith(":")) {
- if (TQString(currentDisplay).startsWith(*(sessionInfoList.at(0)))) {
- return true;
+ DM dm;
+ SessList sess;
+ if (dm.localSessions(sess)) {
+ TQString user, loc;
+ for (SessList::ConstIterator it = sess.begin(); it != sess.end(); ++it) {
+ DM::sess2Str2(*it, user, loc);
+ TQStringList sessionInfoList = TQStringList::split(',', loc, true);
+ if ((*(sessionInfoList.at(0))).startsWith(":")) {
+ if (TQString(currentDisplay).startsWith(*(sessionInfoList.at(0)))) {
+ return true;
+ }
}
}
}
@@ -68,44 +72,54 @@ bool is_vt_active() {
return true;
}
else {
+ DM dm;
+ SessList sess;
TQString cvtName = "";
- TQString output = exec("tdmctl list");
- TQString curConsole = exec("fgconsole");
- bool intFound;
- int curConsoleNum = curConsole.toInt(&intFound);
- if (intFound == false) {
+ TQString curConsole;
+ int curConsoleNum = dm.activeVT();
+ if (curConsoleNum < 0) {
return true;
}
- curConsole = TQString("vt%1").arg(curConsoleNum);;
- TQStringList sessionList = TQStringList::split('\t', output, false);
- for ( TQStringList::Iterator it = sessionList.begin(); it != sessionList.end(); ++it ) {
- TQStringList sessionInfoList = TQStringList::split(',', *it, true);
- if ((*(sessionInfoList.at(0))).startsWith(":")) {
- if ((*(sessionInfoList.at(1))) == TQString(curConsole)) {
- cvtName = (*(sessionInfoList.at(0)));
+ curConsole = TQString("vt%1").arg(curConsoleNum);
+ if (dm.localSessions(sess)) {
+ TQString user, loc;
+ for (SessList::ConstIterator it = sess.begin(); it != sess.end(); ++it) {
+ DM::sess2Str2(*it, user, loc);
+ TQStringList sessionInfoList = TQStringList::split(',', loc, true);
+ if ((*(sessionInfoList.at(0))).startsWith(":")) {
+ if ((*(sessionInfoList.at(1))).stripWhiteSpace() == TQString(curConsole)) {
+ cvtName = (*(sessionInfoList.at(0)));
+ }
}
}
- }
- if (cvtName != "") {
- if (TQString(currentDisplay).startsWith(cvtName)) {
- return true;
+ if (cvtName != "") {
+ if (TQString(currentDisplay).startsWith(cvtName)) {
+ return true;
+ }
+ else {
+ return false;
+ }
}
else {
- return false;
- }
- }
- else {
- // See if the current session is local
- // If it is, then the VT is not currently active and the SAK must be requested later when it is active
- for ( TQStringList::Iterator it = sessionList.begin(); it != sessionList.end(); ++it ) {
- TQStringList sessionInfoList = TQStringList::split(',', *it, true);
- if ((*(sessionInfoList.at(0))).startsWith(":")) {
- if (TQString(currentDisplay).startsWith(*(sessionInfoList.at(0)))) {
- return false;
+ // See if the current session is local
+ // If it is, then the VT is not currently active and the SAK must be requested later when it is active
+ for (SessList::ConstIterator it = sess.begin(); it != sess.end(); ++it) {
+ DM::sess2Str2(*it, user, loc);
+ if ((*it).self) {
+ TQStringList sessionInfoList = TQStringList::split(',', loc, true);
+ if ((*(sessionInfoList.at(1))).startsWith(" vt")) {
+ // Local and inactive
+ return false;
+ }
}
}
+ // Hmm, not local
+ // Do not reject the SAK
+ return true;
}
- // Hmm, not local
+ }
+ else {
+ // Failure!
// Do not reject the SAK
return true;
}