Bug 20876 - Do not fail if PolicyKit cannot be initialized
Summary: Do not fail if PolicyKit cannot be initialized
Status: RESOLVED FIXED
Alias: None
Product: ConsoleKit
Classification: Unclassified
Component: Daemon (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: william.jon.mccann
QA Contact:
URL: https://launchpad.net/bugs/275432
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-26 02:36 UTC by Martin Pitt
Modified: 2009-07-23 10:41 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
patch (1.03 KB, patch)
2009-03-26 02:39 UTC, Martin Pitt
Details | Splinter Review

Description Martin Pitt 2009-03-26 02:36:38 UTC
There are various situations where polkit_context_init() fails:

 - PolicyKit daemon is not installed. This happens e. g. in a Debian or Ubuntu server installation (we split off the library to minimize dependencies)
 - PolicyKit.conf does not exist or is invalid

Right now, CK aborts with

Sep 28 22:10:01 acheron console-kit-daemon[13695]: CRITICAL: cannot initialize libpolkit

However, I think that's too strong. Even without PK, CK is still useful for session tracking. If this happens, CK should behave as if it was compiled without PK support, not abort completely.
Comment 1 Martin Pitt 2009-03-26 02:39:37 UTC
Created attachment 24268 [details] [review]
patch

This patch implements the suggested behaviour. If PK fails to initialize, pol_ctx is unref'ed and kept as NULL. polkit_context_is_caller_authorized() defaults to "NO" if the passed context is NULL, thus when trying to call CK's .Stop() function over D-Bus, the caller gets a proper "not authorized" response.
Comment 2 Ray Strode 2009-07-20 14:32:09 UTC
Do you have an updated patch for polkit 1.0?
Comment 3 Martin Pitt 2009-07-23 10:41:06 UTC
This patch isn't necessary any more with the polkit 1.0 update. That does:

 #ifdef HAVE_POLKIT
-        manager->priv->pol_ctx = polkit_context_new ();
-        polkit_context_set_io_watch_functions (manager->priv->pol_ctx, pk_io_add_watch, pk_io_remove_watch);
-        if (! polkit_context_init (manager->priv->pol_ctx, NULL)) {
-                g_critical ("cannot initialize libpolkit");
-                return FALSE;
-        }
+        manager->priv->pol_ctx = polkit_authority_get ();
 #endif

I. e. it already removed the g_critical()/return FALSE, which is sort of what my previous patch was doing as well. Since the polkit patch was committed now (thanks!), I close this bug.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.