kov changed libgksu/trunk/ChangeLog, libgksu/trunk/libgksu/gksu-context.c

Gustavo Noronha kov at costa.debian.org
Wed Sep 28 19:31:10 UTC 2005


Mensagem de log: 
	* libgksu/gksu-context.c:
	- apply the same solution to handling error return
	  checking to the su backend



-----


Modified: libgksu/trunk/ChangeLog
===================================================================
--- libgksu/trunk/ChangeLog	2005-09-21 18:46:54 UTC (rev 446)
+++ libgksu/trunk/ChangeLog	2005-09-28 19:30:55 UTC (rev 447)
@@ -1,3 +1,9 @@
+2005-09-28  Gustavo Noronha Silva  <kov at debian.org>
+
+	* libgksu/gksu-context.c:
+	- apply the same solution to handling error return
+	  checking to the su backend
+
 2005-09-21  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-21 18:46:54 UTC (rev 446)
+++ libgksu/trunk/libgksu/gksu-context.c	2005-09-28 19:30:55 UTC (rev 447)
@@ -757,7 +757,6 @@
 {
   GQuark gksu_quark;
   int i = 0;
-  gboolean auth_failed = FALSE;
 
   gchar auxcommand[] = PREFIX "/lib/" PACKAGE "/gksu-run-helper";
 
@@ -843,6 +842,8 @@
       gchar buf[256] = {0};
       gint status;
 
+      gchar *cmdline = NULL;
+
       gboolean password_needed = FALSE;
 
       my_uid = getuid();
@@ -904,7 +905,9 @@
 
       if (!strncmp (buf, "su: Authentication failure", 26))
 	{
-	  auth_failed = TRUE;
+	  g_set_error (error, gksu_quark, 
+		       GKSU_CONTEXT_ERROR_WRONGPASS,
+		       _("Wrong password."));
 	  if (context->debug)
 	    fprintf (stderr, "DEBUG (auth_failed) buf: -%s-\n", buf);
 	}
@@ -956,6 +959,10 @@
 	  bzero (buf, 256);
 	  usleep (200);
 
+	  cmdline = get_process_name (pid);
+
+	  usleep(1000);
+
 	  if (select (fdpty+1, &rfds, NULL, NULL, &tv) < 0)
 	    {
 	      g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_PIPEREAD,
@@ -987,26 +994,32 @@
 	{
 	  if (WEXITSTATUS(status))
 	    {
-	      if (auth_failed)
+	      if(cmdline)
 		{
-		  if (context->debug)
-		    fprintf (stderr, "WRONGPASS!\n");
-		
-		  g_set_error (error, gksu_quark, 
-			       GKSU_CONTEXT_ERROR_WRONGPASS,
-			       _("Wrong password."));
+		  /* su already exec()ed something else, don't report
+		   * exit status errors in that case
+		   */
+		  if (!g_str_has_suffix (cmdline, "su\n"))
+		    {
+		      g_free (cmdline);
+		      return TRUE;
+		    }
+		  g_free (cmdline);
 		}
-	      else
+
+	      if (error == NULL)
 		g_set_error (error, gksu_quark, 
 			     GKSU_CONTEXT_ERROR_CHILDFAILED,
-			     _("Child terminated with %d status"),
+			     _("su terminated with %d status"),
 			     WEXITSTATUS(status));
-	      return WEXITSTATUS(status);
 	    }
 	}
     }
 
-  return 0;
+  if (error)
+    return TRUE;
+
+  return FALSE;
 }
 
 /* DO NOT USE -- Deprecated */




More information about the gksu-commits mailing list