Commit 7f4df53f authored by David Zeuthen's avatar David Zeuthen
Browse files

fix a bug where KitList elements were not properly freed

parent 23f01abc
......@@ -773,6 +773,13 @@ out:
return caller;
}
static kit_bool_t
_free_elem_in_list (KitList *list, void *data, void *user_data)
{
kit_free (data);
return FALSE;
}
static KitList *
_get_list_of_sessions (DBusConnection *con, uid_t uid, DBusError *error)
{
......@@ -806,7 +813,7 @@ _get_list_of_sessions (DBusConnection *con, uid_t uid, DBusError *error)
if (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_OBJECT_PATH) {
kit_warning ("Wrong reply from ConsoleKit (element is not a string)");
kit_list_foreach (ret, (KitListForeachFunc) kit_free, NULL);
kit_list_foreach (ret, _free_elem_in_list, NULL);
kit_list_free (ret);
goto out;
}
......@@ -870,17 +877,19 @@ _polkit_is_authorization_relevant_internal (DBusConnection *con,
del_sessions = TRUE;
}
for (i = sessions; i != NULL; i = i->next) {
char *session_id = i->data;
if (strcmp (session_id, polkit_authorization_scope_session_get_ck_objref (auth)) == 0) {
ret = TRUE;
break;
if (sessions != NULL) {
for (i = sessions; i != NULL; i = i->next) {
char *session_id = i->data;
if (strcmp (session_id, polkit_authorization_scope_session_get_ck_objref (auth)) == 0) {
ret = TRUE;
break;
}
}
if (del_sessions) {
kit_list_foreach (sessions, _free_elem_in_list, NULL);
kit_list_free (sessions);
}
}
if (del_sessions) {
kit_list_foreach (sessions, (KitListForeachFunc) kit_free, NULL);
kit_list_free (sessions);
}
break;
......
......@@ -58,6 +58,7 @@
*/
#undef PGH_DEBUG
/* #define PGH_DEBUG */
#define PGH_DEBUG
/* synopsis: polkit-grant-helper <pid> <action-name>
*
......@@ -157,7 +158,7 @@
*
*/
static polkit_bool_t
do_auth (const char *user_to_auth)
do_auth (const char *user_to_auth, gboolean *empty_conversation)
{
int helper_pid;
int helper_stdin;
......@@ -172,6 +173,7 @@ do_auth (const char *user_to_auth)
child_stdin = NULL;
child_stdout = NULL;
ret = FALSE;
*empty_conversation = TRUE;
g_error = NULL;
if (!g_spawn_async_with_pipes (NULL,
......@@ -223,6 +225,9 @@ do_auth (const char *user_to_auth)
if (strcmp (buf, "FAILURE\n") == 0) {
goto out;
}
*empty_conversation = FALSE;
/* send to parent */
fprintf (stdout, buf);
fflush (stdout);
......@@ -536,6 +541,7 @@ main (int argc, char *argv[])
PolKitCaller *caller;
uid_t caller_uid;
PolKitSession *session;
gboolean empty_conversation;
ret = 3;
......@@ -749,10 +755,14 @@ main (int argc, char *argv[])
ret = 1;
/* Start authentication */
if (!do_auth (user_to_auth)) {
if (!do_auth (user_to_auth, &empty_conversation)) {
goto out;
}
#ifdef PGH_DEBUG
fprintf (stderr, "polkit-grant-helper: empty_conversation=%d\n", empty_conversation);
#endif /* PGH_DEBUG */
/* Ask caller if he want to slim down grant type... e.g. he
* might want to go from auth_self_keep_always to
* auth_self_keep_session..
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment