ptp-helper: Make sure to use g_poll() for the main context

The modified main context from https://bugzilla.gnome.org/show_bug.cgi?id=741054
somehow calls setugid(), which abort()s setuid root applications on OSX.
This commit is contained in:
Sebastian Dröge 2015-06-04 19:05:44 +02:00
parent c7c1dcd346
commit f02de0e9a1

View file

@ -612,6 +612,14 @@ write_clock_id (void)
}
}
#ifdef __APPLE__
static gint
dummy_poll (GPollFD * fds, guint nfds, gint timeout)
{
return g_poll (fds, nfds, timeout);
}
#endif
gint
main (gint argc, gchar ** argv)
{
@ -619,6 +627,20 @@ main (gint argc, gchar ** argv)
GMainLoop *loop;
GError *err = NULL;
/* FIXME: Work around some side effects of the changes from
* https://bugzilla.gnome.org/show_bug.cgi?id=741054
*
* The modified poll function somehow calls setugid(), which
* then abort()s the application. Make sure that we use g_poll()
* here!
*/
#ifdef __APPLE__
{
GMainContext *context = g_main_context_default ();
g_main_context_set_poll_func (context, dummy_poll);
}
#endif
#ifdef HAVE_PTP_HELPER_SETUID
if (setuid (0) < 0)
g_error ("not running with superuser privileges");