ptp-helper: Make sure to use g_poll() for the main context
authorSebastian Dröge <sebastian@centricular.com>
Thu, 4 Jun 2015 17:05:44 +0000 (19:05 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Thu, 4 Jun 2015 17:05:44 +0000 (19:05 +0200)
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.

libs/gst/helpers/gst-ptp-helper.c

index 1473cf7..fdae3ba 100644 (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");