kov changed libgksu/trunk/ChangeLog,
libgksu/trunk/libgksu/gksu-context.c
Gustavo Noronha
kov at costa.debian.org
Sun Sep 18 18:51:09 UTC 2005
Mensagem de log:
* libgksu/gksu-context.c:
- applied a patch to use /proc information to find out the
name of the current child process to check if it was sudo
who returned a failure code or the app we called on Linux
systems; patch and modifications done to it were made by
Michael Vogt and his advice, respectively (Ubuntu's #7517)
-----
Modified: libgksu/trunk/ChangeLog
===================================================================
--- libgksu/trunk/ChangeLog 2005-09-16 23:59:49 UTC (rev 442)
+++ libgksu/trunk/ChangeLog 2005-09-18 18:51:08 UTC (rev 443)
@@ -1,3 +1,12 @@
+2005-09-18 Gustavo Noronha Silva <kov at debian.org>
+
+ * libgksu/gksu-context.c:
+ - applied a patch to use /proc information to find out the
+ name of the current child process to check if it was sudo
+ who returned a failure code or the app we called on Linux
+ systems; patch and modifications done to it were made by
+ Michael Vogt and his advice, respectively (Ubuntu's #7517)
+
2005-09-12 Gustavo Noronha Silva <kov at debian.org>
* libgksu/gksu-context.c:
Modified: libgksu/trunk/libgksu/gksu-context.c
===================================================================
--- libgksu/trunk/libgksu/gksu-context.c 2005-09-16 23:59:49 UTC (rev 442)
+++ libgksu/trunk/libgksu/gksu-context.c 2005-09-18 18:51:08 UTC (rev 443)
@@ -413,6 +413,29 @@
return etype;
}
+static gchar *
+get_process_name (pid_t pid)
+{
+#ifdef linux
+ FILE *f;
+ char *cmdline = malloc (sizeof(gchar*)*256);
+ char *cmdfile = g_strdup_printf("/proc/%i/status",pid);
+
+ cmdline[255] = '\0';
+
+ f = fopen(cmdfile, "r");
+ if(f != NULL)
+ {
+ fgets(cmdline, 255, f);
+ cmdline[255] = '\0';
+ fclose(f);
+ }
+ return cmdline;
+#else
+ return NULL;
+#endif
+}
+
/**
* prepare_xauth:
*
@@ -1361,7 +1384,7 @@
}
else
{
- gboolean auth_failed = FALSE;
+ gchar *cmdline = NULL;
// Parent
close(parent_pipe[1]);
@@ -1451,6 +1474,10 @@
while (!waitpid (pid, &status, WNOHANG))
{
+ cmdline = get_process_name (pid);
+
+ usleep(1000);
+
bzero(buffer, 256);
if(!fgets (buffer, 255, infile))
break;
@@ -1472,7 +1499,26 @@
if (WIFEXITED(status))
{
if (WEXITSTATUS(status))
- return TRUE;
+ {
+ if(cmdline)
+ {
+ /* sudo already exec()ed something else, don't report
+ * exit status errors in that case
+ */
+ if (!g_str_has_suffix (cmdline, "sudo\n"))
+ {
+ g_free (cmdline);
+ return TRUE;
+ }
+ g_free (cmdline);
+ }
+
+ if (error == NULL)
+ g_set_error (error, gksu_quark,
+ GKSU_CONTEXT_ERROR_CHILDFAILED,
+ _("sudo terminated with %d status"),
+ WEXITSTATUS(status));
+ }
}
}
More information about the gksu-commits
mailing list