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.
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.
Do you have an updated patch for polkit 1.0?
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.