kov changed libgksu/trunk/ChangeLog, libgksu/trunk/configure.ac, libgksu/trunk/libgksu/gksu-run-helper.c, libgksu/trunk/libgksu/libgksu.c, libgksu/trunk/libgksu/libgksu.h
Gustavo Noronha
kov at alioth.debian.org
Sun Feb 22 19:48:26 UTC 2009
Mensagem de log:
patch by Joshua Kwan <jkwan at vmware.com> to make provide a way of retuning the same error code as the child
-----
Modified: libgksu/trunk/ChangeLog
===================================================================
--- libgksu/trunk/ChangeLog 2009-02-03 12:30:27 UTC (rev 832)
+++ libgksu/trunk/ChangeLog 2009-02-22 19:48:26 UTC (rev 833)
@@ -1,3 +1,9 @@
+2009-02-22 Gustavo Noronha Silva <kov at debian.org>
+
+ * configure.ac, libgksu/libgksu.{c,h}, libgksu/gksu-run-helper.c:
+ - accepted patch by Joshua Kwan <jkwan at vmware.com> to
+ return the same status code as the child
+
2009-02-03 Gustavo Noronha Silva <kov at debian.org>
* configure.ac:
Modified: libgksu/trunk/configure.ac
===================================================================
--- libgksu/trunk/configure.ac 2009-02-03 12:30:27 UTC (rev 832)
+++ libgksu/trunk/configure.ac 2009-02-22 19:48:26 UTC (rev 833)
@@ -3,7 +3,7 @@
AC_PREREQ(2.57)
-AC_INIT(libgksu, 2.0.7, kov at debian.org)
+AC_INIT(libgksu, 2.0.8, kov at debian.org)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
AC_CONFIG_SRCDIR(libgksu/libgksu.c)
AM_CONFIG_HEADER(config.h)
Modified: libgksu/trunk/libgksu/gksu-run-helper.c
===================================================================
--- libgksu/trunk/libgksu/gksu-run-helper.c 2009-02-03 12:30:27 UTC (rev 832)
+++ libgksu/trunk/libgksu/gksu-run-helper.c 2009-02-22 19:48:26 UTC (rev 833)
@@ -25,6 +25,7 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/wait.h>
#include <glib.h>
@@ -173,6 +174,11 @@
clean_dir (xauth_dir);
g_string_free(s, TRUE);
- return return_code;
+ if (WIFEXITED(return_code))
+ {
+ return WEXITSTATUS(return_code);
+ } else if (WIFSIGNALED(return_code)) {
+ return -1;
+ }
}
}
Modified: libgksu/trunk/libgksu/libgksu.c
===================================================================
--- libgksu/trunk/libgksu/libgksu.c 2009-02-03 12:30:27 UTC (rev 832)
+++ libgksu/trunk/libgksu/libgksu.c 2009-02-22 19:48:26 UTC (rev 833)
@@ -1850,10 +1850,47 @@
}
+/**
+ * gksu_su_full:
+ * @context: a #GksuContext
+ * @ask_pass: a #GksuAskPassFunc to be called when the lib determines
+ * requesting a password is necessary; it may be NULL, in which case
+ * the standard password request dialog will be used
+ * @ask_pass_data: a #gpointer with user data to be passed to the
+ * #GksuAskPasswordFunc
+ * @pass_not_needed: a #GksuPassNotNeededFunc that will be called
+ * when the command is being run without the need for requesting
+ * a password; it will only be called if the display-no-pass-info
+ * gconf key is enabled; NULL will have the standard dialog be shown
+ * @pass_not_needed_data: a #gpointer with the user data to be passed to the
+ * #GksuPasswordNotNeededFunc
+ * @error: a #GError object to be filled with the error code or NULL
+ *
+ * This is a compatibility shim over gksu_su_fuller, which, for
+ * compatibility reasons, lacks the 'exit_status' argument. You should
+ * check the documentation for gksu_su_fuller for information about
+ * the arguments.
+ *
+ * Returns: TRUE if all went fine, FALSE if failed
+ */
+gboolean
+gksu_su_full (GksuContext *context,
+ GksuAskPassFunc ask_pass,
+ gpointer ask_pass_data,
+ GksuPassNotNeededFunc pass_not_needed,
+ gpointer pass_not_needed_data,
+ GError **error)
+{
+ return gksu_su_fuller(context,
+ ask_pass, ask_pass_data,
+ pass_not_needed, pass_not_needed_data,
+ NULL, error);
+}
+
/**
- * gksu_su_full:
+ * gksu_su_fuller:
* @context: a #GksuContext
* @ask_pass: a #GksuAskPassFunc to be called when the lib determines
* requesting a password is necessary; it may be NULL, in which case
@@ -1866,6 +1903,8 @@
* gconf key is enabled; NULL will have the standard dialog be shown
* @pass_not_needed_data: a #gpointer with the user data to be passed to the
* #GksuPasswordNotNeededFunc
+ * @exit_status: an optional pointer to a #gint8 which will be filled with
+ * the exit status of the child process
* @error: a #GError object to be filled with the error code or NULL
*
* This could be considered one of the main functions in GKSu.
@@ -1880,12 +1919,13 @@
* Returns: TRUE if all went fine, FALSE if failed
*/
gboolean
-gksu_su_full (GksuContext *context,
- GksuAskPassFunc ask_pass,
- gpointer ask_pass_data,
- GksuPassNotNeededFunc pass_not_needed,
- gpointer pass_not_needed_data,
- GError **error)
+gksu_su_fuller (GksuContext *context,
+ GksuAskPassFunc ask_pass,
+ gpointer ask_pass_data,
+ GksuPassNotNeededFunc pass_not_needed,
+ gpointer pass_not_needed_data,
+ gint8 *exit_status,
+ GError **error)
{
GQuark gksu_quark;
int i = 0;
@@ -2257,6 +2297,15 @@
if (pid_exited != pid)
waitpid(pid, &status, 0);
+ if (exit_status)
+ {
+ if (WIFEXITED(status)) {
+ *exit_status = WEXITSTATUS(status);
+ } else if (WIFSIGNALED(status)) {
+ *exit_status = -1;
+ }
+ }
+
if (WEXITSTATUS(status))
{
if(cmdline)
@@ -2347,6 +2396,46 @@
* #GksuPasswordNotNeededFunc
* @error: a #GError object to be filled with the error code or NULL
*
+ * This is a compatibility shim over gksu_sudo_fuller, which, for
+ * compatibility reasons, lacks the 'exit_status' argument. You should
+ * check the documentation for gksu_sudo_fuller for information about
+ * the arguments.
+ *
+ * Returns: TRUE if all went fine, FALSE if failed
+ */
+
+gboolean
+gksu_sudo_full (GksuContext *context,
+ GksuAskPassFunc ask_pass,
+ gpointer ask_pass_data,
+ GksuPassNotNeededFunc pass_not_needed,
+ gpointer pass_not_needed_data,
+ GError **error)
+{
+ return gksu_sudo_fuller(context,
+ ask_pass, ask_pass_data,
+ pass_not_needed, pass_not_needed_data,
+ NULL, error);
+}
+
+/**
+ * gksu_sudo_fuller:
+ * @context: a #GksuContext
+ * @ask_pass: a #GksuAskPassFunc to be called when the lib determines
+ * requesting a password is necessary; it may be NULL, in which case
+ * the standard password request dialog will be used
+ * @ask_pass_data: a #gpointer with user data to be passed to the
+ * #GksuAskPasswordFunc
+ * @pass_not_needed: a #GksuPassNotNeededFunc that will be called
+ * when the command is being run without the need for requesting
+ * a password; it will only be called if the display-no-pass-info
+ * gconf key is enabled; NULL will have the standard dialog be shown
+ * @pass_not_needed_data: a #gpointer with the user data to be passed to the
+ * #GksuPasswordNotNeededFunc
+ * @error: a #GError object to be filled with the error code or NULL
+ * @exit_status: an optional pointer to a #gint8 which will be filled with
+ * the exit status of the child process
+ *
* This could be considered one of the main functions in GKSu.
* it is responsible for doing the 'user changing' magic calling
* the #GksuAskPassFunc function to request a password if needed.
@@ -2359,12 +2448,13 @@
* Returns: TRUE if all went fine, FALSE if failed
*/
gboolean
-gksu_sudo_full (GksuContext *context,
- GksuAskPassFunc ask_pass,
- gpointer ask_pass_data,
- GksuPassNotNeededFunc pass_not_needed,
- gpointer pass_not_needed_data,
- GError **error)
+gksu_sudo_fuller (GksuContext *context,
+ GksuAskPassFunc ask_pass,
+ gpointer ask_pass_data,
+ GksuPassNotNeededFunc pass_not_needed,
+ gpointer pass_not_needed_data,
+ gint8 *exit_status,
+ GError **error)
{
char **cmd;
char buffer[256] = {0};
@@ -2759,6 +2849,15 @@
waitpid(pid, &status, 0);
sudo_reset_xauth (context, xauth, xauth_env);
+ if (exit_status)
+ {
+ if (WIFEXITED(status)) {
+ *exit_status = WEXITSTATUS(status);
+ } else if (WIFSIGNALED(status)) {
+ *exit_status = -1;
+ }
+ }
+
if (WEXITSTATUS(status))
{
if(cmdline)
@@ -2835,13 +2934,12 @@
* #GksuPasswordNotNeededFunc
* @error: a #GError object to be filled with the error code or NULL
*
- * This function is a wrapper for gksu_sudo_full/gksu_su_full. It will
- * call one of them, depending on the GConf key that defines whether
- * the default behavior for gksu is su or sudo mode. This is the
- * recommended way of using the library functionality.
+ * This is a compatibility shim over gksu_run_fuller, which, for
+ * compatibility reasons, lacks the 'exit_status' argument.
*
* Returns: TRUE if all went fine, FALSE if failed
*/
+
gboolean
gksu_run_full (GksuContext *context,
GksuAskPassFunc ask_pass,
@@ -2850,6 +2948,46 @@
gpointer pass_not_needed_data,
GError **error)
{
+ return gksu_run_fuller(context,
+ ask_pass, ask_pass_data,
+ pass_not_needed, pass_not_needed_data,
+ NULL, error);
+}
+
+/**
+ * gksu_run_fuller:
+ * @context: a #GksuContext
+ * @ask_pass: a #GksuAskPassFunc to be called when the lib determines
+ * requesting a password is necessary; it may be NULL, in which case
+ * the standard password request dialog will be used
+ * @ask_pass_data: a #gpointer with user data to be passed to the
+ * #GksuAskPasswordFunc
+ * @pass_not_needed: a #GksuPassNotNeededFunc that will be called
+ * when the command is being run without the need for requesting
+ * a password; it will only be called if the display-no-pass-info
+ * gconf key is enabled; NULL will have the standard dialog be shown
+ * @pass_not_needed_data: a #gpointer with the user data to be passed to the
+ * #GksuPasswordNotNeededFunc
+ * @exit_status: an optional pointer to a #gint8 which will be filled with
+ * the exit status of the child process
+ * @error: a #GError object to be filled with the error code or NULL
+ *
+ * This function is a wrapper for gksu_sudo_full/gksu_su_full. It will
+ * call one of them, depending on the GConf key that defines whether
+ * the default behavior for gksu is su or sudo mode. This is the
+ * recommended way of using the library functionality.
+ *
+ * Returns: TRUE if all went fine, FALSE if failed
+ */
+gboolean
+gksu_run_fuller (GksuContext *context,
+ GksuAskPassFunc ask_pass,
+ gpointer ask_pass_data,
+ GksuPassNotNeededFunc pass_not_needed,
+ gpointer pass_not_needed_data,
+ gint8 *exit_status,
+ GError **error)
+{
GConfClient *gconf_client;
gboolean sudo_mode;
@@ -2859,13 +2997,13 @@
g_object_unref (gconf_client);
if (sudo_mode)
- return gksu_sudo_full (context, ask_pass, ask_pass_data,
- pass_not_needed, pass_not_needed_data,
- error);
+ return gksu_sudo_fuller (context, ask_pass, ask_pass_data,
+ pass_not_needed, pass_not_needed_data,
+ exit_status, error);
- return gksu_su_full (context, ask_pass, ask_pass_data,
- pass_not_needed, pass_not_needed_data,
- error);
+ return gksu_su_fuller (context, ask_pass, ask_pass_data,
+ pass_not_needed, pass_not_needed_data,
+ exit_status, error);
}
/**
Modified: libgksu/trunk/libgksu/libgksu.h
===================================================================
--- libgksu/trunk/libgksu/libgksu.h 2009-02-03 12:30:27 UTC (rev 832)
+++ libgksu/trunk/libgksu/libgksu.h 2009-02-22 19:48:26 UTC (rev 833)
@@ -182,6 +182,15 @@
gksu_context_free (GksuContext *context);
gboolean
+gksu_su_fuller (GksuContext *context,
+ GksuAskPassFunc ask_pass,
+ gpointer ask_pass_data,
+ GksuPassNotNeededFunc pass_not_needed,
+ gpointer pass_not_needed_data,
+ gint8 *exit_status,
+ GError **error);
+
+gboolean
gksu_su_full (GksuContext *context,
GksuAskPassFunc ask_pass,
gpointer ask_pass_data,
@@ -194,6 +203,15 @@
GError **error);
gboolean
+gksu_sudo_fuller (GksuContext *context,
+ GksuAskPassFunc ask_pass,
+ gpointer ask_pass_data,
+ GksuPassNotNeededFunc pass_not_needed,
+ gpointer pass_not_needed_data,
+ gint8 *exit_status,
+ GError **error);
+
+gboolean
gksu_sudo_full (GksuContext *context,
GksuAskPassFunc ask_pass,
gpointer ask_pass_data,
@@ -205,6 +223,14 @@
gksu_sudo (gchar *command_line,
GError **error);
+gboolean
+gksu_run_fuller (GksuContext *context,
+ GksuAskPassFunc ask_pass,
+ gpointer ask_pass_data,
+ GksuPassNotNeededFunc pass_not_needed,
+ gpointer pass_not_needed_data,
+ gint8 *exit_status,
+ GError **error);
gboolean
gksu_run_full (GksuContext *context,
More information about the gksu-commits
mailing list