clients: check errors of polkit_unix_session_new_for_process_sync()

polkit_unix_session_new_for_process_sync() can fail. And calling
polkit_agent_listener_register() with NULL PolkitSubject results in errors.

https://bugzilla.gnome.org/show_bug.cgi?id=758625

(cherry picked from commit 542200f539)
This commit is contained in:
Jiří Klimeš 2015-11-25 10:51:44 +01:00
parent be8619261d
commit c7cb2e8c1c

View file

@ -323,9 +323,11 @@ nm_polkit_listener_new (gboolean for_session, GError **error)
listener = g_object_new (NM_TYPE_POLKIT_LISTENER, NULL);
priv = NM_POLKIT_LISTENER_GET_PRIVATE (listener);
if (for_session)
session = polkit_unix_session_new_for_process_sync (getpid (), NULL, NULL);
else
if (for_session) {
session = polkit_unix_session_new_for_process_sync (getpid (), NULL, error);
if (!session)
return NULL;
} else
session = polkit_unix_process_new_for_owner (getpid (), 0, getuid ());
priv->reg_handle = polkit_agent_listener_register (listener, POLKIT_AGENT_REGISTER_FLAGS_NONE,