kov changed libgksu/branches/libgksu2/ChangeLog, libgksu/branches/libgksu2/Makefile.am, libgksu/branches/libgksu2/aclocal.m4, libgksu/branches/libgksu2/configure.ac, libgksu/branches/libgksu2/docs/libgksu1.2-undocumented.txt, libgksu/branches/libgksu2/docs/tmpl/gksu-context.sgml, libgksu/branches/libgksu2/docs/tmpl/libgksu1.2-unused.sgml, libgksu/branches/libgksu2/gksu.schemas.in, libgksu/branches/libgksu2/libgksu/Makefile.am, libgksu/branches/libgksu2/libgksu/gksu-context.c, libgksu/branches/libgksu2/libgksu/gksu-context.h, libgksu/branches/libgksu2/libgksu/test-gksu.c, libgksu/branches/libgksu2/libgksuui/ChangeLog, libgksu/branches/libgksu2/libgksuui/Makefile.am

Gustavo Noronha kov at costa.debian.org
Sun Dec 11 23:14:20 UTC 2005


Mensagem de log: 
	* Major design overhaul
	- incorporating libgksuui
	- no longer try to be UI independent; use GTK+ mercylessly
	- incorporating gconf schema and settings handling
	- massive API review, removal of most public functions;
	  GksuContext is no longer a GObject-based object, no longer
	  has many accessor functions for its data fields and is
	  needed for the _full versions of the main API functions
	  right now; this allows saner handling of password prompting
	  and housekeeping



-----


Modified: libgksu/branches/libgksu2/ChangeLog
===================================================================
--- libgksu/branches/libgksu2/ChangeLog	2005-12-03 13:25:43 UTC (rev 486)
+++ libgksu/branches/libgksu2/ChangeLog	2005-12-11 23:14:16 UTC (rev 487)
@@ -1,3 +1,16 @@
+2005-12-11  Gustavo Noronha Silva  <kov at debian.org>
+
+	* Major design overhaul
+	- incorporating libgksuui
+	- no longer try to be UI independent; use GTK+ mercylessly
+	- incorporating gconf schema and settings handling
+	- massive API review, removal of most public functions;
+	  GksuContext is no longer a GObject-based object, no longer
+	  has many accessor functions for its data fields and is
+	  needed for the _full versions of the main API functions
+	  right now; this allows saner handling of password prompting
+	  and housekeeping
+
 2005-11-23  Gustavo Noronha Silva  <kov at debian.org>
 
 	* Release 1.3.7

Modified: libgksu/branches/libgksu2/Makefile.am
===================================================================
--- libgksu/branches/libgksu2/Makefile.am	2005-12-03 13:25:43 UTC (rev 486)
+++ libgksu/branches/libgksu2/Makefile.am	2005-12-11 23:14:16 UTC (rev 487)
@@ -2,9 +2,25 @@
 
 DISTCLEANFILES = *~
 
-SUBDIRS = m4 intl po libgksu docs
+SUBDIRS = m4 intl po libgksuui libgksu docs
 DIST_SUBDIRS = $(SUBDIRS)
 
 ACLOCAL_AMFLAGS = -I m4
 
-EXTRA_DIST = config.rpath mkinstalldirs
+schemasdir       = $(GCONF_SCHEMA_FILE_DIR)
+schemas_in_files = gksu.schemas.in
+schemas_DATA     = $(schemas_in_files:.schemas.in=.schemas)
+ at INTLTOOL_SCHEMAS_RULE@
+
+EXTRA_DIST = config.rpath mkinstalldirs gksu.schemas.in
+
+if GCONF_SCHEMAS_INSTALL
+install-data-local:
+        if test -z "$(DESTDIR)" ; then \
+          for p in $(schemas_DATA) ; do \
+            GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(srcdir)/$$p ; \
+          done \
+        fi
+else
+install-data-local:
+endif

Modified: libgksu/branches/libgksu2/aclocal.m4
===================================================================
--- libgksu/branches/libgksu2/aclocal.m4	2005-12-03 13:25:43 UTC (rev 486)
+++ libgksu/branches/libgksu2/aclocal.m4	2005-12-11 23:14:16 UTC (rev 487)
@@ -13050,6 +13050,203 @@
 AC_MSG_RESULT([$SED])
 ])
 
