diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-04-21 14:56:28 -0500 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2012-06-03 03:27:07 +0200 |
commit | f6c6e7441fd18b7436e8c5c96e8158548015326e (patch) | |
tree | 6aa01c2aa13ffe842f6884ebecb477bd84220d8c /kcontrol | |
parent | 2a0ff52dbaab43dea86e4cbcda31df94b5d59a0a (diff) | |
download | tdebase-f6c6e7441fd18b7436e8c5c96e8158548015326e.tar.gz tdebase-f6c6e7441fd18b7436e8c5c96e8158548015326e.zip |
Fix tsak housekeeping
Provide GUI warning when tsak cannot be used due to system module problems
(cherry picked from commit 6cfb1608365cd45fb2e2736adf547f5f82f4ebd2)
Diffstat (limited to 'kcontrol')
-rw-r--r-- | kcontrol/kdm/kdm-appear.cpp | 38 | ||||
-rw-r--r-- | kcontrol/kdm/kdm-appear.h | 1 |
2 files changed, 36 insertions, 3 deletions
diff --git a/kcontrol/kdm/kdm-appear.cpp b/kcontrol/kdm/kdm-appear.cpp index a68b90881..aec656d52 100644 --- a/kcontrol/kdm/kdm-appear.cpp +++ b/kcontrol/kdm/kdm-appear.cpp @@ -21,7 +21,9 @@ #include <unistd.h> #include <sys/types.h> - +#include <stdlib.h> +#include <sys/types.h> +#include <signal.h> #include <tqbuttongroup.h> #include <tqlabel.h> @@ -47,11 +49,14 @@ #include "kdm-appear.h" #include "kbackedcombobox.h" +#include "config.h" + extern KSimpleConfig *config; +#define TSAK_LOCKFILE "/tmp/ksocket-global/tsak.lock" KDMAppearanceWidget::KDMAppearanceWidget(TQWidget *parent, const char *name) - : TQWidget(parent, name) + : TQWidget(parent, name), sakwarning(0) { TQString wtstr; @@ -247,6 +252,13 @@ KDMAppearanceWidget::KDMAppearanceWidget(TQWidget *parent, const char *name) TQGridLayout *hbox2 = new TQGridLayout( group->layout(), 2, 2, KDialog::spacingHint() ); hbox2->setColStretch(1, 1); hbox2->addWidget(sakbox, 1, 0); + if (getuid() == 0 && config->checkConfigFilesWritable( true )) { + if (system(KDE_BINDIR "/tsak checkdeps") != 0) { + sakbox->setEnabled(false); + sakwarning = new TQLabel( i18n("Secure Attention Key support is not available on your system. Please check for the presence of evdev and uinput."), group ); + hbox2->addWidget(sakwarning, 2, 0); + } + } wtstr = i18n("Here you can enable or disable the Secure Attention Key [SAK] anti-spoofing measure."); TQWhatsThis::add( sakbox, wtstr ); @@ -465,6 +477,21 @@ void KDMAppearanceWidget::save() config->writeEntry("Language", langcombo->current()); config->writeEntry("UseSAK", sakbox->isChecked()); + + // Enable/disable tsak as needed + if (sakbox->isChecked()) { + system(KDE_BINDIR "/tsak"); + } + else { + // Get PID + TQFile file(TSAK_LOCKFILE); + if (file.open(IO_ReadOnly)) { + TQTextStream stream(&file); + unsigned long tsakpid = stream.readLine().toULong(); + file.close(); + kill(tsakpid, SIGTERM); + } + } } @@ -516,7 +543,12 @@ void KDMAppearanceWidget::load() langcombo->setCurrentItem(config->readEntry("Language", "C")); // See if the SAK is enabled - sakbox->setChecked(config->readBoolEntry("UseSAK", true)); + if (sakwarning) { + sakbox->setChecked(config->readBoolEntry("UseSAK", true)); + } + else { + sakbox->setChecked(false); + } } diff --git a/kcontrol/kdm/kdm-appear.h b/kcontrol/kdm/kdm-appear.h index 958a91fb3..7e093be7c 100644 --- a/kcontrol/kdm/kdm-appear.h +++ b/kcontrol/kdm/kdm-appear.h @@ -91,6 +91,7 @@ private: KBackedComboBox *echocombo; KLanguageButton *langcombo; TQCheckBox *sakbox; + TQLabel *sakwarning; }; |