summaryrefslogtreecommitdiffstats
path: root/tdesu/tdesu/sudlg.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-06 15:56:34 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-06 15:56:34 -0600
commitb529f046c9a64ac5fcfa60747af940cf972b3ebc (patch)
tree83c28cf7fa8fed1960ebd3924b579e7ed8c95cc6 /tdesu/tdesu/sudlg.cpp
parent6508fe4c40c60fd7a43bd3d9e19b762e10ea3f53 (diff)
downloadtdebase-b529f046c9a64ac5fcfa60747af940cf972b3ebc.tar.gz
tdebase-b529f046c9a64ac5fcfa60747af940cf972b3ebc.zip
Actually move the kde files that were renamed in the last commit
Diffstat (limited to 'tdesu/tdesu/sudlg.cpp')
-rw-r--r--tdesu/tdesu/sudlg.cpp103
1 files changed, 103 insertions, 0 deletions
diff --git a/tdesu/tdesu/sudlg.cpp b/tdesu/tdesu/sudlg.cpp
new file mode 100644
index 000000000..cfda9168c
--- /dev/null
+++ b/tdesu/tdesu/sudlg.cpp
@@ -0,0 +1,103 @@
+/* vi: ts=8 sts=4 sw=4
+ *
+ * This file is part of the KDE project, module tdesu.
+ * Copyright (C) 2000 Geert Jansen <jansen@kde.org>
+ */
+
+#include <config.h>
+#include <tqstring.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include <tdesu/su.h>
+#include "sudlg.h"
+
+KDEsuDialog::KDEsuDialog(TQCString user, TQCString auth_user, bool enableKeep,const TQString& icon, bool withIgnoreButton)
+ : KPasswordDialog(Password, enableKeep, (withIgnoreButton ? User1:NoDefault), icon)
+{
+ KConfig* config = KGlobal::config();
+ config->setGroup("super-user-command");
+ TQString superUserCommand = config->readEntry("super-user-command", DEFAULT_SUPER_USER_COMMAND);
+ if ( superUserCommand != "sudo" && superUserCommand != "su" ) {
+ kdWarning() << "unknown super user command" << endl;
+ superUserCommand = "su";
+ }
+
+ m_User = auth_user;
+ setCaption(i18n("Run as %1").arg(static_cast<const char *>(user)));
+
+ TQString prompt;
+ if (superUserCommand == "sudo" && m_User == "root") {
+ prompt = i18n("Please enter your password." );
+ } else {
+ if (m_User == "root") {
+ prompt = i18n("The action you requested needs root privileges. "
+ "Please enter root's password below or click "
+ "Ignore to continue with your current privileges.");
+ } else {
+ prompt = i18n("The action you requested needs additional privileges. "
+ "Please enter the password for \"%1\" below or click "
+ "Ignore to continue with your current privileges.").arg(static_cast<const char *>(m_User));
+ }
+ }
+ setPrompt(prompt);
+
+ if( withIgnoreButton )
+ setButtonText(User1, i18n("&Ignore"));
+}
+
+
+KDEsuDialog::~KDEsuDialog()
+{
+}
+
+bool KDEsuDialog::checkPassword(const char *password)
+{
+ SuProcess proc;
+ proc.setUser(m_User);
+ int status = proc.checkInstall(password);
+ switch (status)
+ {
+ case -1:
+ KMessageBox::sorry(this, i18n("Conversation with su failed."));
+ done(Rejected);
+ return false;
+
+ case 0:
+ return true;
+
+ case SuProcess::SuNotFound:
+ KMessageBox::sorry(this,
+ i18n("The program 'su' is not found;\n"
+ "make sure your PATH is set correctly."));
+ done(Rejected);
+ return false;
+
+ case SuProcess::SuNotAllowed:
+ KMessageBox::sorry(this,
+ i18n("You are not allowed to use 'su';\n"
+ "on some systems, you need to be in a special "
+ "group (often: wheel) to use this program."));
+ done(Rejected);
+ return false;
+
+ case SuProcess::SuIncorrectPassword:
+ KMessageBox::sorry(this, i18n("Incorrect password; please try again."));
+ return false;
+
+ default:
+ KMessageBox::error(this, i18n("Internal error: illegal return from "
+ "SuProcess::checkInstall()"));
+ done(Rejected);
+ return false;
+ }
+}
+
+void KDEsuDialog::slotUser1()
+{
+ done(AsUser);
+}
+
+#include "sudlg.moc"