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

Gustavo Noronha kov at costa.debian.org
Sun Aug 21 01:33:50 UTC 2005


Mensagem de log: 
	* libgksu/gksu-context.{c,h}:
	- improve error reporting for sudo; tries to detect if sudo
	  reported that the user cannot run the command for that user



-----


Modified: libgksu/trunk/ChangeLog
===================================================================
--- libgksu/trunk/ChangeLog	2005-08-21 01:29:44 UTC (rev 424)
+++ libgksu/trunk/ChangeLog	2005-08-21 01:33:49 UTC (rev 425)
@@ -1,3 +1,9 @@
+2005-08-20  Gustavo Noronha Silva  <kov at debian.org>
+
+	* libgksu/gksu-context.{c,h}:
+	- improve error reporting for sudo; tries to detect if sudo
+	  reported that the user cannot run the command for that user
+
 2005-08-02  Gustavo Noronha Silva  <kov at debian.org>
 
 	* Release 1.3.3

Modified: libgksu/trunk/libgksu/gksu-context.c
===================================================================
--- libgksu/trunk/libgksu/gksu-context.c	2005-08-21 01:29:44 UTC (rev 424)
+++ libgksu/trunk/libgksu/gksu-context.c	2005-08-21 01:33:49 UTC (rev 425)
@@ -1408,8 +1408,6 @@
 	  */
 	  fgets (buffer, 255, infile);
 	  fgets (buffer, 255, infile);
-	  if (!strcmp (buffer, "Sorry, try again.\n"))
-	    auth_failed = TRUE;
 	} 
       else 
 	{
@@ -1421,6 +1419,14 @@
 	  fprintf (stderr, "%s", buffer);
 	}
 
+      if (!strcmp (buffer, "Sorry, try again.\n"))
+	g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_WRONGPASS,
+		     _("Wrong password."));
+      else if (!strncmp (buffer, "Sorry, user ", 12))
+	g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_NOT_ALLOWED,
+		     _("The underlying authorization mechanism (sudo) "
+		       "does not allow you to run this program. Contact "
+		       "the system administrator."));
 
       while (!waitpid (pid, &status, WNOHANG))
 	{
@@ -1445,20 +1451,14 @@
       if (WIFEXITED(status))
 	{
 	  if (WEXITSTATUS(status))
-	    {
-	      if (auth_failed)
-		g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_WRONGPASS,
-			     _("Wrong password."));
-	      else
-		g_set_error (error, gksu_quark, GKSU_CONTEXT_ERROR_CHILDFAILED,
-			     _("Child terminated with %d status"),
-			     WEXITSTATUS(status));
-
-	      return TRUE;
-	    }
+	    return TRUE;
 	}
     }
   
+  /* if error is set we have found an error condition */
+  if (error)
+    return TRUE;
+
   return FALSE;
 }
 

Modified: libgksu/trunk/libgksu/gksu-context.h
===================================================================
--- libgksu/trunk/libgksu/gksu-context.h	2005-08-21 01:29:44 UTC (rev 424)
+++ libgksu/trunk/libgksu/gksu-context.h	2005-08-21 01:33:49 UTC (rev 425)
@@ -44,7 +44,8 @@
   GKSU_CONTEXT_ERROR_PIPE,
   GKSU_CONTEXT_ERROR_PIPEREAD,
   GKSU_CONTEXT_ERROR_WRONGPASS,
-  GKSU_CONTEXT_ERROR_CHILDFAILED
+  GKSU_CONTEXT_ERROR_CHILDFAILED,
+  GKSU_CONTEXT_ERROR_NOT_ALLOWED
 } GksuContextError;
 
 #define GKSU_TYPE_CONTEXT_ERROR (gksu_context_error_get_type ())




More information about the gksu-commits mailing list