diff options
author | Darrell Anderson <[email protected]> | 2012-04-21 17:12:18 -0500 |
---|---|---|
committer | Darrell Anderson <[email protected]> | 2012-04-21 17:12:18 -0500 |
commit | f074f4da3c47be036e46d7272dc40a7198cf27a3 (patch) | |
tree | 225347d57ea8e35bcf65abbb14359f7b68daae49 /kcontrol/tdm/tdm-appear.cpp | |
parent | ff0bcfcc09e46734507e14b605902034f36da41e (diff) | |
parent | 6cfb1608365cd45fb2e2736adf547f5f82f4ebd2 (diff) | |
download | tdebase-f074f4da3c47be036e46d7272dc40a7198cf27a3.tar.gz tdebase-f074f4da3c47be036e46d7272dc40a7198cf27a3.zip |
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/tdebase
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); + } } |