From 145abc15d57fb29701a12e8a14dcb9c1fd72e9be Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Mon, 7 Dec 2020 22:58:44 +0900 Subject: Renaming of files in preparation for code style tools. Signed-off-by: Michele Calgaro --- tdm/cryptocardwatcher/CMakeLists.txt | 2 +- tdm/cryptocardwatcher/watcher.cc | 105 ----------------------------------- tdm/cryptocardwatcher/watcher.cpp | 105 +++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+), 106 deletions(-) delete mode 100644 tdm/cryptocardwatcher/watcher.cc create mode 100644 tdm/cryptocardwatcher/watcher.cpp (limited to 'tdm/cryptocardwatcher') diff --git a/tdm/cryptocardwatcher/CMakeLists.txt b/tdm/cryptocardwatcher/CMakeLists.txt index 7564ac2cf..4b4674513 100644 --- a/tdm/cryptocardwatcher/CMakeLists.txt +++ b/tdm/cryptocardwatcher/CMakeLists.txt @@ -24,7 +24,7 @@ link_directories( ##### tdecryptocardwatcher (executable) ######### tde_add_executable( tdecryptocardwatcher AUTOMOC - SOURCES main.cpp watcher.cc + SOURCES main.cpp watcher.cpp LINK tdecore-shared tdeio-shared dmctl-static DESTINATION ${BIN_INSTALL_DIR} SETUID diff --git a/tdm/cryptocardwatcher/watcher.cc b/tdm/cryptocardwatcher/watcher.cc deleted file mode 100644 index ecd4e8f3c..000000000 --- a/tdm/cryptocardwatcher/watcher.cc +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2015 Timothy Pearson - * - * This file is part of cryptocardwatcher, the TDE Cryptographic Card Session Monitor - * - * cryptocardwatcher is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * cryptocardwatcher is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with cryptocardwatcher. If not, see http://www.gnu.org/licenses/. - */ - -#include "watcher.h" - -#include - -#include -#include - -#include -#include - -CardWatcher::CardWatcher() : TQObject() { - // -} - -CardWatcher::~CardWatcher() { - // -} - -void CardWatcher::cryptographicCardInserted(TDECryptographicCardDevice* cdevice) { - TQString login_name = TQString::null; - X509CertificatePtrList certList = cdevice->cardX509Certificates(); - if (certList.count() > 0) { - KSSLCertificate* card_cert = NULL; - card_cert = KSSLCertificate::fromX509(certList[0]); - TQStringList cert_subject_parts = TQStringList::split("/", card_cert->getSubject(), false); - for (TQStringList::Iterator it = cert_subject_parts.begin(); it != cert_subject_parts.end(); ++it ) { - TQString lcpart = (*it).lower(); - if (lcpart.startsWith("cn=")) { - login_name = lcpart.right(lcpart.length() - strlen("cn=")); - } - } - delete card_cert; - } - - if (login_name != "") { - // Determine if user already has an active session - DM dm; - SessList sess; - bool user_active = false; - bool unused_session_available = false; - bool unused_session_active = false; - int unused_session_vt_number = -1; - if (dm.localSessions(sess)) { - TQString user, loc; - for (SessList::ConstIterator it = sess.begin(); it != sess.end(); ++it) { - DM::sess2Str2(*it, user, loc); - if (user.startsWith(login_name + ": ")) { - // Found active session - user_active = true; - - // Switch VTs - DM().switchVT((*it).vt); - - break; - } - if (user == "Unused") { - // Found active unused session - unused_session_available = true; - unused_session_vt_number = (*it).vt; - if ((*it).vt == dm.activeVT()) { - unused_session_active = true; - break; - } - } - } - } - if (!user_active || unused_session_available) { - if (unused_session_available) { - if (!unused_session_active) { - // Switch to unused VT - DM().switchVT(unused_session_vt_number); - } - } - else { - // Activate new VT - DM().startReserve(); - } - } - } -} - -void CardWatcher::cryptographicCardRemoved(TDECryptographicCardDevice* cdevice) { - // -} - -#include "watcher.moc" \ No newline at end of file diff --git a/tdm/cryptocardwatcher/watcher.cpp b/tdm/cryptocardwatcher/watcher.cpp new file mode 100644 index 000000000..ecd4e8f3c --- /dev/null +++ b/tdm/cryptocardwatcher/watcher.cpp @@ -0,0 +1,105 @@ +/* + * Copyright 2015 Timothy Pearson + * + * This file is part of cryptocardwatcher, the TDE Cryptographic Card Session Monitor + * + * cryptocardwatcher is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * cryptocardwatcher is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with cryptocardwatcher. If not, see http://www.gnu.org/licenses/. + */ + +#include "watcher.h" + +#include + +#include +#include + +#include +#include + +CardWatcher::CardWatcher() : TQObject() { + // +} + +CardWatcher::~CardWatcher() { + // +} + +void CardWatcher::cryptographicCardInserted(TDECryptographicCardDevice* cdevice) { + TQString login_name = TQString::null; + X509CertificatePtrList certList = cdevice->cardX509Certificates(); + if (certList.count() > 0) { + KSSLCertificate* card_cert = NULL; + card_cert = KSSLCertificate::fromX509(certList[0]); + TQStringList cert_subject_parts = TQStringList::split("/", card_cert->getSubject(), false); + for (TQStringList::Iterator it = cert_subject_parts.begin(); it != cert_subject_parts.end(); ++it ) { + TQString lcpart = (*it).lower(); + if (lcpart.startsWith("cn=")) { + login_name = lcpart.right(lcpart.length() - strlen("cn=")); + } + } + delete card_cert; + } + + if (login_name != "") { + // Determine if user already has an active session + DM dm; + SessList sess; + bool user_active = false; + bool unused_session_available = false; + bool unused_session_active = false; + int unused_session_vt_number = -1; + if (dm.localSessions(sess)) { + TQString user, loc; + for (SessList::ConstIterator it = sess.begin(); it != sess.end(); ++it) { + DM::sess2Str2(*it, user, loc); + if (user.startsWith(login_name + ": ")) { + // Found active session + user_active = true; + + // Switch VTs + DM().switchVT((*it).vt); + + break; + } + if (user == "Unused") { + // Found active unused session + unused_session_available = true; + unused_session_vt_number = (*it).vt; + if ((*it).vt == dm.activeVT()) { + unused_session_active = true; + break; + } + } + } + } + if (!user_active || unused_session_available) { + if (unused_session_available) { + if (!unused_session_active) { + // Switch to unused VT + DM().switchVT(unused_session_vt_number); + } + } + else { + // Activate new VT + DM().startReserve(); + } + } + } +} + +void CardWatcher::cryptographicCardRemoved(TDECryptographicCardDevice* cdevice) { + // +} + +#include "watcher.moc" \ No newline at end of file -- cgit v1.2.1