summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kdesktop/lock/sakdlg.cc2
-rw-r--r--tdm/kfrontend/sakdlg.cc2
-rw-r--r--tdmlib/CMakeLists.txt2
-rw-r--r--tdmlib/tdmtsak.cpp94
4 files changed, 57 insertions, 43 deletions
diff --git a/kdesktop/lock/sakdlg.cc b/kdesktop/lock/sakdlg.cc
index 1ae946b6..803c7791 100644
--- a/kdesktop/lock/sakdlg.cc
+++ b/kdesktop/lock/sakdlg.cc
@@ -124,7 +124,7 @@ void SAKDlg::slotSAKProcessExited()
SAKDlg::~SAKDlg()
{
if ((mSAKProcess) && (mSAKProcess->isRunning())) {
- mSAKProcess->kill(SIGTERM);
+ mSAKProcess->kill(SIGKILL);
delete mSAKProcess;
}
hide();
diff --git a/tdm/kfrontend/sakdlg.cc b/tdm/kfrontend/sakdlg.cc
index 3ea8d761..3758a471 100644
--- a/tdm/kfrontend/sakdlg.cc
+++ b/tdm/kfrontend/sakdlg.cc
@@ -222,7 +222,7 @@ void SAKDlg::cryptographicCardRemoved(TDECryptographicCardDevice* cdevice) {
SAKDlg::~SAKDlg()
{
if ((mSAKProcess) && (mSAKProcess->isRunning())) {
- mSAKProcess->kill(SIGTERM);
+ mSAKProcess->kill(SIGKILL);
delete mSAKProcess;
}
diff --git a/tdmlib/CMakeLists.txt b/tdmlib/CMakeLists.txt
index 3341e915..266d4be5 100644
--- a/tdmlib/CMakeLists.txt
+++ b/tdmlib/CMakeLists.txt
@@ -77,7 +77,7 @@ endif( )
if( BUILD_TSAK )
tde_add_executable( tdmtsak
SOURCES tdmtsak.cpp
- LINK ${TQT_LIBRARIES}
+ LINK ${TQT_LIBRARIES} tdecore-shared dmctl-static
DESTINATION ${BIN_INSTALL_DIR}
SETUID
DESCRIPTION "Secure Attention Key interface for TDM"
diff --git a/tdmlib/tdmtsak.cpp b/tdmlib/tdmtsak.cpp
index c893f86e..768bcda8 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;
}