0ec613faa4
This is the new generation of gksu, a simple utility to run programs as root, even in X-based environments. This version uses the new libgksu-polkit library, which uses PolicyKit for authorization purposes and a D-Bus service to actually perform the work. ok jasper@
242 lines
8.6 KiB
Plaintext
242 lines
8.6 KiB
Plaintext
$OpenBSD: patch-mechanism_gksu-controller_c,v 1.1.1.1 2010/09/22 05:16:56 ajacoutot Exp $
|
|
|
|
Prevent stdin, stdout and stderr definitions clash.
|
|
|
|
--- mechanism/gksu-controller.c.orig Sat Jan 30 17:38:25 2010
|
|
+++ mechanism/gksu-controller.c Mon Sep 20 11:51:12 2010
|
|
@@ -50,13 +50,13 @@ struct _GksuControllerPrivate {
|
|
* control a process after Spawn; it is generated by GksuServer */
|
|
guint32 cookie;
|
|
|
|
- GIOChannel *stdin;
|
|
+ GIOChannel *gksu_stdin;
|
|
guint stdin_source_id;
|
|
|
|
- GIOChannel *stdout;
|
|
+ GIOChannel *gksu_stdout;
|
|
guint stdout_source_id;
|
|
|
|
- GIOChannel *stderr;
|
|
+ GIOChannel *gksu_stderr;
|
|
guint stderr_source_id;
|
|
};
|
|
|
|
@@ -98,25 +98,25 @@ static void gksu_controller_finalize(GObject *object)
|
|
GksuController *self = GKSU_CONTROLLER(object);
|
|
GksuControllerPrivate *priv = self->priv;
|
|
|
|
- if(priv->stdin)
|
|
+ if(priv->gksu_stdin)
|
|
{
|
|
g_source_remove(priv->stdin_source_id);
|
|
- g_io_channel_shutdown(priv->stdin, FALSE, NULL);
|
|
- g_io_channel_unref(priv->stdin);
|
|
+ g_io_channel_shutdown(priv->gksu_stdin, FALSE, NULL);
|
|
+ g_io_channel_unref(priv->gksu_stdin);
|
|
}
|
|
|
|
- if(priv->stdout)
|
|
+ if(priv->gksu_stdout)
|
|
{
|
|
g_source_remove(priv->stdout_source_id);
|
|
- g_io_channel_shutdown(priv->stdout, FALSE, NULL);
|
|
- g_io_channel_unref(priv->stdout);
|
|
+ g_io_channel_shutdown(priv->gksu_stdout, FALSE, NULL);
|
|
+ g_io_channel_unref(priv->gksu_stdout);
|
|
}
|
|
|
|
- if(priv->stderr)
|
|
+ if(priv->gksu_stderr)
|
|
{
|
|
g_source_remove(priv->stderr_source_id);
|
|
- g_io_channel_shutdown(priv->stderr, FALSE, NULL);
|
|
- g_io_channel_unref(priv->stderr);
|
|
+ g_io_channel_shutdown(priv->gksu_stderr, FALSE, NULL);
|
|
+ g_io_channel_unref(priv->gksu_stderr);
|
|
}
|
|
|
|
g_free(priv->working_directory);
|
|
@@ -166,7 +166,7 @@ static void gksu_controller_process_exited_cb(GPid pid
|
|
g_signal_emit(self, signals[PROCESS_EXITED], 0, status);
|
|
}
|
|
|
|
-static gboolean gksu_controller_stdin_hangup_cb(GIOChannel *stdin,
|
|
+static gboolean gksu_controller_stdin_hangup_cb(GIOChannel *gksu_stdin,
|
|
GIOCondition condition,
|
|
GksuController *self)
|
|
{
|
|
@@ -181,7 +181,7 @@ static gboolean gksu_controller_stdin_hangup_cb(GIOCha
|
|
return FALSE;
|
|
}
|
|
|
|
-static gboolean gksu_controller_stdout_ready_to_read_cb(GIOChannel *stdout,
|
|
+static gboolean gksu_controller_stdout_ready_to_read_cb(GIOChannel *gksu_stdout,
|
|
GIOCondition condition,
|
|
GksuController *self)
|
|
{
|
|
@@ -202,7 +202,7 @@ static gboolean gksu_controller_stdout_ready_to_read_c
|
|
return FALSE;
|
|
}
|
|
|
|
-static gboolean gksu_controller_stderr_ready_to_read_cb(GIOChannel *stderr,
|
|
+static gboolean gksu_controller_stderr_ready_to_read_cb(GIOChannel *gksu_stderr,
|
|
GIOCondition condition,
|
|
GksuController *self)
|
|
{
|
|
@@ -271,8 +271,8 @@ static gboolean gksu_controller_prepare_xauth(GksuCont
|
|
/* actually create the real file */
|
|
if (g_file_test("/usr/bin/xauth", G_FILE_TEST_IS_EXECUTABLE))
|
|
xauth_bin = "/usr/bin/xauth";
|
|
- else if (g_file_test("/usr/X11R6/bin/xauth", G_FILE_TEST_IS_EXECUTABLE))
|
|
- xauth_bin = "/usr/X11R6/bin/xauth";
|
|
+ else if (g_file_test("${X11BASE}/bin/xauth", G_FILE_TEST_IS_EXECUTABLE))
|
|
+ xauth_bin = "${X11BASE}/bin/xauth";
|
|
else
|
|
{
|
|
unlink(tmpfilename);
|
|
@@ -333,9 +333,9 @@ GksuController* gksu_controller_run(GksuController *se
|
|
|
|
/* the pointers are just to allow us to only pass in fds in which
|
|
* our caller is interested */
|
|
- gint *stdin = NULL;
|
|
- gint *stdout = NULL;
|
|
- gint *stderr = NULL;
|
|
+ gint *gksu_stdin = NULL;
|
|
+ gint *gksu_stdout = NULL;
|
|
+ gint *gksu_stderr = NULL;
|
|
gint stdin_real, stdout_real, stderr_real;
|
|
|
|
GError *internal_error = NULL;
|
|
@@ -383,21 +383,21 @@ GksuController* gksu_controller_run(GksuController *se
|
|
* g_spawn_async_with_pipes handles it correctly
|
|
*/
|
|
if(using_stdin)
|
|
- stdin = &stdin_real;
|
|
+ gksu_stdin = &stdin_real;
|
|
|
|
if(using_stdout)
|
|
- stdout = &stdout_real;
|
|
+ gksu_stdout = &stdout_real;
|
|
else
|
|
spawn_flags |= G_SPAWN_STDOUT_TO_DEV_NULL;
|
|
|
|
if(using_stderr)
|
|
- stderr = &stderr_real;
|
|
+ gksu_stderr = &stderr_real;
|
|
else
|
|
spawn_flags |= G_SPAWN_STDERR_TO_DEV_NULL;
|
|
|
|
g_spawn_async_with_pipes(priv->working_directory, priv->arguments, environmentv,
|
|
spawn_flags, NULL, NULL, pid,
|
|
- stdin, stdout, stderr, &internal_error);
|
|
+ gksu_stdin, gksu_stdout, gksu_stderr, &internal_error);
|
|
g_strfreev(environmentv);
|
|
|
|
if(internal_error)
|
|
@@ -414,34 +414,34 @@ GksuController* gksu_controller_run(GksuController *se
|
|
*/
|
|
if(stdin)
|
|
{
|
|
- priv->stdin = g_io_channel_unix_new(stdin_real);
|
|
- g_io_channel_set_encoding(priv->stdin, NULL, NULL);
|
|
- g_io_channel_set_buffered(priv->stdin, FALSE);
|
|
+ priv->gksu_stdin = g_io_channel_unix_new(stdin_real);
|
|
+ g_io_channel_set_encoding(priv->gksu_stdin, NULL, NULL);
|
|
+ g_io_channel_set_buffered(priv->gksu_stdin, FALSE);
|
|
priv->stdin_source_id =
|
|
- g_io_add_watch(priv->stdin, G_IO_HUP|G_IO_NVAL,
|
|
+ g_io_add_watch(priv->gksu_stdin, G_IO_HUP|G_IO_NVAL,
|
|
(GIOFunc)gksu_controller_stdin_hangup_cb,
|
|
(gpointer)self);
|
|
}
|
|
|
|
if(stdout)
|
|
{
|
|
- priv->stdout = g_io_channel_unix_new(stdout_real);
|
|
- g_io_channel_set_flags(priv->stdout, G_IO_FLAG_NONBLOCK, NULL);
|
|
+ priv->gksu_stdout = g_io_channel_unix_new(stdout_real);
|
|
+ g_io_channel_set_flags(priv->gksu_stdout, G_IO_FLAG_NONBLOCK, NULL);
|
|
/* the child may output binary data; we don't care */
|
|
- g_io_channel_set_encoding(priv->stdout, NULL, NULL);
|
|
+ g_io_channel_set_encoding(priv->gksu_stdout, NULL, NULL);
|
|
priv->stdout_source_id =
|
|
- g_io_add_watch(priv->stdout, G_IO_IN|G_IO_PRI|G_IO_HUP,
|
|
+ g_io_add_watch(priv->gksu_stdout, G_IO_IN|G_IO_PRI|G_IO_HUP,
|
|
(GIOFunc)gksu_controller_stdout_ready_to_read_cb,
|
|
(gpointer)self);
|
|
}
|
|
|
|
if(stderr)
|
|
{
|
|
- priv->stderr = g_io_channel_unix_new(stderr_real);
|
|
- g_io_channel_set_flags(priv->stderr, G_IO_FLAG_NONBLOCK, NULL);
|
|
- g_io_channel_set_encoding(priv->stderr, NULL, NULL);
|
|
+ priv->gksu_stderr = g_io_channel_unix_new(stderr_real);
|
|
+ g_io_channel_set_flags(priv->gksu_stderr, G_IO_FLAG_NONBLOCK, NULL);
|
|
+ g_io_channel_set_encoding(priv->gksu_stderr, NULL, NULL);
|
|
priv->stderr_source_id =
|
|
- g_io_add_watch(priv->stderr, G_IO_IN|G_IO_PRI|G_IO_HUP,
|
|
+ g_io_add_watch(priv->gksu_stderr, G_IO_IN|G_IO_PRI|G_IO_HUP,
|
|
(GIOFunc)gksu_controller_stderr_ready_to_read_cb,
|
|
(gpointer)self);
|
|
}
|
|
@@ -484,13 +484,13 @@ void gksu_controller_close_fd(GksuController *self, gi
|
|
switch(fd)
|
|
{
|
|
case 0:
|
|
- channel = priv->stdin;
|
|
+ channel = priv->gksu_stdin;
|
|
break;
|
|
case 1:
|
|
- channel = priv->stdout;
|
|
+ channel = priv->gksu_stdout;
|
|
break;
|
|
case 2:
|
|
- channel = priv->stderr;
|
|
+ channel = priv->gksu_stderr;
|
|
break;
|
|
default:
|
|
fprintf(stderr, "Trying to close invalid FD '%d' for PID '%d'\n",
|
|
@@ -526,12 +526,12 @@ gchar* gksu_controller_read_output(GksuController *sel
|
|
switch(fd)
|
|
{
|
|
case 1:
|
|
- channel = priv->stdout;
|
|
+ channel = priv->gksu_stdout;
|
|
source_id = &(priv->stdout_source_id);
|
|
handler_func = (GIOFunc)gksu_controller_stdout_ready_to_read_cb;
|
|
break;
|
|
case 2:
|
|
- channel = priv->stderr;
|
|
+ channel = priv->gksu_stderr;
|
|
source_id = &(priv->stderr_source_id);
|
|
handler_func = (GIOFunc)gksu_controller_stderr_ready_to_read_cb;
|
|
break;
|
|
@@ -588,7 +588,7 @@ gboolean gksu_controller_write_input(GksuController *s
|
|
const gsize length, GError **error)
|
|
{
|
|
GksuControllerPrivate *priv = self->priv;
|
|
- GIOChannel *channel = priv->stdin;
|
|
+ GIOChannel *channel = priv->gksu_stdin;
|
|
GError *internal_error = NULL;
|
|
gsize bytes_written =0;
|
|
gsize bytes_left = length;
|
|
@@ -616,7 +616,7 @@ gboolean gksu_controller_is_using_stdout(GksuControlle
|
|
{
|
|
GksuControllerPrivate *priv = self->priv;
|
|
|
|
- if(priv->stdout)
|
|
+ if(priv->gksu_stdout)
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
@@ -626,7 +626,7 @@ gboolean gksu_controller_is_using_stderr(GksuControlle
|
|
{
|
|
GksuControllerPrivate *priv = self->priv;
|
|
|
|
- if(priv->stderr)
|
|
+ if(priv->gksu_stderr)
|
|
return TRUE;
|
|
|
|
return FALSE;
|