PolicyKit: Branch 'master' - 2 commits

David Zeuthen david at kemper.freedesktop.org
Tue Dec 15 09:08:22 PST 2009


 src/polkitbackend/polkitbackendinteractiveauthority.c |    6 +++---
 src/programs/pkexec.c                                 |   15 ++++++++++++---
 2 files changed, 15 insertions(+), 6 deletions(-)

New commits:
commit 2a91f171e23a90aa837bdafe9bb4b3a66fddbb39
Author: David Zeuthen <davidz at redhat.com>
Date:   Tue Dec 15 12:03:53 2009 -0500

    Properly handle return value from getpwnam_r()
    
    Pointed out by Kay Sievers - thanks!
    
    Signed-off-by: David Zeuthen <davidz at redhat.com>

diff --git a/src/programs/pkexec.c b/src/programs/pkexec.c
index ba6ab36..ae0d842 100644
--- a/src/programs/pkexec.c
+++ b/src/programs/pkexec.c
@@ -214,6 +214,7 @@ main (int argc, char *argv[])
 {
   guint n;
   guint ret;
+  gint rc;
   gboolean opt_show_help;
   gboolean opt_show_version;
   PolkitAuthority *authority;
@@ -384,10 +385,18 @@ main (int argc, char *argv[])
       goto out;
     }
 
-  /* Look up information about the user we care about */
-  if (getpwnam_r (opt_user, &pwstruct, pwbuf, sizeof pwbuf, &pw) != 0)
+  /* Look up information about the user we care about - yes, the return
+   * value of this function is a bit funky
+   */
+  rc = getpwnam_r (opt_user, &pwstruct, pwbuf, sizeof pwbuf, &pw);
+  if (rc == 0 && pw == NULL)
+    {
+      g_printerr ("User `%s' does not exist.\n", opt_user);
+      goto out;
+    }
+  else if (pw == NULL)
     {
-      g_printerr ("Error getting information for user %s: %s\n", opt_user, g_strerror (errno));
+      g_printerr ("Error getting information for user `%s': %s\n", opt_user, g_strerror (rc));
       goto out;
     }
 
commit 3b7dfe47a66db58cd1f895771545f4cb3d1ae8e2
Author: David Zeuthen <davidz at redhat.com>
Date:   Tue Dec 15 12:03:26 2009 -0500

    Remove trailing whitespace from log messages
    
    Signed-off-by: David Zeuthen <davidz at redhat.com>

diff --git a/src/polkitbackend/polkitbackendinteractiveauthority.c b/src/polkitbackend/polkitbackendinteractiveauthority.c
index abf7cf4..004a99b 100644
--- a/src/polkitbackend/polkitbackendinteractiveauthority.c
+++ b/src/polkitbackend/polkitbackendinteractiveauthority.c
@@ -586,7 +586,7 @@ check_authorization_challenge_cb (AuthenticationAgent         *agent,
         {
           polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
                                         "Operator of %s successfully authenticated as %s to gain "
-                                        "TEMPORARY authorization for action %s for %s [%s] (owned by %s) ",
+                                        "TEMPORARY authorization for action %s for %s [%s] (owned by %s)",
                                         session_str,
                                         authenticated_identity_str,
                                         action_id,
@@ -598,7 +598,7 @@ check_authorization_challenge_cb (AuthenticationAgent         *agent,
         {
           polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
                                         "Operator of %s successfully authenticated as %s to gain "
-                                        "ONE-SHOT authorization for action %s for %s [%s] (owned by %s) ",
+                                        "ONE-SHOT authorization for action %s for %s [%s] (owned by %s)",
                                         session_str,
                                         authenticated_identity_str,
                                         action_id,
@@ -611,7 +611,7 @@ check_authorization_challenge_cb (AuthenticationAgent         *agent,
     {
       polkit_backend_authority_log (POLKIT_BACKEND_AUTHORITY (authority),
                                     "Operator of %s FAILED to authenticate to gain "
-                                    "authorization for action %s for %s [%s] (owned by %s) ",
+                                    "authorization for action %s for %s [%s] (owned by %s)",
                                     session_str,
                                     action_id,
                                     subject_str,


More information about the hal-commit mailing list