Add support for sudo in kdesu.
The main problem is that sudo cannot be killed when it prompts password, as it's run by root, so the correct way out is to close the write fd.
This commit is contained in:
parent
4ddc5c3e1c
commit
a868937d39
19
x11/kde/libs3/patches/patch-kdesu_process_cpp
Normal file
19
x11/kde/libs3/patches/patch-kdesu_process_cpp
Normal file
@ -0,0 +1,19 @@
|
||||
$OpenBSD: patch-kdesu_process_cpp,v 1.1 2002/05/15 17:19:44 espie Exp $
|
||||
--- kdesu/process.cpp.orig Wed May 15 11:41:43 2002
|
||||
+++ kdesu/process.cpp Wed May 15 11:41:31 2002
|
||||
@@ -360,8 +360,13 @@ int PtyProcess::waitForChild()
|
||||
while (1)
|
||||
{
|
||||
tv.tv_sec = 1; tv.tv_usec = 0;
|
||||
- FD_SET(m_Fd, &fds);
|
||||
- ret = select(m_Fd+1, &fds, 0L, 0L, &tv);
|
||||
+ if (m_Fd != -1)
|
||||
+ {
|
||||
+ FD_SET(m_Fd, &fds);
|
||||
+ ret = select(m_Fd+1, &fds, 0L, 0L, &tv);
|
||||
+ }
|
||||
+ else
|
||||
+ ret = 0;
|
||||
if (ret == -1)
|
||||
{
|
||||
if (errno == EINTR) continue;
|
88
x11/kde/libs3/patches/patch-kdesu_su_cpp
Normal file
88
x11/kde/libs3/patches/patch-kdesu_su_cpp
Normal file
@ -0,0 +1,88 @@
|
||||
$OpenBSD: patch-kdesu_su_cpp,v 1.1 2002/05/15 17:19:44 espie Exp $
|
||||
--- kdesu/su.cpp.orig Sat May 11 11:13:25 2002
|
||||
+++ kdesu/su.cpp Wed May 15 12:02:01 2002
|
||||
@@ -41,17 +41,33 @@
|
||||
#ifndef __PATH_SU
|
||||
#define __PATH_SU "false"
|
||||
#endif
|
||||
+#ifndef __PATH_SUDO
|
||||
+#define __PATH_SUDO "false"
|
||||
+#endif
|
||||
|
||||
+class SuProcess::SuProcessPrivate
|
||||
+{
|
||||
+public:
|
||||
+ bool m_useSudo;
|
||||
+};
|
||||
|
||||
SuProcess::SuProcess(const QCString &user, const QCString &command)
|
||||
{
|
||||
m_User = user;
|
||||
m_Command = command;
|
||||
+ d = new SuProcess::SuProcessPrivate();
|
||||
+ d->m_useSudo = false;
|
||||
}
|
||||
|
||||
|
||||
SuProcess::~SuProcess()
|
||||
{
|
||||
+ delete d;
|
||||
+}
|
||||
+
|
||||
+void SuProcess::setUseSudo(bool use_sudo)
|
||||
+{
|
||||
+ d->m_useSudo = use_sudo;
|
||||
}
|
||||
|
||||
int SuProcess::checkInstall(const char *password)
|
||||
@@ -65,7 +81,7 @@ int SuProcess::checkNeedPassword()
|
||||
}
|
||||
|
||||
/*
|
||||
- * Execute a command with su(1).
|
||||
+ * Execute a command with su(1) or sudo
|
||||
*/
|
||||
|
||||
int SuProcess::exec(const char *password, int check)
|
||||
@@ -74,14 +90,20 @@ int SuProcess::exec(const char *password
|
||||
setTerminal(true);
|
||||
|
||||
QCStringList args;
|
||||
+ if (d->m_useSudo)
|
||||
+ {
|
||||
+ args += "-S";
|
||||
+ args += "-u";
|
||||
+ }
|
||||
if ((m_Scheduler != SchedNormal) || (m_Priority > 50))
|
||||
args += "root";
|
||||
else
|
||||
args += m_User;
|
||||
- args += "-c";
|
||||
+ if (!d->m_useSudo)
|
||||
+ args += "-c";
|
||||
args += QCString(__KDE_BINDIR) + "/kdesu_stub";
|
||||
|
||||
- if (StubProcess::exec(__PATH_SU, args) < 0)
|
||||
+ if (StubProcess::exec(d->m_useSudo ? __PATH_SUDO : __PATH_SU, args) < 0)
|
||||
{
|
||||
return check ? SuNotFound : -1;
|
||||
}
|
||||
@@ -90,7 +112,8 @@ int SuProcess::exec(const char *password
|
||||
if (ret < 0)
|
||||
{
|
||||
if (!check)
|
||||
- kdError(900) << k_lineinfo << "Conversation with su failed\n";
|
||||
+ kdError(900) << k_lineinfo << "Conversation with " <<
|
||||
+ (d->m_useSudo ? "sudo" : "su") << " failed\n";
|
||||
return ret;
|
||||
}
|
||||
if (check == 2)
|
||||
@@ -98,6 +121,8 @@ int SuProcess::exec(const char *password
|
||||
if (ret == 1)
|
||||
{
|
||||
kill(m_Pid, SIGTERM);
|
||||
+ close(m_Fd);
|
||||
+ m_Fd = -1;
|
||||
waitForChild();
|
||||
}
|
||||
return ret;
|
11
x11/kde/libs3/patches/patch-kdesu_su_h
Normal file
11
x11/kde/libs3/patches/patch-kdesu_su_h
Normal file
@ -0,0 +1,11 @@
|
||||
$OpenBSD: patch-kdesu_su_h,v 1.1 2002/05/15 17:19:44 espie Exp $
|
||||
--- kdesu/su.h.orig Wed May 15 10:47:17 2002
|
||||
+++ kdesu/su.h Wed May 15 11:53:22 2002
|
||||
@@ -44,6 +44,7 @@ public:
|
||||
* Checks if a password is needed.
|
||||
*/
|
||||
int checkNeedPassword();
|
||||
+ void setUseSudo(bool sudo);
|
||||
|
||||
private:
|
||||
int ConverseSU(const char *password);
|
Loading…
x
Reference in New Issue
Block a user