+# Configure paths for GTK+
+# Owen Taylor     1997-2001
+
+dnl AM_PATH_GTK_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
+dnl Test for GTK+, and define GTK_CFLAGS and GTK_LIBS, if gthread is specified in MODULES, 
+dnl pass to pkg-config
+dnl
+AC_DEFUN([AM_PATH_GTK_2_0],
+[dnl 
+dnl Get the cflags and libraries from pkg-config
+dnl
+AC_ARG_ENABLE(gtktest, [  --disable-gtktest       do not try to compile and run a test GTK+ program],
+		    , enable_gtktest=yes)
+
+  pkg_config_args=gtk+-2.0
+  for module in . $4
+  do
+      case "$module" in
+         gthread) 
+             pkg_config_args="$pkg_config_args gthread-2.0"
+         ;;
+      esac
+  done
+
+  no_gtk=""
+
+  AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
+
+  if test x$PKG_CONFIG != xno ; then
+    if pkg-config --atleast-pkgconfig-version 0.7 ; then
+      :
+    else
+      echo "*** pkg-config too old; version 0.7 or better required."
+      no_gtk=yes
+      PKG_CONFIG=no
+    fi
+  else
+    no_gtk=yes
+  fi
+
+  min_gtk_version=ifelse([$1], ,2.0.0,$1)
+  AC_MSG_CHECKING(for GTK+ - version >= $min_gtk_version)
+
+  if test x$PKG_CONFIG != xno ; then
+    ## don't try to run the test against uninstalled libtool libs
+    if $PKG_CONFIG --uninstalled $pkg_config_args; then
+	  echo "Will use uninstalled version of GTK+ found in PKG_CONFIG_PATH"
+	  enable_gtktest=no
+    fi
+
+    if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args; then
+	  :
+    else
+	  no_gtk=yes
+    fi
+  fi
+
+  if test x"$no_gtk" = x ; then
+    GTK_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags`
+    GTK_LIBS=`$PKG_CONFIG $pkg_config_args --libs`
+    gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
+           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
+    gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
+           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
+    gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
+           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
+    if test "x$enable_gtktest" = "xyes" ; then
+      ac_save_CFLAGS="$CFLAGS"
+      ac_save_LIBS="$LIBS"
+      CFLAGS="$CFLAGS $GTK_CFLAGS"
+      LIBS="$GTK_LIBS $LIBS"
+dnl
+dnl Now check if the installed GTK+ is sufficiently new. (Also sanity
+dnl checks the results of pkg-config to some extent)
+dnl
+      rm -f conf.gtktest
+      AC_TRY_RUN([
+#include <gtk/gtk.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int 
+main ()
+{
+  int major, minor, micro;
+  char *tmp_version;
+
+  system ("touch conf.gtktest");
+
+  /* HP/UX 9 (%@#!) writes to sscanf strings */
+  tmp_version = g_strdup("$min_gtk_version");
+  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
+     printf("%s, bad version string\n", "$min_gtk_version");
+     exit(1);
+   }
+
+  if ((gtk_major_version != $gtk_config_major_version) ||
+      (gtk_minor_version != $gtk_config_minor_version) ||
+      (gtk_micro_version != $gtk_config_micro_version))
+    {
+      printf("\n*** 'pkg-config --modversion gtk+-2.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", 
+             $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
+             gtk_major_version, gtk_minor_version, gtk_micro_version);
+      printf ("*** was found! If pkg-config was correct, then it is best\n");
+      printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
+      printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
+      printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
+      printf("*** required on your system.\n");
+      printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
+      printf("*** to point to the correct configuration files\n");
+    } 
+  else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
+	   (gtk_minor_version != GTK_MINOR_VERSION) ||
+           (gtk_micro_version != GTK_MICRO_VERSION))
+    {
+      printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
+	     GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
+      printf("*** library (version %d.%d.%d)\n",
+	     gtk_major_version, gtk_minor_version, gtk_micro_version);
+    }
+  else
+    {
+      if ((gtk_major_version > major) ||
+        ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
+        ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
+      {
+        return 0;
+       }
+     else
+      {
+        printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
+               gtk_major_version, gtk_minor_version, gtk_micro_version);
+        printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
+	       major, minor, micro);
+        printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
+        printf("***\n");
+        printf("*** If you have already installed a sufficiently new version, this error\n");
+        printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
+        printf("*** being found. The easiest way to fix this is to remove the old version\n");
+        printf("*** of GTK+, but you can also set the PKG_CONFIG environment to point to the\n");
+        printf("*** correct copy of pkg-config. (In this case, you will have to\n");
+        printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
+        printf("*** so that the correct libraries are found at run-time))\n");
+      }
+    }
+  return 1;
+}
+],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
+       CFLAGS="$ac_save_CFLAGS"
+       LIBS="$ac_save_LIBS"
+     fi
+  fi
+  if test "x$no_gtk" = x ; then
+     AC_MSG_RESULT(yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version))
+     ifelse([$2], , :, [$2])     
+  else
+     AC_MSG_RESULT(no)
+     if test "$PKG_CONFIG" = "no" ; then
+       echo "*** A new enough version of pkg-config was not found."
+       echo "*** See http://pkgconfig.sourceforge.net"
+     else
+       if test -f conf.gtktest ; then
+        :
+       else
+          echo "*** Could not run GTK+ test program, checking why..."
+	  ac_save_CFLAGS="$CFLAGS"
+	  ac_save_LIBS="$LIBS"
+          CFLAGS="$CFLAGS $GTK_CFLAGS"
+          LIBS="$LIBS $GTK_LIBS"
+          AC_TRY_LINK([
+#include <gtk/gtk.h>
+#include <stdio.h>
+],      [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
+        [ echo "*** The test program compiled, but did not run. This usually means"
+          echo "*** that the run-time linker is not finding GTK+ or finding the wrong"
+          echo "*** version of GTK+. If it is not finding GTK+, you'll need to set your"
+          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
+          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
+          echo "*** is required on your system"
+	  echo "***"
+          echo "*** If you have an old version installed, it is best to remove it, although"
+          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
+        [ echo "*** The test program failed to compile or link. See the file config.log for the"
+          echo "*** exact error that occured. This usually means GTK+ is incorrectly installed."])
+          CFLAGS="$ac_save_CFLAGS"
+          LIBS="$ac_save_LIBS"
+       fi
+     fi
+     GTK_CFLAGS=""
+     GTK_LIBS=""
+     ifelse([$3], , :, [$3])
+  fi
+  AC_SUBST(GTK_CFLAGS)
+  AC_SUBST(GTK_LIBS)
+  rm -f conf.gtktest
+])
+
 # gettext.m4 serial 28 (gettext-0.13)
 dnl Copyright (C) 1995-2003 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU

Modified: libgksu/branches/libgksu2/configure.ac
===================================================================
--- libgksu/branches/libgksu2/configure.ac	2005-12-03 13:25:43 UTC (rev 486)
+++ libgksu/branches/libgksu2/configure.ac	2005-12-11 23:14:16 UTC (rev 487)
@@ -26,6 +26,8 @@
 AC_PROG_INSTALL
 AC_PROG_LIBTOOL
 
+AM_PATH_GTK_2_0(2.0.0,, AC_MSG_ERROR(Can't find GTK 2.0.0 or better) )
+
 # Checks for library functions.
 ALL_LINGUAS="ca cs da de es eu hu pl pt_BR ro ru sk nb nl"
 
@@ -65,11 +67,13 @@
 
 AC_CONFIG_FILES([
 	Makefile
-	m4/Makefile 
+	m4/Makefile
 	intl/Makefile
 	po/Makefile.in
 	libgksu/Makefile
 	libgksu/libgksu1.2.pc
+	libgksuui/Makefile
+	libgksuui/libgksuui1.1.pc
 	docs/Makefile
 	])
 AC_OUTPUT

Modified: libgksu/branches/libgksu2/docs/libgksu1.2-undocumented.txt
===================================================================
--- libgksu/branches/libgksu2/docs/libgksu1.2-undocumented.txt	2005-12-03 13:25:43 UTC (rev 486)
+++ libgksu/branches/libgksu2/docs/libgksu1.2-undocumented.txt	2005-12-11 23:14:16 UTC (rev 487)
@@ -1,8 +1,10 @@
-100% symbol docs coverage.
-27 symbols documented.
+67% symbol docs coverage.
+4 symbols documented.
 0 symbols incomplete.
-0 not documented.
+2 not documented.
 
 
+gksu_context_free
+gksu_context_new
 
 

Modified: libgksu/branches/libgksu2/docs/tmpl/gksu-context.sgml
===================================================================
--- libgksu/branches/libgksu2/docs/tmpl/gksu-context.sgml	2005-12-03 13:25:43 UTC (rev 486)
+++ libgksu/branches/libgksu2/docs/tmpl/gksu-context.sgml	2005-12-11 23:14:16 UTC (rev 487)
@@ -22,23 +22,6 @@
 <!-- ##### SECTION Stability_Level ##### -->
 
 
-<!-- ##### STRUCT GksuContext ##### -->
-<para>
-
-</para>
-
- at parent: 
- at xauth: 
- at dir: 
- at display: 
- at user: 
- at password: 
- at command: 
- at login_shell: 
- at keep_env: 
- at debug: 
- at ssh_fwd: 
-
 <!-- ##### FUNCTION gksu_context_new ##### -->
 <para>
 
@@ -55,195 +38,3 @@
 @context: 
 
 
-<!-- ##### FUNCTION gksu_context_set_user ##### -->
-<para>
-
-</para>
-
- at context: 
- at username: 
-
-
-<!-- ##### FUNCTION gksu_context_get_user ##### -->
-<para>
-
-</para>
-
- at context: 
- at Returns: 
-
-
-<!-- ##### FUNCTION gksu_context_set_command ##### -->
-<para>
-
-</para>
-
- at context: 
- at command: 
-
-
-<!-- ##### FUNCTION gksu_context_get_command ##### -->
-<para>
-
-</para>
-
- at context: 
- at Returns: 
-
-
-<!-- ##### FUNCTION gksu_context_set_password ##### -->
-<para>
-
-</para>
-
- at context: 
- at password: 
-
-
-<!-- ##### FUNCTION gksu_context_get_password ##### -->
-<para>
-
-</para>
-
- at context: 
- at Returns: 
-
-
-<!-- ##### FUNCTION gksu_context_set_login_shell ##### -->
-<para>
-
-</para>
-
- at context: 
- at value: 
-
-
-<!-- ##### FUNCTION gksu_context_get_login_shell ##### -->
-<para>
-
-</para>
-
- at context: 
- at Returns: 
-
-
-<!-- ##### FUNCTION gksu_context_set_keep_env ##### -->
-<para>
-
-</para>
-
- at context: 
- at value: 
-
-
-<!-- ##### FUNCTION gksu_context_get_keep_env ##### -->
-<para>
-
-</para>
-
- at context: 
- at Returns: 
-
-
-<!-- ##### FUNCTION gksu_context_set_debug ##### -->
-<para>
-
-</para>
-
- at context: 
- at value: 
-
-
-<!-- ##### FUNCTION gksu_context_get_debug ##### -->
-<para>
-
-</para>
-
- at context: 
- at Returns: 
-
-
-<!-- ##### FUNCTION gksu_context_set_ssh_fwd ##### -->
-<para>
-
-</para>
-
- at context: 
- at value: 
-
-
-<!-- ##### FUNCTION gksu_context_get_ssh_fwd ##### -->
-<para>
-
-</para>
-
- at context: 
- at Returns: 
-
-
-<!-- ##### FUNCTION gksu_context_sudo_try_need_password ##### -->
-<para>
-
-</para>
-
- at context: 
- at Returns: 
-
-
-<!-- ##### FUNCTION gksu_context_try_need_password ##### -->
-<para>
-
-</para>
-
- at context: 
- at Returns: 
-
-
-<!-- ##### FUNCTION gksu_context_run_full ##### -->
-<para>
-
-</para>
-
- at context: 
- at ask_pass: 
- at user_data: 
- at pass_not_needed: 
- at pnn_user_data: 
- at error: 
- at Returns: 
-
-
-<!-- ##### FUNCTION gksu_context_run ##### -->
-<para>
-
-</para>
-
- at context: 
- at error: 
- at Returns: 
-
-
-<!-- ##### FUNCTION gksu_context_sudo_run_full ##### -->
-<para>
-
-</para>
-
- at context: 
- at ask_pass: 
- at user_data: 
- at pass_not_needed: 
- at pnn_user_data: 
- at error: 
- at Returns: 
-
-
-<!-- ##### FUNCTION gksu_context_sudo_run ##### -->
-<para>
-
-</para>
-
- at context: 
- at error: 
- at Returns: 
-
-

Modified: libgksu/branches/libgksu2/docs/tmpl/libgksu1.2-unused.sgml
===================================================================
--- libgksu/branches/libgksu2/docs/tmpl/libgksu1.2-unused.sgml	2005-12-03 13:25:43 UTC (rev 486)
+++ libgksu/branches/libgksu2/docs/tmpl/libgksu1.2-unused.sgml	2005-12-11 23:14:16 UTC (rev 487)
@@ -610,6 +610,23 @@
 @debug: 
 @ssh_fwd: 
 
+<!-- ##### STRUCT GksuContext ##### -->
+<para>
+
+</para>
+
+ at parent: 
+ at xauth: 
+ at dir: 
+ at display: 
+ at user: 
+ at password: 
+ at command: 
+ at login_shell: 
+ at keep_env: 
+ at debug: 
+ at ssh_fwd: 
+
 <!-- ##### MACRO HASHWORDBITS ##### -->
 <para>
 
@@ -892,6 +909,22 @@
 @error: 
 @Returns: 
 
+<!-- ##### FUNCTION gksu_context_get_command ##### -->
+<para>
+
+</para>
+
+ at context: 
+ at Returns: 
+
+<!-- ##### FUNCTION gksu_context_get_debug ##### -->
+<para>
+
+</para>
+
+ at context: 
+ at Returns: 
+
 <!-- ##### FUNCTION gksu_context_get_grab ##### -->
 <para>
 
@@ -908,6 +941,22 @@
 @context: 
 @Returns: 
 
+<!-- ##### FUNCTION gksu_context_get_keep_env ##### -->
+<para>
+
+</para>
+
+ at context: 
+ at Returns: 
+
+<!-- ##### FUNCTION gksu_context_get_login_shell ##### -->
+<para>
+
+</para>
+
+ at context: 
+ at Returns: 
+
 <!-- ##### FUNCTION gksu_context_get_message ##### -->
 <para>
 
@@ -916,6 +965,22 @@
 @context: 
 @Returns: 
 
+<!-- ##### FUNCTION gksu_context_get_password ##### -->
+<para>
+
+</para>
+
+ at context: 
+ at Returns: 
+
+<!-- ##### FUNCTION gksu_context_get_ssh_fwd ##### -->
+<para>
+
+</para>
+
+ at context: 
+ at Returns: 
+
 <!-- ##### FUNCTION gksu_context_get_title ##### -->
 <para>
 
@@ -931,6 +996,52 @@
 
 @Returns: 
 
+<!-- ##### FUNCTION gksu_context_get_user ##### -->
+<para>
+
+</para>
+
+ at context: 
+ at Returns: 
+
+<!-- ##### FUNCTION gksu_context_run ##### -->
+<para>
+
+</para>
+
+ at context: 
+ at error: 
+ at Returns: 
+
+<!-- ##### FUNCTION gksu_context_run_full ##### -->
+<para>
+
+</para>
+
+ at context: 
+ at ask_pass: 
+ at user_data: 
+ at pass_not_needed: 
+ at pnn_user_data: 
+ at error: 
+ at Returns: 
+
+<!-- ##### FUNCTION gksu_context_set_command ##### -->
+<para>
+
+</para>
+
+ at context: 
+ at command: 
+
+<!-- ##### FUNCTION gksu_context_set_debug ##### -->
+<para>
+
+</para>
+
+ at context: 
+ at value: 
+
 <!-- ##### FUNCTION gksu_context_set_grab ##### -->
 <para>
 
@@ -947,6 +1058,22 @@
 @context: 
 @icon: 
 
+<!-- ##### FUNCTION gksu_context_set_keep_env ##### -->
+<para>
+
+</para>
+
+ at context: 
+ at value: 
+
+<!-- ##### FUNCTION gksu_context_set_login_shell ##### -->
+<para>
+
+</para>
+
+ at context: 
+ at value: 
+
 <!-- ##### FUNCTION gksu_context_set_message ##### -->
 <para>
 
@@ -956,6 +1083,22 @@
 @format: 
 @Varargs: 
 
+<!-- ##### FUNCTION gksu_context_set_password ##### -->
+<para>
+
+</para>
+
+ at context: 
+ at password: 
+
+<!-- ##### FUNCTION gksu_context_set_ssh_fwd ##### -->
+<para>
+
+</para>
+
+ at context: 
+ at value: 
+
 <!-- ##### FUNCTION gksu_context_set_title ##### -->
 <para>
 
@@ -965,6 +1108,52 @@
 @format: 
 @Varargs: 
 
+<!-- ##### FUNCTION gksu_context_set_user ##### -->
+<para>
+
+</para>
+
+ at context: 
+ at username: 
+
+<!-- ##### FUNCTION gksu_context_sudo_run ##### -->
+<para>
+
+</para>
+
+ at context: 
+ at error: 
+ at Returns: 
+
+<!-- ##### FUNCTION gksu_context_sudo_run_full ##### -->
+<para>
+
+</para>
+
+ at context: 
+ at ask_pass: 
+ at user_data: 
+ at pass_not_needed: 
+ at pnn_user_data: 
+ at error: 
+ at Returns: 
+
+<!-- ##### FUNCTION gksu_context_sudo_try_need_password ##### -->
+<para>
+
+</para>
+
+ at context: 
+ at Returns: 
+
+<!-- ##### FUNCTION gksu_context_try_need_password ##### -->
+<para>
+
+</para>
+
+ at context: 
+ at Returns: 
+
 <!-- ##### FUNCTION gksu_get_conf ##### -->
 <para>
 

Copied: libgksu/branches/libgksu2/gksu.schemas.in (from rev 476, gksu/trunk/gksu/gksu.schemas.in)

Modified: libgksu/branches/libgksu2/libgksu/Makefile.am
===================================================================
--- libgksu/branches/libgksu2/libgksu/Makefile.am	2005-12-03 13:25:43 UTC (rev 486)
+++ libgksu/branches/libgksu2/libgksu/Makefile.am	2005-12-11 23:14:16 UTC (rev 487)
@@ -1,5 +1,5 @@
 AM_CFLAGS = -g -O2 -Wall
-INCLUDES = `pkg-config --cflags glib-2.0`
+INCLUDES = `pkg-config --cflags gtk+-2.0 gconf-2.0`
 AM_CPPFLAGS = -DLOCALEDIR=\"$(datadir)/locale\" -DDATA_DIR=\"$(datadir)\" -DPREFIX=\"$(prefix)\"
 LTPACKAGE = $(shell echo ${PACKAGE} | sed s,.,_,g)
 
@@ -9,7 +9,8 @@
 # major -> breaks backward compatibility (changes to existing ABI)
 # minor -> keeps compatibility (additions to the API)
 # micro -> no change to the API/ABI
-libgksu1_2_la_LDFLAGS = -version-info 0:5:0 -Wl,--version-script=libgksu.ver -Wl,-O1 `pkg-config --libs glib-2.0 gobject-2.0` -lutil
+libgksu1_2_la_LIBADD = ../libgksuui/libgksuui1.0.la
+libgksu1_2_la_LDFLAGS = -version-info 0:5:0 -Wl,--version-script=libgksu.ver -Wl,-O1 `pkg-config --libs gtk+-2.0 gobject-2.0 gconf-2.0` -lutil
 
 noinst_HEADERS = defines.h
 

Modified: libgksu/branches/libgksu2/libgksu/gksu-context.c
===================================================================
--- libgksu/branches/libgksu2/libgksu/gksu-context.c	2005-12-03 13:25:43 UTC (rev 486)
+++ libgksu/branches/libgksu2/libgksu/gksu-context.c	2005-12-11 23:14:16 UTC (rev 487)
@@ -31,384 +31,448 @@
 #include <sys/select.h>
 #include <errno.h>
 
-#include <glib.h>
+#include <gtk/gtk.h>
+#include <gconf/gconf-client.h>
 #include <locale.h>
 
 #include "defines.h"
 #include "../config.h"
 
 #include "gksu-context.h"
+#include "../libgksuui/gksuui-dialog.h"
 
-/* local function declarations */
-static void
-gksu_context_init (GTypeInstance *instance, gpointer g_class);
+#define BASE_PATH "/apps/gksu/"
 
-static void
-gksu_context_dispose (GObject *object);
+/* GLOBALS */
+gboolean print_pass = FALSE;
+gboolean force_grab = FALSE;
+gboolean grab = TRUE;
+gboolean message_changed = FALSE;
+gboolean prompt = FALSE;
+gboolean always_ask_pass = FALSE;
 
-static void
-gksu_context_finalize (GObject *object);
-
-static void
-gksu_context_class_init (GksuContextClass *klass);
-
-void
-nullify_password (GksuContext *context)
+GType
+gksu_error_get_type (void)
 {
-  if (context->password)
-    g_free (context->password);
-  context->password = NULL;
+  static GType etype = 0;
+  if (etype == 0) {
+    static const GEnumValue values[] = {
+      { GKSU_ERROR_HELPER, "GKSU_ERROR_HELPER", "helper" },
+      { GKSU_ERROR_NOCOMMAND, "GKSU_ERROR_NOCOMMAND", "nocommand" },
+      { GKSU_ERROR_NOPASSWORD, "GKSU_ERROR_NOPASSWORD", "nopassword" },
+      { GKSU_ERROR_FORK, "GKSU_ERROR_FORK", "fork" },
+      { GKSU_ERROR_EXEC, "GKSU_ERROR_EXEC", "exec" },
+      { GKSU_ERROR_PIPE, "GKSU_ERROR_PIPE", "pipe" },
+      { GKSU_ERROR_PIPEREAD, "GKSU_ERROR_PIPEREAD", "piperead" },
+      { GKSU_ERROR_WRONGPASS, "GKSU_ERROR_WRONGPASS", "wrongpass" },
+      { GKSU_ERROR_CHILDFAILED, "GKSU_ERROR_CHILDFAILED", "childfailed" },
+      { 0, NULL, NULL }
+    };
+    etype = g_enum_register_static ("GksuError", values);
+  }
+  return etype;
 }
 
-/**
- * gksu_context_new:
- *
- * Creates a new context to use gksu with. You must
- * manually free the context with gksu_context_free
- * after use.
- *
- * Returns: a new #GksuContext.
- */
-GksuContext*
-gksu_context_new ()
+static pid_t
+test_lock(const char* fname)
 {
-  g_type_init ();
-  return (GksuContext*) g_type_create_instance (GKSU_TYPE_CONTEXT);
+   int FD = open(fname, 0);
+   if(FD < 0) {
+      if(errno == ENOENT) {
+	 // File does not exist
+	 return 0;
+      } else {
+	 perror("open");
+	 return(-1);
+      }
+   }
+   struct flock fl;
+   fl.l_type = F_WRLCK;
+   fl.l_whence = SEEK_SET;
+   fl.l_start = 0;
+   fl.l_len = 0;
+   if (fcntl(FD, F_GETLK, &fl) < 0) {
+      g_critical("fcntl error");
+      close(FD);
+      return(-1);
+   }
+   close(FD);
+   // lock is available
+   if(fl.l_type == F_UNLCK)
+      return(0);
+   // file is locked by another process
+   return (fl.l_pid);
 }
 
-/**
- * gksu_context_free:
- * @context: the #GksuContext to be freed.
- *
- * Frees the provided #GksuContext.
- */
-void
-gksu_context_free (GksuContext *context)
+static int
+get_lock(const char *File)
 {
-  g_object_unref (G_OBJECT(context));
-}
+   int FD = open(File,O_RDWR | O_CREAT | O_TRUNC,0640);
+   if (FD < 0)
+   {
+      // Read only .. cant have locking problems there.
+      if (errno == EROFS)
+      {
+	 g_warning(_("Not using locking for read only lock file %s"),File);
+	 return dup(0);       // Need something for the caller to close
+      }
 
-/**
- * gksu_context_set_user:
- * @context: the #GksuContext you want to modify
- * @username: the target username
- *
- * Sets up what user the command will be run as. The default
- * is root, but you can run the command as any user.
- *
- */
-void
-gksu_context_set_user (GksuContext *context, gchar *username)
-{
-  g_assert (username != NULL);
+      // Feh.. We do this to distinguish the lock vs open case..
+      errno = EPERM;
+      return -1;
+   }
+   fcntl(FD,F_SETFD, FD_CLOEXEC);
 
-  if (context->user)
-    g_free (context->user);
-  context->user = g_strdup (username);
-}
+   // Aquire a write lock
+   struct flock fl;
+   fl.l_type = F_WRLCK;
+   fl.l_whence = SEEK_SET;
+   fl.l_start = 0;
+   fl.l_len = 0;
+   if (fcntl(FD,F_SETLK,&fl) == -1)
+   {
+      if (errno == ENOLCK)
+      {
+	 g_warning(_("Not using locking for nfs mounted lock file %s"), File);
+	 unlink(File);
+	 close(FD);
+	 return dup(0);       // Need something for the caller to close
+      }
 
-/**
- * gksu_context_get_user:
- * @context: the #GksuContext from which to grab the information
- *
- * Gets the user the command will be run as, as set 
- * by gksu_context_set_user.
- *
- * Returns: a pointer to the string containing the username.
- */
-const gchar*
-gksu_context_get_user (GksuContext *context)
-{
-  return context->user;
+      int Tmp = errno;
+      close(FD);
+      errno = Tmp;
+      return -1;
+   }
+
+   return FD;
 }
 
-/**
- * gksu_context_set_command:
- * @context: the #GksuContext you want to modify
- * @command: the command that shall be ran
- *
- * Sets up what command will run with the target user.
- *
- */
+#define GRAB_TRIES	16
+#define GRAB_WAIT	250 /* milliseconds */
+
+typedef enum
+  {
+    FAILED_GRAB_MOUSE,
+    FAILED_GRAB_KEYBOARD
+  } FailedGrabWhat;
+
 void
-gksu_context_set_command (GksuContext *context, gchar *command)
+report_failed_grab (FailedGrabWhat what)
 {
-  g_assert (command != NULL);
+  GtkWidget *dialog;
 
-  if (context->command)
-    g_free (context->command);
-  context->command = g_strdup (command);
-}
+  dialog = g_object_new (GTK_TYPE_MESSAGE_DIALOG,
+			 "message-type", GTK_MESSAGE_WARNING,
+			 "buttons", GTK_BUTTONS_CLOSE,
+			 NULL);
 
-/**
- * gksu_context_get_command:
- * @context: the #GksuContext from which to grab the information
- *
- * Gets the command that will be run, as set by 
- * gksu_context_set_command.
- *
- * Returns: a pointer to the string containing the command.
- */
-const gchar*
-gksu_context_get_command (GksuContext *context)
-{
-  return context->command;
+  switch (what)
+    {
+    case FAILED_GRAB_MOUSE:
+      gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG(dialog),
+				     _("<b>Could not grab your mouse.</b>\n\n"
+				       "A malicious client may be eavesdropping\n"
+				       "on your session or you may have just clicked\n"
+				       "a menu or some application just decided to get\n"
+				       "focus.\n\n"
+				       "Try again."));
+
+      break;
+    case FAILED_GRAB_KEYBOARD:
+      gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG(dialog),
+				     _("Could not grab your keyboard.\n"
+				       "A malicious client may be eavesdropping\n"
+				       "on your session or you may have just clicked\n"
+				       "a menu or some application just decided to get\n"
+				       "focus.\n\n"
+				       "Try again."));
+      break;
+    }
+
+  gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
+  gtk_dialog_run (GTK_DIALOG(dialog));
+  gtk_widget_destroy (dialog);
+
+  while (gtk_events_pending ())
+    gtk_main_iteration ();
+
 }
 
-/**
- * gksu_context_set_password:
- * @context: the #GksuContext you want to modify
- * @password: the password
- *
- * Sets up what is the password to be passed to su/sudo. *
- */
-void
-gksu_context_set_password (GksuContext *context, gchar *password)
+int
+grab_keyboard_and_mouse (GtkWidget *dialog)
 {
-  if (context->password)
+  GdkGrabStatus status;
+  gint grab_tries = 0;
+  gint lock = -1;
+
+  gchar *fname = g_strdup_printf ("%s/.gksu.lock", getenv ("HOME"));
+  pid_t pid = test_lock (fname);
+
+  if (pid != 0)
     {
-      g_free (context->password);
-      context->password = NULL;
+      g_warning ("Lock taken by pid: %i. Exiting.", pid);
+      exit (0);
     }
 
-  if (password && strcmp ("", password) && strcmp ("\n", password))
+  lock = get_lock(fname);
+  if( lock < 0)
+    g_warning ("Unable to create lock file.");
+  g_free (fname);
+
+  gtk_widget_show_all (dialog);
+
+  /* reset cursor */
+  gdk_window_set_cursor(dialog->window, gdk_cursor_new(GDK_LEFT_PTR));
+
+  for(;;)
     {
-      if (password[strlen(password) - 1] == '\n')
-	context->password = g_strdup (password);
-      else
-	context->password = g_strdup_printf ("%s\n", password);
+      status = gdk_pointer_grab ((GTK_WIDGET(dialog))->window, TRUE, 0, NULL,
+				 NULL, GDK_CURRENT_TIME);
+      if (status == GDK_GRAB_SUCCESS)
+	break;
+      usleep (GRAB_WAIT * 1000);
+      if (++grab_tries > GRAB_TRIES)
+	{
+	  gtk_widget_hide (dialog);
+	  report_failed_grab (FAILED_GRAB_MOUSE);
+	  exit (1);
+	  break;
+	}
     }
-}
 
-/**
- * gksu_context_get_password:
- * @context: the #GksuContext from which to grab the information
- *
- * Gets the password that is set for calling the su/sudo
- * programs.
- *
- * Returns: a pointer to the string containing the password.
- */
-const gchar*
-gksu_context_get_password (GksuContext *context)
-{
-  return context->password;
-}
+  for(;;)
+    {
+      status = gdk_keyboard_grab ((GTK_WIDGET(dialog))->window,
+				  FALSE, GDK_CURRENT_TIME);
+      if (status == GDK_GRAB_SUCCESS)
+	break;
 
-/**
- * gksu_context_set_login_shell:
- * @context: the #GksuContext you want to modify
- * @value: TRUE or FALSE
- *
- * Should the shell in which the command will be run be
- * a login shell?
- */
-void
-gksu_context_set_login_shell (GksuContext *context, gboolean value)
-{
-  context->login_shell = value;
-}
+      usleep(GRAB_WAIT * 1000);
 
-/**
- * gksu_context_get_login_shell:
- * @context: the #GksuContext from which to grab the information
- *
- * Finds out if the shell created by the underlying su process
- * will be a login shell.
- *
- * Returns: TRUE if the shell will be a login shell, FALSE otherwise.
- */
-gboolean
-gksu_context_get_login_shell (GksuContext *context)
-{
-  return context->login_shell;
-}
+      if (++grab_tries > GRAB_TRIES)
+	{
+	  gtk_widget_hide (dialog);
+	  report_failed_grab (FAILED_GRAB_KEYBOARD);
+	  exit (1);
+	  break;
+	}
+    }
 
-/**
- * gksu_context_set_keep_env:
- * @context: the #GksuContext you want to modify
- * @value: TRUE or FALSE
- *
- * Should the environment be kept as it is? Defaults to
- * TRUE. Notice that setting this to FALSE may cause the
- * X authorization stuff to fail.
- */
-void
-gksu_context_set_keep_env (GksuContext *context, gboolean value)
-{
-  context->keep_env = value;
-}
+  /* we "raise" the window because there is a race here for
+   * focus-follow-mouse and auto-raise WMs that may put the window
+   * in the background and confuse users
+   */
+  gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
 
-/**
- * gksu_context_get_keep_env:
- * @context: the #GksuContext from which to grab the information
- *
- * Finds out if the environment in which the program will be
- * run will be reset.
- *
- * Returns: TRUE if the environment is going to be kept, 
- * FALSE otherwise.
- */
-gboolean
-gksu_context_get_keep_env (GksuContext *context)
-{
-  return context->keep_env;
+  while (gtk_events_pending ())
+    gtk_main_iteration ();
+
+  return lock;
 }
 
-/**
- * gksu_context_set_debug:
- * @context: the #GksuContext you want to modify
- * @value: TRUE or FALSE
- *
- * Set up if debuging information should be printed.
- */
 void
-gksu_context_set_debug (GksuContext *context, gboolean value)
+ungrab_keyboard_and_mouse (int lock)
 {
-  context->debug = value;
-}
+  /* Ungrab */
+  gdk_pointer_ungrab(GDK_CURRENT_TIME);
+  gdk_keyboard_ungrab(GDK_CURRENT_TIME);
+  gdk_flush();
 
-/**
- * gksu_context_get_debug:
- * @context: the #GksuContext from which to grab the information
- *
- * Finds out if the library is configured to print debuging
- * information.
- *
- * Returns: TRUE if it is, FALSE otherwise.
- */
-gboolean
-gksu_context_get_debug (GksuContext *context)
-{
-  return context->debug;
+  close(lock);
 }
 
-/**
- * gksu_context_set_ssh_fwd:
- * @context: the #GksuContext you want to modify
- * @value: TRUE or FALSE
- *
- * Set up if we are running inside a sshd forwarding
- * session. That's because the X authorization semantics
- * differ a bit.
- * -> THIS SETTING IS CURRENTLY USED FOR NOTHING
- */
 void
-gksu_context_set_ssh_fwd (GksuContext *context, gboolean value)
+get_configuration_options (GksuContext *context)
 {
-  context->ssh_fwd = value;
+  GConfClient *gconf_client = context->gconf_client;
+
+  grab = !gconf_client_get_bool (gconf_client, BASE_PATH "disable-grab",
+				 NULL);
+  force_grab = gconf_client_get_bool (gconf_client, BASE_PATH "force-grab",
+				      NULL);
+  context->sudo_mode = gconf_client_get_bool (gconf_client, BASE_PATH "sudo-mode",
+					      NULL);
+  prompt = gconf_client_get_bool (gconf_client, BASE_PATH "prompt",
+				  NULL);
+  always_ask_pass = gconf_client_get_bool (gconf_client,
+					   BASE_PATH "always-ask-password",
+					   NULL);
 }
 
 /**
- * gksu_context_get_ssh_fwd:
- * @context: the #GksuContext from which to grab the information
+ * gksuui_ask_password:
+ * @context: a #GksuContext
+ * @prompt: the prompt that should be used instead of "Password: "
+ * @grab: should the X keyboard and mouse inputs be grabbed
  *
- * Finds out if the library is configured as being run inside a
- * ssh X11 forwarding tunnel.
- * -> THIS SETTING IS CURRENTLY USED FOR NOTHING
+ * This is a convenience function to create a #GksuuiDialog and
  *
- * Returns: TRUE if it is, FALSE otherwise.
+ *
+ * Returns: a newly allocated gchar containing the password
+ * or NULL if an error happens or the user cancels the action
  */
-gboolean
-gksu_context_get_ssh_fwd (GksuContext *context)
+static gchar*
+su_ask_password (GksuContext *context, gchar *prompt,
+		 gpointer data, GError **error)
 {
-  return context->ssh_fwd;
-}
+  GtkWidget *dialog = NULL;
+  gchar *password = NULL, *tmp = NULL;
 
-GType
-gksu_context_get_type (void)
-{
-  static GType type = 0;
+  int retvalue = 0;
 
-  if (type == 0)
+  if (grab)
+    dialog = g_object_new (GKSUUI_TYPE_DIALOG,
+			   "type", GTK_WINDOW_POPUP,
+			   NULL);
+  else
+    dialog = gksuui_dialog_new ();
+
+  if (prompt)
+    gksuui_dialog_set_prompt (GKSUUI_DIALOG(dialog), prompt);
+
+  if (!message_changed)
     {
-      static const GTypeInfo info =
-	{
-	  sizeof (GksuContextClass), /* size of class */
-	  NULL, /* base_init */
-	  NULL, /* base_finalize */
-	  (GClassInitFunc) gksu_context_class_init,
-	  NULL, /* class_finalize */
-	  NULL, /* class_data */
-	  sizeof (GksuContext), /* size of object */
-	  0, /* n_preallocs */
-	  (GInstanceInitFunc) gksu_context_init /* instance_init */
-	};
-      type = g_type_register_static (G_TYPE_OBJECT,
-				     "GksuContextType",
-				     &info, 0);
+      gchar *msg;
+
+      if (context->sudo_mode)
+	msg = g_strdup_printf (_("<b>Please enter your password\n"
+				 "to run %s as user %s</b>"),
+			       context->command,
+			       context->user);
+      else
+	msg = g_strdup_printf (_("<b>To run the program \"%s\" you need to "
+				 "enter the %s password</b>"),
+			       context->command,
+			       context->user);
+
+      gksuui_dialog_set_message (GKSUUI_DIALOG(dialog), msg);
+      g_free (msg);
     }
 
-  return type;
-}
+  int lock = 0;
+  if (grab)
+    lock = grab_keyboard_and_mouse (dialog);
+  retvalue = gtk_dialog_run (GTK_DIALOG(dialog));
+  gtk_widget_hide (dialog);
+  if (grab)
+    ungrab_keyboard_and_mouse (lock);
 
-static void
-gksu_context_init (GTypeInstance *instance, gpointer g_class)
-{
-  GksuContext *self = (GksuContext*)instance;
+  while (gtk_events_pending ())
+    gtk_main_iteration ();
 
-  self->xauth = NULL;
-  self->dir = NULL;
-  self->display = NULL;
-  self->user = g_strdup ("root");
-  self->password = NULL;
-  self->command = NULL;
+  if (retvalue != GTK_RESPONSE_OK)
+    return NULL;
 
-  self->login_shell = FALSE;
-  self->keep_env = FALSE;
+  tmp = gksuui_dialog_get_password (GKSUUI_DIALOG(dialog));
+  password = g_locale_from_utf8 (tmp, strlen (tmp), NULL, NULL, NULL);
+  g_free (tmp);
 
-  self->debug = FALSE;
-  self->ssh_fwd = FALSE;
+  return password;
 }
 
 static void
-gksu_context_dispose (GObject *object)
+set_sensitivity_cb (GtkWidget *button, gpointer data)
 {
-  GksuContext *self = (GksuContext*)object;
+  GtkWidget *widget = (GtkWidget*)data;
+  gboolean sensitive;
 
-  g_free (self->xauth);
-  g_free (self->dir);
-  g_free (self->display);
-  g_free (self->user);
-  g_free (self->password);
-  g_free (self->command);
+  sensitive = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button));
+  gtk_widget_set_sensitive (widget, sensitive);
 }
 
 static void
-gksu_context_finalize (GObject *object)
+cb_toggled_cb (GtkWidget *button, gpointer data)
 {
+  GConfClient *gconf_client;
+  gchar *key;
+  gboolean toggled;
+  gchar *key_name;
+
+  g_return_if_fail (data != NULL);
+
+  key_name = (gchar*)data;
+
+  gconf_client = gconf_client_get_default ();
+  toggled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button));
+
+  key = g_strdup_printf (BASE_PATH "%s", key_name);
+
+  if (!strcmp (key_name, "save-keyring"))
+    {
+      if (toggled)
+	gconf_client_set_string (gconf_client, key, "session", NULL);
+      else
+	gconf_client_set_string (gconf_client, key, "default", NULL);
+    }
+  else if (!strcmp (key_name, "display-no-pass-info"))
+    {
+      /* the meaning of the key is the exact opposite of the meaning
+	 of the answer - when the check button is checked the key must
+	 be off
+      */
+      gconf_client_set_bool (gconf_client, key, !toggled, NULL);
+    }
+  else
+    gconf_client_set_bool (gconf_client, key, toggled, NULL);
+
+  g_object_unref (gconf_client);
+
+  g_free (key);
 }
 
-static void
-gksu_context_class_init (GksuContextClass *klass)
+void
+no_pass (GksuContext *context, gpointer data)
 {
-  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  GtkWidget *dialog;
+  GtkWidget *alignment;
+  GtkWidget *check_button;
 
-  gobject_class->dispose = gksu_context_dispose;
-  gobject_class->finalize = gksu_context_finalize;
+  dialog = gtk_message_dialog_new_with_markup (NULL, 0,
+					       GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
+					       _("<b>The \"%s\" program was started with "
+						 "the privileges of the %s user without "
+						 "the need to ask for a password, due to "
+						 "your system's authentication mechanism "
+						 "setup.</b>"
+						 "\n\n"
+						 "It is possible that you are being allowed "
+						 "to run specific programs as user %s "
+						 "without the need for a password, or that "
+						 "the password is cached."
+						 "\n"
+						 "This is not a problem report; it's "
+						 "simply a notification to make sure "
+						 "you are aware of this."),
+					       context->command,
+					       context->user,
+					       context->user);
 
+  alignment = gtk_alignment_new (0.5, 0.5, 0.6, 1);
+  gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), alignment, TRUE, TRUE, 2);
+
+  check_button = gtk_check_button_new_with_mnemonic (_("Do _not display this message again"));
+  g_signal_connect (G_OBJECT(check_button), "toggled",
+		    G_CALLBACK(cb_toggled_cb), "display-no-pass-info");
+  gtk_container_add (GTK_CONTAINER(alignment), check_button);
+
+  gtk_widget_show_all (dialog);
+  gtk_dialog_run (GTK_DIALOG(dialog));
+  gtk_widget_destroy (GTK_WIDGET(dialog));
+
+  while (gtk_events_pending ())
+    gtk_main_iteration ();
 }
 
-GType
-gksu_context_error_get_type (void)
+static void
+nullify_password (gchar *pass)
 {
-  static GType etype = 0;
-  if (etype == 0) {
-    static const GEnumValue values[] = {
-      { GKSU_CONTEXT_ERROR_HELPER, "GKSU_CONTEXT_ERROR_HELPER", "helper" },
-      { GKSU_CONTEXT_ERROR_NOCOMMAND, "GKSU_CONTEXT_ERROR_NOCOMMAND", "nocommand" },
-      { GKSU_CONTEXT_ERROR_NOPASSWORD, "GKSU_CONTEXT_ERROR_NOPASSWORD", "nopassword" },
-      { GKSU_CONTEXT_ERROR_FORK, "GKSU_CONTEXT_ERROR_FORK", "fork" },
-      { GKSU_CONTEXT_ERROR_EXEC, "GKSU_CONTEXT_ERROR_EXEC", "exec" },
-      { GKSU_CONTEXT_ERROR_PIPE, "GKSU_CONTEXT_ERROR_PIPE", "pipe" },
-      { GKSU_CONTEXT_ERROR_PIPEREAD, "GKSU_CONTEXT_ERROR_PIPEREAD", "piperead" },
-      { GKSU_CONTEXT_ERROR_WRONGPASS, "GKSU_CONTEXT_ERROR_WRONGPASS", "wrongpass" },
-      { GKSU_CONTEXT_ERROR_CHILDFAILED, "GKSU_CONTEXT_ERROR_CHILDFAILED", "childfailed" },
-      { 0, NULL, NULL }
-    };
-    etype = g_enum_register_static ("GksuContextError", values);
-  }
-  return etype;
+  if (pass)
+    {
+      memset(pass, 0, strlen(pass));
+      g_free (pass);
+    }
+  pass = NULL;
 }
 
 static gchar *
@@ -423,7 +487,7 @@
 
   f = fopen(cmdfile, "r");
   g_free (cmdfile);
-  if(f != NULL) 
+  if(f != NULL)
     {
       fgets(cmdline, 255, f);
       cmdline[255] = '\0';
@@ -438,7 +502,7 @@
 /**
  * prepare_xauth:
  *
- * Sets up the variables with values for the $DISPLAY 
+ * Sets up the variables with values for the $DISPLAY
  * environment variable and xauth-related stuff. Also
  * creates a temporary directory to hold a .Xauthority
  *
@@ -458,9 +522,9 @@
   display = g_strdup (getenv ("DISPLAY"));
   tmpv = g_strsplit (display, ":", 3);
   g_free (display);
-  
+
   context->display = g_strdup_printf (":%s", tmpv[1]);
-  
+
   g_strfreev (tmpv);
 
   /* get the authorization token */
@@ -483,7 +547,7 @@
 
   if (context->debug)
     {
-      fprintf(stderr, 
+      fprintf(stderr,
 	      "xauth: -%s-\n"
 	      "display: -%s-\n",
 	      context->xauth, context->display);
@@ -526,7 +590,7 @@
   newfn = g_strdup_printf("%s/.Xauthority", dir);
 
   out = open(newfn, O_WRONLY | O_CREAT | O_EXCL, 0600);
-  if (out == -1) 
+  if (out == -1)
     {
       if (errno == EEXIST)
 	fprintf (stderr,
@@ -540,7 +604,7 @@
 
       return TRUE;
     }
-  
+
   in = open(fn, O_RDONLY);
   if (in == -1)
     {
@@ -549,8 +613,8 @@
 	       fn, dir, strerror(errno));
       return TRUE;
     }
-  
-  while ((r = read(in, buf, BUFSIZ)) > 0) 
+
+  while ((r = read(in, buf, BUFSIZ)) > 0)
     {
       if (full_write(out, buf, r) == -1)
 	{
@@ -585,7 +649,7 @@
       fprintf (stderr, strerror(errno));
       return 1;
     }
-  
+
   xauth = g_strdup(g_getenv ("XAUTHORITY"));
   if (xauth == NULL)
     xauth = g_strdup_printf ("%s/.Xauthority", g_get_home_dir());
@@ -600,7 +664,7 @@
 }
 
 static void
-sudo_reset_xauth (GksuContext *context, gchar *xauth, 
+sudo_reset_xauth (GksuContext *context, gchar *xauth,
 		  gchar *xauth_env)
 {
   /* reset the env var as it was before or clean it  */
@@ -608,123 +672,58 @@
     setenv ("XAUTHORITY", xauth_env, TRUE);
   else
     unsetenv ("XAUTHORITY");
-  
+
   if (context->debug)
     fprintf (stderr, "xauth: %s\nxauth_env: %s\ndir: %s\n",
 	     xauth, xauth_env, context->dir);
-  
+
   unlink (xauth);
   rmdir (context->dir);
 
   g_free (xauth);
 }
 
-gboolean
-try_su_run (GksuContext *context)
+GksuContext*
+gksu_context_new ()
 {
-  int fdpty;
-  pid_t pid;
-  int i = 0;
+  GksuContext *context;
 
-  gboolean need_pass = TRUE;
+  context = g_new (GksuContext, 1);
 
-  pid = forkpty (&fdpty, NULL, NULL, NULL);
-  if (pid == 0)
-    {
-      gchar **cmd = g_malloc (sizeof(gchar*)*7);
+  context->xauth = NULL;
+  context->dir = NULL;
+  context->display = NULL;
 
-      cmd[i] = g_strdup ("/bin/su"); i++;
-      if (context->login_shell)
-	{
-	  cmd[i] = g_strdup ("-"); i++;
-	}
-      cmd[i] = g_strdup (context->user); i++;
-      if (context->keep_env)
-	{
-	  cmd[i] = g_strdup ("-p"); i++;
-	}
-      cmd[i] = g_strdup ("-c"); i++;
+  context->gconf_client = gconf_client_get_default ();
 
-      /* needs to get X authorization prior to running the program */
-      cmd[i] = g_strdup_printf ("echo > /dev/null"); i++;
+  context->sudo_mode = FALSE;
 
-      cmd[i] = NULL;
+  context->user = NULL;
+  context->command = NULL;
 
-      /* executes the command */
-      if (execv (cmd[0], cmd) == -1)
-	{
-	  fprintf (stderr, 
-		   _("Unable to run /bin/su: %s"),
-		   strerror(errno));
+  context->login_shell = FALSE;
+  context->keep_env = FALSE;
 
-	  for (i = 0 ; cmd[i] != NULL ; i++)
-	    g_free (cmd[i]);
-	  g_free(cmd);
-	  
-	  return TRUE;
-	}
-    }
-  else if (pid == -1)
-    {
-      return TRUE;
-    }
-  else
-    {
-      fd_set rfds;
+  context->grab = TRUE;
 
-      struct timeval tv;
-      struct termios tio;
+  context->debug = FALSE;
 
-      gchar buf[256];
-      gint status;
-
-      FD_ZERO(&rfds);
-      FD_SET(fdpty, &rfds);
-
-      tv.tv_sec = 0;
-      tv.tv_usec = 100;
-
-      if (select (fdpty+1, &rfds, NULL, NULL, &tv) < 0)
-	return TRUE;
-
-      read (fdpty, buf, 256);
-      if (context->debug)
-	fprintf (stderr, "try_su_run: buf: -%s-\n", buf);
-
-      usleep (100);
-
-      tcgetattr (fdpty, &tio);
-      
-      if ((tio.c_lflag & ECHO))
-	need_pass = FALSE;
-
-      kill (pid, SIGKILL);
-      waitpid (pid, &status, 0);
-    }
-
-  return need_pass;
+  return context;
 }
 
-/**
- * gksu_context_try_need_password
- * @context: a #GksuContext
- *
- * Checks if we need to ask for a password or if we have ways of
- * getting the password for ourselves or we simply don't need it.
- * Since 1.3.0.
- *
- * Returns: TRUE if requesting a password is needed, FALSE otherwise.
- *
- */
-gboolean
-gksu_context_try_need_password (GksuContext *context)
+void
+gksu_context_free (GksuContext *context)
 {
-  nullify_password (context);
+  g_free (context->xauth);
+  g_free (context->dir);
+  g_free (context->display);
 
-  if (try_su_run (context) == FALSE)
-    return FALSE;
+  g_object_unref (context->gconf_client);
 
-  return TRUE;
+  g_free (context->user);
+  g_free (context->command);
+
+  g_free (context);
 }
 
 /**
@@ -749,10 +748,12 @@
  * Returns: the child's error status, 0 if all went fine, -1 if failed
  */
 gboolean
-gksu_context_run_full (GksuContext *context, 
-		       GksuAskPasswordFunc ask_pass, gpointer user_data, 
-		       GksuPasswordNotNeededFunc pass_not_needed, 
-		       gpointer pnn_user_data, GError **error)
+gksu_su_full (GksuContext *context,
+	      GksuAskPassFunc ask_pass,
+	      gpointer ask_pass_data,
+	      GksuPassNotNeededFunc pass_not_needed,
+	      gpointer pass_not_needed_data,
+	      GError **error)
 {
   GQuark gksu_quark;
   int i = 0;
@@ -762,27 +763,31 @@
   int fdpty;
   pid_t pid;
 
+  get_configuration_options (context);
+
   gksu_quark = g_quark_from_string (PACKAGE);
 
   if (!context->command)
     {
-      g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_NOCOMMAND,
+      g_set_error (error, gksu_quark, GKSU_ERROR_NOCOMMAND,
 		   _("gksu_run needs a command to be run, "
 		     "none was provided."));
       return -1;
     }
 
+  if (!context->user)
+    context->user = g_strdup ("root");
+
   if (!g_file_test (auxcommand, G_FILE_TEST_IS_EXECUTABLE))
     {
-      g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_HELPER,
+      g_set_error (error, gksu_quark, GKSU_ERROR_HELPER,
 		   _("The gksu-run-helper command was not found or "
 		     "is not executable."));
       return -1;
     }
 
-  /* 
-     FIXME: need to check if we are in X and also need to
-     provide GError stuff
+  /*
+     FIXME: need to provide GError stuff
   */
   prepare_xauth (context);
 
@@ -804,7 +809,7 @@
       cmd[i] = g_strdup ("-c"); i++;
 
       /* needs to get X authorization prior to running the program */
-      cmd[i] = g_strdup_printf ("%s \"%s\"", auxcommand, 
+      cmd[i] = g_strdup_printf ("%s \"%s\"", auxcommand,
 				context->command); i++;
 
       cmd[i] = NULL;
@@ -812,7 +817,7 @@
       /* executes the command */
       if (execv (cmd[0], cmd) == -1)
 	{
-	  fprintf (stderr, 
+	  fprintf (stderr,
 		   _("Unable to run /bin/su: %s"),
 		   strerror(errno));
 	}
@@ -823,7 +828,7 @@
     }
   else if (pid == -1)
     {
-      g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_FORK,
+      g_set_error (error, gksu_quark, GKSU_ERROR_FORK,
 		   _("Failed to fork new process: %s"),
 		   strerror(errno));
       return -1;
@@ -842,7 +847,6 @@
       gint status;
 
       gchar *cmdline = NULL;
-
       gboolean password_needed = FALSE;
 
       my_uid = getuid();
@@ -850,53 +854,73 @@
       if (pwd)
 	target_uid = pwd->pw_uid;
 
+      if (ask_pass == NULL)
+	{
+	  ask_pass = su_ask_password;
+	}
+
+      if (pass_not_needed == NULL)
+	{
+	  pass_not_needed = no_pass;
+	}
+
       /* no need to ask for password if we're already root */
       if (my_uid != target_uid && my_uid)
 	{
-	  if (context->password || ask_pass)
+	  struct termios tio;
+
+	  usleep (100);
+	  read (fdpty, buf, 256);
+	  if (context->debug)
+	    fprintf (stderr, "gksu_context_run: buf: -%s-\n", buf);
+
+	  usleep (100);
+
+	  tcgetattr (fdpty, &tio);
+
+	  if (!(tio.c_lflag & ECHO))
 	    {
-	      struct termios tio;
+	      gchar *password = NULL;
+	      gchar *tmp = NULL;
 
-	      usleep (100);
-	      read (fdpty, buf, 256);
-	      if (context->debug)
-		fprintf (stderr, "gksu_context_run: buf: -%s-\n", buf);
+	      tmp = ask_pass (context, buf, ask_pass_data, error);
+	      g_return_val_if_fail (tmp != NULL, -1);
 
 	      usleep (100);
 
-	      tcgetattr (fdpty, &tio);
+	      password = g_strdup_printf ("%s\n", tmp);
+	      nullify_password (tmp);
 
-	      if (!(tio.c_lflag & ECHO))
-		{
-		  if (!context->password)
-		    {
-		      if (ask_pass (context, buf, user_data, error))
-			  return -1;
+	      write (fdpty, password, strlen(password));
 
-		      g_return_val_if_fail (context->password, -1);
-		    }
+	      nullify_password (password);
 
-		  usleep (100);
-
-		  password_needed = TRUE;
-		  write (fdpty, context->password, 
-			 strlen(context->password));
-		}
+	      password_needed = TRUE;
 	    }
 	}
 
       if (!password_needed)
-	pass_not_needed (context, pnn_user_data);
-      
+	{
+	  gboolean should_display;
+
+	  should_display = gconf_client_get_bool (context->gconf_client,
+						  BASE_PATH "display-no-pass-info", NULL);
+
+	  /* configuration tells us to show this message */
+	  if (should_display)
+	    pass_not_needed (context, pass_not_needed_data);
+	}
+
       if (context->debug)
 	fprintf (stderr, "DEBUG (run:after-pass) buf: -%s-\n", buf);
       if (strncmp (buf, "gksu", 4) && strncmp (buf, "su", 2))
 	{
-	  bzero (buf, 256);
 	  /* drop the \n echoed on password entry if su did request
 	     a password */
 	  if (password_needed)
 	    read (fdpty, buf, 256);
+	  if (context->debug)
+	    fprintf (stderr, "DEBUG (run:post-after-pass) buf: -%s-\n", buf);
 	  read (fdpty, buf, 255);
 	  if (context->debug)
 	    fprintf (stderr, "DEBUG (run:post-after-pass) buf: -%s-\n", buf);
@@ -904,8 +928,8 @@
 
       if (!strncmp (buf, "su: Authentication failure", 26))
 	{
-	  g_set_error (error, gksu_quark, 
-		       GKSU_CONTEXT_ERROR_WRONGPASS,
+	  g_set_error (error, gksu_quark,
+		       GKSU_ERROR_WRONGPASS,
 		       _("Wrong password."));
 	  if (context->debug)
 	    fprintf (stderr, "DEBUG (auth_failed) buf: -%s-\n", buf);
@@ -913,14 +937,14 @@
       else if (!strncmp (buf, "gksu: waiting", 13))
 	{
 	  gchar *line;
-	  
+
 	  if (context->debug)
 	    fprintf (stderr, "DEBUG (gksu: waiting) buf: -%s-\n", buf);
 
 	  line = g_strdup_printf ("gksu-run: %s\n", context->display);
 	  write (fdpty, line, strlen(line));
 	  g_free (line);
-	  
+
 	  line = g_strdup_printf ("gksu-run: %s\n", context->xauth);
 	  write (fdpty, line, strlen(line));
 	  g_free (line);
@@ -938,7 +962,7 @@
 					   " %s\n"
 					   "While expecting:\n"
 					   " %s"), buf, "gksu: waiting");
-	  g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_HELPER, emsg);
+	  g_set_error (error, gksu_quark, GKSU_ERROR_HELPER, emsg);
 	  g_free (emsg);
 
 	  if (context->debug)
@@ -966,7 +990,7 @@
 
 	  if (select (fdpty+1, &rfds, NULL, NULL, &tv) < 0)
 	    {
-	      g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_PIPEREAD,
+	      g_set_error (error, gksu_quark, GKSU_ERROR_PIPEREAD,
 			   _("Could not read from the pipe "
 			     "with the child: %s"),
 			   strerror(errno));
@@ -1009,8 +1033,8 @@
 		}
 
 	      if (error == NULL)
-		g_set_error (error, gksu_quark, 
-			     GKSU_CONTEXT_ERROR_CHILDFAILED,
+		g_set_error (error, gksu_quark,
+			     GKSU_ERROR_CHILDFAILED,
 			     _("su terminated with %d status"),
 			     WEXITSTATUS(status));
 	    }
@@ -1023,166 +1047,23 @@
   return FALSE;
 }
 
-/* DO NOT USE -- Deprecated */
 gboolean
-gksu_context_ask_and_run (GksuContext *context, GksuAskPasswordFunc ask_pass, 
-			  gpointer user_data, GError **error)
+gksu_su (gchar *command_line, GError **error)
 {
-  return gksu_context_run_full (context, ask_pass, user_data, NULL, NULL, error);
-}
+  GksuContext *context = gksu_context_new ();
+  gboolean retval;
 
-/**
- * gksu_context_run:
- * @context: a #GksuContext
- * @error: a #GError object to be filled with the error code or NULL
- *
- * This could be considered one of the main functions in GKSu.
- * it is responsible for doing the 'user changing' magic.
- *
- * Returns: the child's error status, 0 if all went fine, -1 if failed
- */
-gboolean
-gksu_context_run (GksuContext *context, GError **error)
-{
-  return gksu_context_run_full (context, NULL, NULL, NULL, NULL, error);
+  context->command = g_strdup (command_line);
+  context->user = g_strdup ("root");
+  retval = gksu_su_full (context,
+			 NULL, NULL,
+			 NULL, NULL,
+			 error);
+  gksu_context_free (context);
+  return retval;
 }
 
-static gboolean
-ack_killed_child (gpointer pid)
-{
-      waitpid (GPOINTER_TO_INT(pid), NULL, 0);
-      return FALSE;
-}
-
-static gboolean
-try_sudo_validation (GksuContext *context)
-{
-  char **cmd;
-  int argcount = 4;
-  char buffer[256] = {0};
-
-  pid_t pid;
-  size_t r;
-  FILE *infile, *outfile;
-  int parent_pipe[2];	/* For talking to the parent */
-  int child_pipe[2];	/* For talking to the child */
-
-  gboolean need_pass = TRUE;
-  
-  if ((pipe(parent_pipe)) == -1)
-    return TRUE;
-
-  if ((pipe(child_pipe)) == -1)
-    return TRUE;
-
-  cmd = g_new (gchar *, argcount + 1);
-  
-  argcount = 0;
-
-  /* sudo binary */
-  cmd[argcount] = g_strdup("/usr/bin/sudo");
-  argcount++;
-
-  /* Make sudo read from STDIN */
-  cmd[argcount] = g_strdup("-S");
-  argcount++;
-
-  /* Make sudo use next arg as prompt */
-  cmd[argcount] = g_strdup("-p");
-  argcount++;
-
-  /* prompt */
-  cmd[argcount] = g_strdup("GNOME_SUDO_PASS");
-  argcount++;
-
-  /* just try to validate the password */
-  cmd[argcount] = g_strdup("-v");
-  argcount++;
-
-  cmd[argcount] = NULL;
-
-  pid = fork();
-  if (pid == -1)
-    return TRUE;
-  else if (pid == 0) 
-    {
-      // Child
-      close(child_pipe[1]);
-      dup2(child_pipe[0], STDIN_FILENO);
-      dup2(parent_pipe[1], STDERR_FILENO);
-      
-      execv(cmd[0], cmd);
-      
-      return TRUE;
-    } 
-  else 
-    {
-      // Parent
-      close(parent_pipe[1]);
-      
-      infile = fdopen(parent_pipe[0], "r");
-      if (!infile)
-	return TRUE;
-
-      outfile = fdopen(child_pipe[1], "w");
-      if (!outfile)
-	return TRUE;
-
-      /*
-	we are expecting to receive a GNOME_SUDO_PASS
-	if we don't there are two possibilities: an error
-	or a password is not needed
-      */
-      r = read(parent_pipe[0], buffer, 15);
-      buffer[16] = '\0';
-
-      if (context->debug)
-	fprintf (stderr, "buffer: -%s-\n", buffer);
-
-      if (strncmp(buffer, "GNOME_SUDO_PASS", 15) == 0) 
-	{
-	  if (context->debug)
-	    fprintf (stderr, "We'll need a password...\n");
-
-	  fprintf (outfile, "\n");
-	} 
-      else 
-	{
-	  if (context->debug)
-	    fprintf (stderr, "We won't need a password, it seems!\n");
-	  need_pass = FALSE;
-	}
-
-      /* politely request that sudo GET OUT OF THE WAY */
-      kill (pid, SIGKILL);
-
-      g_timeout_add (3000, ack_killed_child, GINT_TO_POINTER(pid));
-    }
-
-  return need_pass;
-}
-
 /**
- * gksu_context_sudo_try_need_password
- * @context: a #GksuContext
- *
- * Checks if we need to ask for a password or if we have ways of
- * getting the password for ourselves or we simply don't need it.
- * Since 1.3.1.
- *
- * Returns: TRUE if requesting a password is needed, FALSE otherwise.
- *
- */
-gboolean
-gksu_context_sudo_try_need_password (GksuContext *context)
-{
-  if (!try_sudo_validation (context))
-    return FALSE;
-
-  return TRUE;
-}
-
-/**
  * gksu_context_sudo_run_full:
  * @context: a #GksuContext
  * @ask_pass: a #GksuAskPasswordFunc
@@ -1204,10 +1085,12 @@
  * Returns: the child's error status, 0 if all went fine, -1 if failed
  */
 gboolean
-gksu_context_sudo_run_full (GksuContext *context, 
-			    GksuAskPasswordFunc ask_pass, gpointer user_data, 
-			    GksuPasswordNotNeededFunc pass_not_needed, 
-			    gpointer pnn_user_data, GError **error)
+gksu_sudo_full (GksuContext *context,
+		GksuAskPassFunc ask_pass,
+		gpointer ask_pass_data,
+		GksuPassNotNeededFunc pass_not_needed,
+		gpointer pass_not_needed_data,
+		GError **error)
 {
   char **cmd;
   char buffer[256] = {0};
@@ -1216,7 +1099,7 @@
 
   GQuark gksu_quark;
 
-  gchar *xauth = NULL, 
+  gchar *xauth = NULL,
     *xauth_env = NULL;
 
   pid_t pid;
@@ -1225,23 +1108,40 @@
   FILE *infile, *outfile;
   int parent_pipe[2];	/* For talking to the parent */
   int child_pipe[2];	/* For talking to the child */
-  
+
+  get_configuration_options (context);
+
   gksu_quark = g_quark_from_string (PACKAGE);
 
   if (!context->command)
     {
-      g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_NOCOMMAND,
+      g_set_error (error, gksu_quark, GKSU_ERROR_NOCOMMAND,
 		   _("gksu_sudo_run needs a command to be run, "
 		     "none was provided."));
       return -1;
     }
 
-  /* 
-     FIXME: need to check if we are in X
+  if (!context->user)
+    context->user = g_strdup ("root");
+
+  if (ask_pass == NULL)
+    {
+      if (context->debug)
+	fprintf (stderr, "No ask_pass set, using default!\n");
+      ask_pass = su_ask_password;
+    }
+
+  if (pass_not_needed == NULL)
+    {
+      pass_not_needed = no_pass;
+    }
+
+  /*
+     FIXME: need to set GError in a more detailed way
   */
   if (sudo_prepare_xauth (context) == 1)
     {
-      g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_XAUTH,
+      g_set_error (error, gksu_quark, GKSU_ERROR_XAUTH,
 		   _("Unable to copy the user's Xauthorization file."));
       return -1;
     }
@@ -1255,7 +1155,7 @@
     fprintf (stderr, "xauth: %s\n", xauth);
 
   cmd = g_new (gchar *, argcount + 1);
-  
+
   argcount = 0;
 
   /* sudo binary */
@@ -1313,7 +1213,7 @@
 	    inside_quotes = !inside_quotes;
 	  }
 
-	if ((context->command[i] == ' ' && inside_quotes == FALSE) 
+	if ((context->command[i] == ' ' && inside_quotes == FALSE)
 	    || context->command[i] == '\0')
 	  {
 	    tmp_arg = g_realloc (tmp_arg, sizeof(gchar)*(j+1));
@@ -1353,7 +1253,7 @@
 
   if ((pipe(parent_pipe)) == -1)
     {
-      g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_PIPE,
+      g_set_error (error, gksu_quark, GKSU_ERROR_PIPE,
 		   _("Error creating pipe: %s"),
 		   strerror(errno));
       sudo_reset_xauth (context, xauth, xauth_env);
@@ -1362,7 +1262,7 @@
 
   if ((pipe(child_pipe)) == -1)
     {
-      g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_PIPE,
+      g_set_error (error, gksu_quark, GKSU_ERROR_PIPE,
 		   _("Error creating pipe: %s"),
 		   strerror(errno));
       sudo_reset_xauth (context, xauth, xauth_env);
@@ -1372,39 +1272,39 @@
   pid = fork();
   if (pid == -1)
     {
-      g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_FORK,
+      g_set_error (error, gksu_quark, GKSU_ERROR_FORK,
 		   _("Failed to fork new process: %s"),
 		   strerror(errno));
       sudo_reset_xauth (context, xauth, xauth_env);
       return -1;
     }
-  else if (pid == 0) 
+  else if (pid == 0)
     {
       // Child
       setsid();   // make us session leader
       close(child_pipe[1]);
       dup2(child_pipe[0], STDIN_FILENO);
       dup2(parent_pipe[1], STDERR_FILENO);
-      
+
       execv(cmd[0], cmd);
-      
-      g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_EXEC,
+
+      g_set_error (error, gksu_quark, GKSU_ERROR_EXEC,
 		   _("Failed to exec new process: %s"),
 		   strerror(errno));
       sudo_reset_xauth (context, xauth, xauth_env);
       return -1;
-    } 
-  else 
+    }
+  else
     {
       gchar *cmdline = NULL;
 
       // Parent
       close(parent_pipe[1]);
-      
+
       infile = fdopen(parent_pipe[0], "r");
       if (!infile)
 	{
-	  g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_PIPE,
+	  g_set_error (error, gksu_quark, GKSU_ERROR_PIPE,
 		       _("Error opening pipe: %s"),
 		       strerror(errno));
 	  sudo_reset_xauth (context, xauth, xauth_env);
@@ -1414,7 +1314,7 @@
       outfile = fdopen(child_pipe[1], "w");
       if (!outfile)
 	{
-	  g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_PIPE,
+	  g_set_error (error, gksu_quark, GKSU_ERROR_PIPE,
 		       _("Error opening pipe: %s"),
 		       strerror(errno));
 	  sudo_reset_xauth (context, xauth, xauth_env);
@@ -1431,56 +1331,51 @@
       if (context->debug)
 	fprintf (stderr, "buffer: -%s-\n", buffer);
 
-      if (strncmp(buffer, "GNOME_SUDO_PASS", 15) == 0) 
+      if (strncmp(buffer, "GNOME_SUDO_PASS", 15) == 0)
 	{
+	  gchar *password = NULL;
+
 	  if (context->debug)
 	    fprintf (stderr, "Yeah, we're in...\n");
 
-	  if ((context->password == NULL || (!strcmp (context->password, "")))
-	      && ask_pass == NULL)
-	    {
-	      g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_NOPASSWORD,
-			   _("No password was supplied and sudo needs it."));
-	      fprintf (outfile, "\n");
-	      sudo_reset_xauth (context, xauth, xauth_env);
-	      return -1;
-	    }
+	  password = ask_pass (context, _("Password: "),
+			       ask_pass_data, error);
+	  g_return_val_if_fail (password != NULL, -1);
 
-	  if (!context->password)
-	    {
-	      if (ask_pass (context, _("Password: "), user_data, error))
-		return -1;
-	      
-	      g_return_val_if_fail (context->password, -1);
-	    }
-	  
 	  usleep (100);
 
-	  fprintf (outfile, "%s", context->password);
+	  fprintf (outfile, "%s\n", password);
 	  fclose (outfile);
 
+	  nullify_password (password);
+
 	  /* ignore the newline that comes right after sudo receives
 	     the password
 	  */
 	  fgets (buffer, 255, infile);
 	  fgets (buffer, 255, infile);
-	} 
-      else 
+	}
+      else
 	{
+	  gboolean should_display;
 	  if (context->debug)
 	    fprintf (stderr, "No password prompt found; we'll assume we don't need a password.\n");
 
-	  if (pass_not_needed)
-	    pass_not_needed (context, pnn_user_data);
+	  should_display = gconf_client_get_bool (context->gconf_client,
+						  BASE_PATH "display-no-pass-info", NULL);
 
+	  /* configuration tells us to show this message */
+	  if (should_display)
+	    pass_not_needed (context, pass_not_needed_data);
+
 	  fprintf (stderr, "%s", buffer);
 	}
 
       if (!strcmp (buffer, "Sorry, try again.\n"))
-	g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_WRONGPASS,
+	g_set_error (error, gksu_quark, GKSU_ERROR_WRONGPASS,
 		     _("Wrong password."));
       else if (!strncmp (buffer, "Sorry, user ", 12))
-	g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_NOT_ALLOWED,
+	g_set_error (error, gksu_quark, GKSU_ERROR_NOT_ALLOWED,
 		     _("The underlying authorization mechanism (sudo) "
 		       "does not allow you to run this program. Contact "
 		       "the system administrator."));
@@ -1494,7 +1389,7 @@
 	    {
 	      needle += 1;
 	      if (!strncmp (needle, "is not in", 9))
-		g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_NOT_ALLOWED,
+		g_set_error (error, gksu_quark, GKSU_ERROR_NOT_ALLOWED,
 			     _("The underlying authorization mechanism (sudo) "
 			       "does not allow you to run this program. Contact "
 			       "the system administrator."));
@@ -1524,7 +1419,7 @@
 	  fprintf (stderr, "%s", buffer);
 	  fflush (stderr);
 	}
-      
+
       sudo_reset_xauth (context, xauth, xauth_env);
 
       if (WIFEXITED(status))
@@ -1545,14 +1440,14 @@
 		}
 
 	      if (error == NULL)
-		g_set_error (error, gksu_quark, 
-			     GKSU_CONTEXT_ERROR_CHILDFAILED,
+		g_set_error (error, gksu_quark,
+			     GKSU_ERROR_CHILDFAILED,
 			     _("sudo terminated with %d status"),
 			     WEXITSTATUS(status));
 	    }
 	}
     }
-  
+
   /* if error is set we have found an error condition */
   if (error)
     return TRUE;
@@ -1560,28 +1455,20 @@
   return FALSE;
 }
 
-/* DO NOT USE -- Deprecated */
 gboolean
-gksu_context_sudo_ask_and_run (GksuContext *context, GksuAskPasswordFunc ask_pass, 
-			       gpointer user_data, GError **error)
+gksu_sudo (gchar *command_line,
+	   GError **error)
 {
-  return gksu_context_sudo_run_full (context, ask_pass, user_data, NULL, NULL, error);
-}
+  GksuContext *context = gksu_context_new ();
+  gboolean retval;
 
-/**
- * gksu_context_sudo_run:
- * @context: a #GksuContext
- * @error: a #GError object to be filled with the error code or NULL
- *
- * This could be considered one of the main functions in GKSu.
- * it is responsible for doing the 'user changing' magic by
- * calling gksu_ask_password() if it needs the user's password
- * it behaves like sudo.
- *
- * Returns: the child's error status, 0 if all went fine, -1 if failed
- */
-gboolean
-gksu_context_sudo_run (GksuContext *context, GError **error)
-{
-  return gksu_context_sudo_run_full (context, NULL, NULL, NULL, NULL, error);
+  context->command = g_strdup (command_line);
+  context->user = g_strdup ("root");
+  retval = gksu_sudo_full (context,
+			   NULL, NULL,
+			   NULL, NULL,
+			   error);
+  gksu_context_free (context);
+
+  return retval;
 }

Modified: libgksu/branches/libgksu2/libgksu/gksu-context.h
===================================================================
--- libgksu/branches/libgksu2/libgksu/gksu-context.h	2005-12-03 13:25:43 UTC (rev 486)
+++ libgksu/branches/libgksu2/libgksu/gksu-context.h	2005-12-11 23:14:16 UTC (rev 487)
@@ -24,175 +24,98 @@
 #include <glib.h>
 #include <glib-object.h>
 
-#define GKSU_TYPE_CONTEXT (gksu_context_get_type ())
-#define GKSU_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GKSU_TYPE_CONTEXT, GksuContext))
-#define GKSU_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GKSU_TYPE_CONTEXT, GksuContextClass))
-#define GKSU_IS_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GKSU_TYPE_CONTEXT))
-#define GKSU_IS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GKSU_TYPE_CONTEXT))
-#define GKSU_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GKSU_TYPE_CONTEXT, GksuContextClass))
+#include <gtk/gtk.h>
 
+#include <gconf/gconf-client.h>
+
 G_BEGIN_DECLS
 
-typedef enum
+typedef struct
 {
-  GKSU_CONTEXT_ERROR_XAUTH,
-  GKSU_CONTEXT_ERROR_HELPER,
-  GKSU_CONTEXT_ERROR_NOCOMMAND,
-  GKSU_CONTEXT_ERROR_NOPASSWORD,
-  GKSU_CONTEXT_ERROR_FORK,
-  GKSU_CONTEXT_ERROR_EXEC,
-  GKSU_CONTEXT_ERROR_PIPE,
-  GKSU_CONTEXT_ERROR_PIPEREAD,
-  GKSU_CONTEXT_ERROR_WRONGPASS,
-  GKSU_CONTEXT_ERROR_CHILDFAILED,
-  GKSU_CONTEXT_ERROR_NOT_ALLOWED
-} GksuContextError;
+  /*
+   * Protected
+   */
 
-#define GKSU_TYPE_CONTEXT_ERROR (gksu_context_error_get_type ())
-
-typedef struct _GksuContext GksuContext;
-typedef struct _GksuContextClass GksuContextClass;
-
-/**
- * GksuContext:
- * @parent: #GksuContext is based on #GObject
- * @xauth: the X authorization token
- * @dir: the directory where the .Xauthority file is created in sudo
- * mode
- * @display: storage for the DISPLAY environment variable
- * @user: user gksu will switch to
- * @password: the password that should be passed to su or sudo
- * @command: which command to run with su
- * @login_shell: should run a login shell?
- * @keep_env: should the current environment be kept?
- * @debug: show debug information?
- * @ssh_fwd: are we running inside a ssh X11 forwarding
- * tunnel?
- *
- * Object that holds all configuration information, some
- * important environment variables and some meta-information
- * about mainly x authentication.
- *
- */
-struct _GksuContext
-{
-  GObject parent;
-
+  /* Xauth stuff */
   gchar *xauth;
   gchar *dir;
-
   gchar *display;
 
+  gboolean sudo_mode;
+
+  GConfClient *gconf_client;
+
+  /*
+   * Public
+   */
+
+  /* what to run, with whose powers */
   gchar *user;
-  gchar *password;
   gchar *command;
 
   gboolean login_shell;
   gboolean keep_env;
 
+  /* UI options */
+  gboolean grab;
+
   gboolean debug;
-  gboolean ssh_fwd;
-};
+} GksuContext;
 
-struct _GksuContextClass
+typedef enum
 {
-  GObjectClass parent;
-};
+  GKSU_ERROR_XAUTH,
+  GKSU_ERROR_HELPER,
+  GKSU_ERROR_NOCOMMAND,
+  GKSU_ERROR_NOPASSWORD,
+  GKSU_ERROR_FORK,
+  GKSU_ERROR_EXEC,
+  GKSU_ERROR_PIPE,
+  GKSU_ERROR_PIPEREAD,
+  GKSU_ERROR_WRONGPASS,
+  GKSU_ERROR_CHILDFAILED,
+  GKSU_ERROR_NOT_ALLOWED
+} GksuError;
 
-typedef gboolean (*GksuAskPasswordFunc) (GksuContext*, gchar*, gpointer, GError**);
-typedef void (*GksuPasswordNotNeededFunc) (GksuContext*, gpointer);
+typedef
+gchar*
+(*GksuAskPassFunc) (GksuContext *context, gchar *prompt,
+		    gpointer user_data, GError**);
 
-/* 
-   Context handling
-*/
+typedef
+void
+(*GksuPassNotNeededFunc) (GksuContext *context, gpointer user_data);
+
 GksuContext*
 gksu_context_new ();
 
 void
 gksu_context_free (GksuContext *context);
 
-/* 
-   getters and setters for the configuration
-   options
-*/
-void
-gksu_context_set_user (GksuContext *context, gchar *username);
-
-const gchar*
-gksu_context_get_user (GksuContext *context);
-
-void
-gksu_context_set_command (GksuContext *context, gchar *command);
-
-const gchar*
-gksu_context_get_command (GksuContext *context);
-
-void
-gksu_context_set_password (GksuContext *context, gchar *password);
-
-const gchar*
-gksu_context_get_password (GksuContext *context);
-
-void
-gksu_context_set_login_shell (GksuContext *context, gboolean value);
-
 gboolean
-gksu_context_get_login_shell (GksuContext *context);
+gksu_su_full (GksuContext *context,
+	      GksuAskPassFunc ask_pass,
+	      gpointer ask_pass_data,
+	      GksuPassNotNeededFunc pass_not_needed,
+	      gpointer pass_not_needed_data,
+	      GError **error);
 
-void
-gksu_context_set_keep_env (GksuContext *context, gboolean value);
-
 gboolean
-gksu_context_get_keep_env (GksuContext *context);
+gksu_su (gchar *command_line,
+	 GError **error);
 
-void
-gksu_context_set_debug (GksuContext *context, gboolean value);
-
 gboolean
-gksu_context_get_debug (GksuContext *context);
+gksu_sudo_full (GksuContext *context,
+		GksuAskPassFunc ask_pass,
+		gpointer ask_pass_data,
+		GksuPassNotNeededFunc pass_not_needed,
+		gpointer pass_not_needed_data,
+		GError **error);
 
-void
-gksu_context_set_ssh_fwd (GksuContext *context, gboolean value);
-
 gboolean
-gksu_context_get_ssh_fwd (GksuContext *context);
+gksu_sudo (gchar *command_line,
+	   GError **error);
 
-GType
-gksu_context_get_type (void);
-
-gboolean
-gksu_context_try_need_password (GksuContext *context);
-
-gboolean
-gksu_context_run_full (GksuContext *context, 
-		       GksuAskPasswordFunc ask_pass, gpointer user_data, 
-		       GksuPasswordNotNeededFunc pass_not_needed, 
-		       gpointer pnn_user_data, GError **error);
-
-gboolean
-gksu_context_run (GksuContext *context, GError **error);
-
-gboolean
-gksu_context_sudo_try_need_password (GksuContext *context);
-
-gboolean
-gksu_context_sudo_run_full (GksuContext *context, 
-			    GksuAskPasswordFunc ask_pass, gpointer user_data, 
-			    GksuPasswordNotNeededFunc pass_not_needed, 
-			    gpointer pnn_user_data, GError **error);
-
-gboolean
-gksu_context_sudo_run (GksuContext *context, GError **error);
-
-/* DO NOT USE - Deprecated */
-gboolean
-gksu_context_ask_and_run (GksuContext *context, GksuAskPasswordFunc ask_pass, 
-			  gpointer user_data, GError **error);
-
-gboolean
-gksu_context_sudo_ask_and_run (GksuContext *context, GksuAskPasswordFunc ask_pass, 
-			       gpointer user_data, GError **error);
-
 G_END_DECLS
 
 #endif

Modified: libgksu/branches/libgksu2/libgksu/test-gksu.c
===================================================================
--- libgksu/branches/libgksu2/libgksu/test-gksu.c	2005-12-03 13:25:43 UTC (rev 486)
+++ libgksu/branches/libgksu2/libgksu/test-gksu.c	2005-12-11 23:14:16 UTC (rev 487)
@@ -24,19 +24,16 @@
 
 #include "gksu.h"
 
-gboolean
-su_ask_pass (GksuContext *context, gchar *prompt, gpointer data, GError **error)
+gchar *
+su_ask_pass (GksuContext *context, gchar *prompt,
+	     gpointer data, GError **error)
 {
-  char *password;
-
-  password = getpass (prompt);
-  gksu_context_set_password (context, password);
-
-  return 0;
+  return getpass (prompt);
 }
 
 void
-password_not_needed (GksuContext *context, gpointer data)
+password_not_needed (GksuContext *context,
+		     gpointer data)
 {
   fprintf (stderr, "Will run %s as %s!\n", context->command, context->user);
 }
@@ -46,7 +43,6 @@
 {
   GksuContext *context;
   GError *error = NULL;
-  char *password;
   gboolean try_su = TRUE;
   gboolean try_sudo = TRUE;
 
@@ -58,59 +54,46 @@
 	try_su = FALSE;
     }
 
+  gtk_init (&argc, &argv);
+
   context = gksu_context_new ();
 
-  gksu_context_set_debug (context, TRUE);
-  gksu_context_set_command (context, "/usr/bin/X11/xterm");
+  context->debug = TRUE;
+  context->command = g_strdup ("/usr/bin/X11/xterm");
 
   if (try_su)
     {
-      if (gksu_context_try_need_password (context))
-	{
-	  password = getpass ("Type the root password: ");
-	  gksu_context_set_password (context, password);
-	}
-      
-      printf ("Testing gksu_run...\n");
-      gksu_context_run (context, &error);
+      printf ("Testing gksu_su...\n");
+      gksu_su ("/usr/bin/X11/xterm", &error);
       if (error)
-	fprintf (stderr, "gksu_run failed: %s\n", error->message);
+	fprintf (stderr, "gksu_su failed: %s\n", error->message);
 
-      gksu_context_set_password (context, NULL);
-      printf ("Testing gksu_ask_and_run...\n");
-      gksu_context_run_full (context, su_ask_pass, NULL, 
-			     password_not_needed, NULL, 
-			     &error);
-      gksu_context_set_password (context, NULL);
+      error = NULL;
+      printf ("Testing gksu_su_full...\n");
+      gksu_su_full (context,
+		    su_ask_pass, NULL,
+		    password_not_needed, NULL,
+		    &error);
     }
-  
+
+  /* of course you need to set up /etc/sudoers for this to work */
   if (try_sudo)
     {
+    printf ("Testing gksu_sudo...\n");
       error = NULL;
-      /* sudo may already have my authorization */
-      if (gksu_context_sudo_try_need_password (context))
-	{
-	  password = NULL;
-	  password = getpass ("Type your password(sudo): ");
-	  gksu_context_set_password (context, password);
-	}
-      
-      /* of course you need to set up /etc/sudoers for this to work */
-      printf ("Testing gksu_sudo_run...\n");
-      error = NULL;
-      gksu_context_sudo_run (context, &error);
+      gksu_sudo ("/usr/bin/X11/xterm", &error);
       if (error)
-	fprintf (stderr, "gksu_run failed: %s\n", error->message);
+	fprintf (stderr, "gksu_sudo failed: %s\n", error->message);
 
       error = NULL;
-      gksu_context_set_password (context, NULL);
-      gksu_context_sudo_run_full (context, su_ask_pass, NULL, 
-				  password_not_needed, NULL, 
-				  &error);
+      gksu_sudo_full (context,
+		      su_ask_pass, NULL,
+		      password_not_needed, NULL,
+		      &error);
       if (error)
-	fprintf (stderr, "gksu_run failed: %s\n", error->message);
+	fprintf (stderr, "gksu_sudo_full failed: %s\n", error->message);
     }
-      
+
   return 0;
 }
 

Copied: libgksu/branches/libgksu2/libgksuui/ChangeLog (from rev 469, libgksuui/trunk/ChangeLog)

Modified: libgksu/branches/libgksu2/libgksuui/Makefile.am
===================================================================
--- libgksu/branches/libgksu2/libgksuui/Makefile.am	2005-12-03 13:25:43 UTC (rev 486)
+++ libgksu/branches/libgksu2/libgksuui/Makefile.am	2005-12-11 23:14:16 UTC (rev 487)
@@ -16,11 +16,11 @@
 includedir = ${prefix}/include/$(PACKAGE)
 
 pkgconfigdir = ${libdir}/pkgconfig
-pkgconfig_DATA = $(PACKAGE).pc
+pkgconfig_DATA = libgksuui1.1.pc
 
 noinst_PROGRAMS = test-gksuui
 test_gksuui_SOURCES = test-gksuui.c
-test_gksuui_LDADD = $(PACKAGE).la
+test_gksuui_LDADD = libgksuui1.0.la
 test_gksuui_LDFLAGS = `pkg-config --libs glib-2.0`
 
 EXTRA_DIST = libgksuui.ver




More information about the gksu-commits mailing list