Use DM library in tdmtsak instead of making command line calls

pull/2/head
Timothy Pearson 9 years ago
parent cd13be0789
commit 6d028f3b52

@ -124,7 +124,7 @@ void SAKDlg::slotSAKProcessExited()
SAKDlg::~SAKDlg() SAKDlg::~SAKDlg()
{ {
if ((mSAKProcess) && (mSAKProcess->isRunning())) { if ((mSAKProcess) && (mSAKProcess->isRunning())) {
mSAKProcess->kill(SIGTERM); mSAKProcess->kill(SIGKILL);
delete mSAKProcess; delete mSAKProcess;
} }
hide(); hide();

@ -222,7 +222,7 @@ void SAKDlg::cryptographicCardRemoved(TDECryptographicCardDevice* cdevice) {
SAKDlg::~SAKDlg() SAKDlg::~SAKDlg()
{ {
if ((mSAKProcess) && (mSAKProcess->isRunning())) { if ((mSAKProcess) && (mSAKProcess->isRunning())) {
mSAKProcess->kill(SIGTERM); mSAKProcess->kill(SIGKILL);
delete mSAKProcess; delete mSAKProcess;
} }

@ -77,7 +77,7 @@ endif( )
if( BUILD_TSAK ) if( BUILD_TSAK )
tde_add_executable( tdmtsak tde_add_executable( tdmtsak
SOURCES tdmtsak.cpp SOURCES tdmtsak.cpp
LINK ${TQT_LIBRARIES} LINK ${TQT_LIBRARIES} tdecore-shared dmctl-static
DESTINATION ${BIN_INSTALL_DIR} DESTINATION ${BIN_INSTALL_DIR}
SETUID SETUID
DESCRIPTION "Secure Attention Key interface for TDM" DESCRIPTION "Secure Attention Key interface for TDM"

@ -1,6 +1,6 @@
/* /*
This file is part of the TDE project 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 This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public modify it under the terms of the GNU Library General Public
@ -18,10 +18,12 @@
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#include "tdmtsak.h"
#include <tqstringlist.h> #include <tqstringlist.h>
#include "dmctl.h"
#include "tdmtsak.h"
#define FIFO_FILE "/tmp/tdesocket-global/tsak" #define FIFO_FILE "/tmp/tdesocket-global/tsak"
TQString exec(const char * cmd) { TQString exec(const char * cmd) {
@ -44,18 +46,20 @@ bool is_vt_local() {
return false; return false;
} }
else { else {
TQString cvtName = ""; DM dm;
TQString output = exec("tdmctl list"); SessList sess;
TQStringList sessionList = TQStringList::split('\t', output, false); if (dm.localSessions(sess)) {
// See if the current session is local TQString user, loc;
for ( TQStringList::Iterator it = sessionList.begin(); it != sessionList.end(); ++it ) { for (SessList::ConstIterator it = sess.begin(); it != sess.end(); ++it) {
TQStringList sessionInfoList = TQStringList::split(',', *it, true); DM::sess2Str2(*it, user, loc);
TQStringList sessionInfoList = TQStringList::split(',', loc, true);
if ((*(sessionInfoList.at(0))).startsWith(":")) { if ((*(sessionInfoList.at(0))).startsWith(":")) {
if (TQString(currentDisplay).startsWith(*(sessionInfoList.at(0)))) { if (TQString(currentDisplay).startsWith(*(sessionInfoList.at(0)))) {
return true; return true;
} }
} }
} }
}
// Not local // Not local
return false; return false;
} }
@ -68,20 +72,22 @@ bool is_vt_active() {
return true; return true;
} }
else { else {
DM dm;
SessList sess;
TQString cvtName = ""; TQString cvtName = "";
TQString output = exec("tdmctl list"); TQString curConsole;
TQString curConsole = exec("fgconsole"); int curConsoleNum = dm.activeVT();
bool intFound; if (curConsoleNum < 0) {
int curConsoleNum = curConsole.toInt(&intFound);
if (intFound == false) {
return true; return true;
} }
curConsole = TQString("vt%1").arg(curConsoleNum);; curConsole = TQString("vt%1").arg(curConsoleNum);
TQStringList sessionList = TQStringList::split('\t', output, false); if (dm.localSessions(sess)) {
for ( TQStringList::Iterator it = sessionList.begin(); it != sessionList.end(); ++it ) { TQString user, loc;
TQStringList sessionInfoList = TQStringList::split(',', *it, true); 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(0))).startsWith(":")) {
if ((*(sessionInfoList.at(1))) == TQString(curConsole)) { if ((*(sessionInfoList.at(1))).stripWhiteSpace() == TQString(curConsole)) {
cvtName = (*(sessionInfoList.at(0))); cvtName = (*(sessionInfoList.at(0)));
} }
} }
@ -97,10 +103,12 @@ bool is_vt_active() {
else { else {
// See if the current session is local // 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 // 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 ) { for (SessList::ConstIterator it = sess.begin(); it != sess.end(); ++it) {
TQStringList sessionInfoList = TQStringList::split(',', *it, true); DM::sess2Str2(*it, user, loc);
if ((*(sessionInfoList.at(0))).startsWith(":")) { if ((*it).self) {
if (TQString(currentDisplay).startsWith(*(sessionInfoList.at(0)))) { TQStringList sessionInfoList = TQStringList::split(',', loc, true);
if ((*(sessionInfoList.at(1))).startsWith(" vt")) {
// Local and inactive
return false; return false;
} }
} }
@ -110,6 +118,12 @@ bool is_vt_active() {
return true; return true;
} }
} }
else {
// Failure!
// Do not reject the SAK
return true;
}
}
} }
int main (int argc, char *argv[]) int main (int argc, char *argv[])

Loading…
Cancel
Save