PolicyKit: Branch 'master' - 5 commits
David Zeuthen
david at kemper.freedesktop.org
Tue Mar 4 13:30:34 PST 2008
src/polkit-dbus/polkit-dbus.c | 2 +-
src/polkit-grant/polkit-grant-helper-shadow.c | 13 +++++--------
src/polkit-grant/polkit-grant-helper.c | 4 ++--
tools/polkit-policy-file-validate.c | 3 ++-
4 files changed, 10 insertions(+), 12 deletions(-)
New commits:
commit 5fbde20956aab779fd9dc50b512564f544ff8170
Author: Jim Meyering <meyering at redhat.com>
Date: Tue Mar 4 14:21:29 2008 +0100
handle kit_strdup failure.
* tools/polkit-policy-file-validate.c (validate_file):
Signed-off-by: Jim Meyering <meyering at redhat.com>
Signed-off-by: David Zeuthen <davidz at redhat.com>
diff --git a/tools/polkit-policy-file-validate.c b/tools/polkit-policy-file-validate.c
index c70de17..e77bbdd 100644
--- a/tools/polkit-policy-file-validate.c
+++ b/tools/polkit-policy-file-validate.c
@@ -99,7 +99,8 @@ validate_file (const char *file)
basename++;
else
basename = file;
- prefix = kit_strdup (basename);
+ if ((prefix = kit_strdup (basename)) == NULL)
+ goto out;
/* strip out "policy" - retain the dot */
prefix [strlen (prefix) - 6] = '\0';
commit 038354db125c1471d283c30dbade9fbb7e1eefb1
Author: Jim Meyering <meyering at redhat.com>
Date: Tue Mar 4 14:19:45 2008 +0100
avoid unnecessary/leaky use of strdup.
* polkit-grant-helper.c (main): Move the declaration of "buf"
to the outer scope and use a pointer into it, instead.
Signed-off-by: Jim Meyering <meyering at redhat.com>
Signed-off-by: David Zeuthen <davidz at redhat.com>
diff --git a/src/polkit-grant/polkit-grant-helper.c b/src/polkit-grant/polkit-grant-helper.c
index fbf6769..b0f59f8 100644
--- a/src/polkit-grant/polkit-grant-helper.c
+++ b/src/polkit-grant/polkit-grant-helper.c
@@ -555,6 +555,7 @@ main (int argc, char *argv[])
uid_t caller_uid;
PolKitSession *session;
gboolean empty_conversation;
+ char buf[256];
ret = 3;
@@ -708,7 +709,6 @@ main (int argc, char *argv[])
/* wait for libpolkit-grant to tell us what user to use */
if (admin_users != NULL) {
int n;
- char buf[256];
#ifdef PGH_DEBUG
fprintf (stderr, "waiting for admin user name...\n");
@@ -726,7 +726,7 @@ main (int argc, char *argv[])
goto out;
}
- user_to_auth = strdup (buf) + sizeof "POLKIT_GRANT_CALLER_SELECT_ADMIN_USER " - 1;
+ user_to_auth = buf + sizeof "POLKIT_GRANT_CALLER_SELECT_ADMIN_USER " - 1;
#ifdef PGH_DEBUG
fprintf (stderr, "libpolkit-grant wants to auth as '%s'\n", user_to_auth);
#endif /* PGH_DEBUG */
commit a8a97bc37d08da95b4e7a7907ba18a5e8447bc7e
Author: Jim Meyering <meyering at redhat.com>
Date: Tue Mar 4 14:09:52 2008 +0100
(do_auth): rename local: s/buf/password/
Signed-off-by: Jim Meyering <meyering at redhat.com>
Signed-off-by: David Zeuthen <davidz at redhat.com>
diff --git a/src/polkit-grant/polkit-grant-helper-shadow.c b/src/polkit-grant/polkit-grant-helper-shadow.c
index 9586c5f..d9d3ef1 100644
--- a/src/polkit-grant/polkit-grant-helper-shadow.c
+++ b/src/polkit-grant/polkit-grant-helper-shadow.c
@@ -126,19 +126,19 @@ error:
int do_auth (const char *user_to_auth)
{
struct spwd *shadow;
- char buf[256];
+ char password[256];
if ((shadow = getspnam (user_to_auth)) == NULL)
goto error;
- if (fgets (buf, sizeof (buf), stdin) == NULL)
+ if (fgets (password, sizeof (password), stdin) == NULL)
goto error;
- if (strlen (buf) > 0 &&
- buf[strlen (buf) - 1] == '\n')
- buf[strlen (buf) - 1] = '\0';
+ if (strlen (password) > 0 &&
+ password[strlen (password) - 1] == '\n')
+ password[strlen (password) - 1] = '\0';
- if (strcmp (shadow->sp_pwdp, crypt (buf, shadow->sp_pwdp)) != 0)
+ if (strcmp (shadow->sp_pwdp, crypt (password, shadow->sp_pwdp)) != 0)
goto error;
return 1;
commit 83445eb999c5e595f122a03e3a094a0d7941e67e
Author: Jim Meyering <meyering at redhat.com>
Date: Tue Mar 4 11:14:10 2008 +0100
remove unnecessary strdup.
* src/polkit-grant/polkit-grant-helper-shadow.c (do_auth):
Signed-off-by: Jim Meyering <meyering at redhat.com>
Signed-off-by: David Zeuthen <davidz at redhat.com>
diff --git a/src/polkit-grant/polkit-grant-helper-shadow.c b/src/polkit-grant/polkit-grant-helper-shadow.c
index 018e30a..9586c5f 100644
--- a/src/polkit-grant/polkit-grant-helper-shadow.c
+++ b/src/polkit-grant/polkit-grant-helper-shadow.c
@@ -126,7 +126,6 @@ error:
int do_auth (const char *user_to_auth)
{
struct spwd *shadow;
- char *password;
char buf[256];
if ((shadow = getspnam (user_to_auth)) == NULL)
@@ -139,9 +138,7 @@ int do_auth (const char *user_to_auth)
buf[strlen (buf) - 1] == '\n')
buf[strlen (buf) - 1] = '\0';
- password = strdup (buf);
-
- if (strcmp (shadow->sp_pwdp, crypt (password, shadow->sp_pwdp)) != 0)
+ if (strcmp (shadow->sp_pwdp, crypt (buf, shadow->sp_pwdp)) != 0)
goto error;
return 1;
commit 798208df31032eb028b004442119a77f1bd0bb76
Author: Jim Meyering <meyering at redhat.com>
Date: Tue Mar 4 11:12:48 2008 +0100
handle kit_strdup_printf failure.
* src/polkit-dbus/polkit-dbus.c (polkit_caller_new_from_pid):
Signed-off-by: Jim Meyering <meyering at redhat.com>
Signed-off-by: David Zeuthen <davidz at redhat.com>
diff --git a/src/polkit-dbus/polkit-dbus.c b/src/polkit-dbus/polkit-dbus.c
index fc329d3..54cc7f5 100644
--- a/src/polkit-dbus/polkit-dbus.c
+++ b/src/polkit-dbus/polkit-dbus.c
@@ -643,7 +643,7 @@ polkit_caller_new_from_pid (DBusConnection *con, pid_t pid, DBusError *error)
if (uid == (uid_t) -1) {
proc_path = kit_strdup_printf ("/proc/%d", pid);
- if (stat (proc_path, &statbuf) != 0) {
+ if (proc_path && stat (proc_path, &statbuf) != 0) {
kit_warning ("Cannot lookup information for pid %d: %s", pid, strerror (errno));
goto out;
}
More information about the hal-commit
mailing list