diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-04-21 14:56:28 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-04-21 14:56:28 -0500 |
commit | 6cfb1608365cd45fb2e2736adf547f5f82f4ebd2 (patch) | |
tree | 5fc9847d0c926f959af4e2dc106a008565aeaf0c /kcontrol/tdm/tdm-appear.cpp | |
parent | 8abe81cec22c84b0eab5dd877f441f5bafdf5b59 (diff) | |
download | tdebase-6cfb1608365cd45fb2e2736adf547f5f82f4ebd2.tar.gz tdebase-6cfb1608365cd45fb2e2736adf547f5f82f4ebd2.zip |
Fix tsak housekeeping
Provide GUI warning when tsak cannot be used due to system module problems
Diffstat (limited to 'kcontrol/tdm/tdm-appear.cpp')
-rw-r--r-- | kcontrol/tdm/tdm-appear.cpp | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/kcontrol/tdm/tdm-appear.cpp b/kcontrol/tdm/tdm-appear.cpp index cdd5f2fc9..990270123 100644 --- a/kcontrol/tdm/tdm-appear.cpp +++ b/kcontrol/tdm/tdm-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 "tdm-appear.h" #include "kbackedcombobox.h" +#include "config.h" + extern KSimpleConfig *config; +#define TSAK_LOCKFILE "/tmp/tdesocket-global/tsak.lock" TDMAppearanceWidget::TDMAppearanceWidget(TQWidget *parent, const char *name) - : TQWidget(parent, name) + : TQWidget(parent, name), sakwarning(0) { TQString wtstr; @@ -247,6 +252,13 @@ TDMAppearanceWidget::TDMAppearanceWidget(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 TDMAppearanceWidget::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 TDMAppearanceWidget::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); + } } |