[neon/backports-focal/iio-sensor-proxy/Neon/unstable] /: New upstream version 2.2

Ritesh Raj Sarraf null at kde.org
Fri Oct 9 07:46:07 BST 2020


Git commit c384da59723a93d7db5947fadbfd01c4d8d905fe by Ritesh Raj Sarraf.
Committed on 20/02/2017 at 17:46.
Pushed by bshah into tag 'Neon/unstable'.

New upstream version 2.2

M  +18   -0    NEWS
M  +32   -14   README
M  +32   -14   README.md
M  +10   -10   configure
M  +1    -1    configure.ac
M  +1    -1    data/80-iio-sensor-proxy.rules
M  +10   -0    data/iio-sensor-proxy.service.in
M  +12   -12   data/net.hadess.SensorProxy.conf
M  +3    -3    docs/Makefile.in
M  +2    -2    src/drv-fake-compass.c
M  +44   -39   src/iio-sensor-proxy.c
M  +8    -3    src/monitor-sensor.c

https://invent.kde.org/neon/backports-focal/iio-sensor-proxy/commit/c384da59723a93d7db5947fadbfd01c4d8d905fe

diff --git a/NEWS b/NEWS
index bcce427..3566680 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,21 @@
+2.2
+---
+
+This release fixes iio-sensor-proxy not receiving udev events
+because of the excessive lockdown added in version 2.1. This
+also fixes a possible crash on startup due to a race condition.
+
+2.1
+---
+
+This release fixes a security problem that will affect services
+other than iio-sensor-proxy, that have a system D-Bus interface.
+Upgrading to this version is highly recommended.
+
+- Make D-Bus policy rules only affect SensorProxy itself
+- Lockdown service through systemd
+- Fix startup problem on machines with a Compass device
+
 2.0
 ---
 
diff --git a/README b/README
index 679d4c5..dd26ad6 100644
--- a/README
+++ b/README
@@ -13,7 +13,7 @@ Installation
 make
 make install
 ```
-It requires libgudev and systemd.
+It requires libgudev and systemd (>= 233 for the accelerometer quirks).
 
 Usage
 -----
@@ -72,6 +72,20 @@ orientation matches the screen one.
 `ACCEL_MOUNT_MATRIX` udev property. See [60-sensor.hwdb](https://github.com/systemd/systemd/blob/master/hwdb/60-sensor.hwdb)
 for details.
 
+Compass testing
+---------------
+
+Only the Geoclue daemon (as the geoclue user) is allowed to access the `net.hadess.SensorProxy.Compass`
+interface, the results of which it will propagate to clients along with positional information.
+
+If your device does not contain a compass, you can run tests with:
+- If your device does not contain a real compass:
+  - Add FAKE_COMPASS=1 to the environment of `iio-sensor-proxy.service` if your device does not contain a real one
+  - Run the daemon manually with `systemctl start iio-sensor-proxy.service`
+- Verify that iio-sensor-proxy is running with `systemctl` or `ps`
+- As root, get a shell as the `geoclue` user with `su -s /bin/bash geoclue`
+- Run, as the `geoclue` user, `monitor-sensor`
+
 References
 ----------
 
@@ -82,22 +96,26 @@ References
 Tested on
 ---------
 
+- Apple MacBook Air (4,2)
+- Apple MacBook Air (6,2)
+- Apple MacBook Pro (8.2)
+- Asus Transformer Book TP500LB
+- Asus Zenbook UX31A, UX303L, UX305
+- Cube i9
+- Dell Inspiron 13 7000
+- Dell Venue 11 Pro (7140)
+- Dell Venue 8 Pro
+- HP Pavilion X360
+- HP Spectre x360 (Kaby Lake)
 - Lenovo IdeaPad Yoga 13
-- Microsoft Surface Pro 2
-- Lenovo Yoga 2 Pro
+- Lenovo ThinkPad Twist
+- Lenovo X1 Carbon 2014 (rev2)
+- Lenovo X1 Tablet
 - Lenovo Yoga 2 13" and 11"
+- Lenovo Yoga 2 Pro
+- Lenovo Yoga 460
 - Lenovo Yoga 900
+- Microsoft Surface Pro 2
 - Onda v975w
-- Dell Venue 8 Pro
-- Dell Venue 11 Pro (7140)
-- Lenovo ThinkPad Twist
-- MacBook Pro (8.2)
-- Lenovo X1 Carbon 2014 (rev2)
-- MacBook Air (6,2)
-- MacBook Air (4,2)
 - Toshiba Portégé Z10t
 - Toshiba Radius 11 L10WC10C
-- Dell Inspiron 13 7000
-- Cube i9
-- HP Pavilion X360
-- Asus Zenbook UX31A, UX305
diff --git a/README.md b/README.md
index 679d4c5..dd26ad6 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@ Installation
 make
 make install
 ```
-It requires libgudev and systemd.
+It requires libgudev and systemd (>= 233 for the accelerometer quirks).
 
 Usage
 -----
@@ -72,6 +72,20 @@ orientation matches the screen one.
 `ACCEL_MOUNT_MATRIX` udev property. See [60-sensor.hwdb](https://github.com/systemd/systemd/blob/master/hwdb/60-sensor.hwdb)
 for details.
 
+Compass testing
+---------------
+
+Only the Geoclue daemon (as the geoclue user) is allowed to access the `net.hadess.SensorProxy.Compass`
+interface, the results of which it will propagate to clients along with positional information.
+
+If your device does not contain a compass, you can run tests with:
+- If your device does not contain a real compass:
+  - Add FAKE_COMPASS=1 to the environment of `iio-sensor-proxy.service` if your device does not contain a real one
+  - Run the daemon manually with `systemctl start iio-sensor-proxy.service`
+- Verify that iio-sensor-proxy is running with `systemctl` or `ps`
+- As root, get a shell as the `geoclue` user with `su -s /bin/bash geoclue`
+- Run, as the `geoclue` user, `monitor-sensor`
+
 References
 ----------
 
@@ -82,22 +96,26 @@ References
 Tested on
 ---------
 
+- Apple MacBook Air (4,2)
+- Apple MacBook Air (6,2)
+- Apple MacBook Pro (8.2)
+- Asus Transformer Book TP500LB
+- Asus Zenbook UX31A, UX303L, UX305
+- Cube i9
+- Dell Inspiron 13 7000
+- Dell Venue 11 Pro (7140)
+- Dell Venue 8 Pro
+- HP Pavilion X360
+- HP Spectre x360 (Kaby Lake)
 - Lenovo IdeaPad Yoga 13
-- Microsoft Surface Pro 2
-- Lenovo Yoga 2 Pro
+- Lenovo ThinkPad Twist
+- Lenovo X1 Carbon 2014 (rev2)
+- Lenovo X1 Tablet
 - Lenovo Yoga 2 13" and 11"
+- Lenovo Yoga 2 Pro
+- Lenovo Yoga 460
 - Lenovo Yoga 900
+- Microsoft Surface Pro 2
 - Onda v975w
-- Dell Venue 8 Pro
-- Dell Venue 11 Pro (7140)
-- Lenovo ThinkPad Twist
-- MacBook Pro (8.2)
-- Lenovo X1 Carbon 2014 (rev2)
-- MacBook Air (6,2)
-- MacBook Air (4,2)
 - Toshiba Portégé Z10t
 - Toshiba Radius 11 L10WC10C
-- Dell Inspiron 13 7000
-- Cube i9
-- HP Pavilion X360
-- Asus Zenbook UX31A, UX305
diff --git a/configure b/configure
index d3f0324..9b1cfa4 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for iio-sensor-proxy 2.0.
+# Generated by GNU Autoconf 2.69 for iio-sensor-proxy 2.2.
 #
 # Report bugs to <hadess at hadess.net>.
 #
@@ -580,8 +580,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='iio-sensor-proxy'
 PACKAGE_TARNAME='iio-sensor-proxy'
-PACKAGE_VERSION='2.0'
-PACKAGE_STRING='iio-sensor-proxy 2.0'
+PACKAGE_VERSION='2.2'
+PACKAGE_STRING='iio-sensor-proxy 2.2'
 PACKAGE_BUGREPORT='hadess at hadess.net'
 PACKAGE_URL=''
 
@@ -1287,7 +1287,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures iio-sensor-proxy 2.0 to adapt to many kinds of systems.
+\`configure' configures iio-sensor-proxy 2.2 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1358,7 +1358,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of iio-sensor-proxy 2.0:";;
+     short | recursive ) echo "Configuration of iio-sensor-proxy 2.2:";;
    esac
   cat <<\_ACEOF
 
@@ -1480,7 +1480,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-iio-sensor-proxy configure 2.0
+iio-sensor-proxy configure 2.2
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1581,7 +1581,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by iio-sensor-proxy $as_me 2.0, which was
+It was created by iio-sensor-proxy $as_me 2.2, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2460,7 +2460,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='iio-sensor-proxy'
- VERSION='2.0'
+ VERSION='2.2'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -6226,7 +6226,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by iio-sensor-proxy $as_me 2.0, which was
+This file was extended by iio-sensor-proxy $as_me 2.2, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -6283,7 +6283,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-iio-sensor-proxy config.status 2.0
+iio-sensor-proxy config.status 2.2
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
index f8ded66..212aae3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
 AC_PREREQ(2.59)
 
-AC_INIT([iio-sensor-proxy], [2.0], [hadess at hadess.net])
+AC_INIT([iio-sensor-proxy], [2.2], [hadess at hadess.net])
 
 AX_IS_RELEASE([git-directory])
 
diff --git a/data/80-iio-sensor-proxy.rules b/data/80-iio-sensor-proxy.rules
index c7b3bef..06040dc 100644
--- a/data/80-iio-sensor-proxy.rules
+++ b/data/80-iio-sensor-proxy.rules
@@ -7,7 +7,7 @@ ACTION=="remove", GOTO="iio_sensor_proxy_end"
 SUBSYSTEM=="hwmon", TEST=="light", ENV{IIO_SENSOR_PROXY_TYPE}="hwmon-als"
 SUBSYSTEM=="iio", TEST=="in_accel_x_raw", TEST=="in_accel_y_raw", TEST=="in_accel_z_raw", ENV{IIO_SENSOR_PROXY_TYPE}="iio-poll-accel"
 SUBSYSTEM=="iio", TEST=="scan_elements/in_accel_x_en", TEST=="scan_elements/in_accel_y_en", TEST=="scan_elements/in_accel_z_en", ENV{IIO_SENSOR_PROXY_TYPE}="iio-buffer-accel"
-SUBSYSTEM=="iio", TEST=="scan_elements/in_rot_from_north_magnetic_tilt_comp_en", ENV{IIO_SENSOR_PROXY_TYPE}="iio-compass"
+SUBSYSTEM=="iio", TEST=="scan_elements/in_rot_from_north_magnetic_tilt_comp_en", ENV{IIO_SENSOR_PROXY_TYPE}="iio-buffer-compass"
 SUBSYSTEM=="iio", TEST=="in_illuminance_input", ENV{IIO_SENSOR_PROXY_TYPE}="iio-poll-als"
 SUBSYSTEM=="iio", TEST=="scan_elements/in_intensity_both_en", ENV{IIO_SENSOR_PROXY_TYPE}="iio-buffer-als"
 SUBSYSTEM=="input", ENV{ID_INPUT_ACCELEROMETER}=="1", ENV{IIO_SENSOR_PROXY_TYPE}="input-accel"
diff --git a/data/iio-sensor-proxy.service.in b/data/iio-sensor-proxy.service.in
index e4b6e78..01e1e79 100644
--- a/data/iio-sensor-proxy.service.in
+++ b/data/iio-sensor-proxy.service.in
@@ -7,3 +7,13 @@ BusName=net.hadess.SensorProxy
 ExecStart=@sbindir@/iio-sensor-proxy
 #Uncomment this to enable debug
 #Environment="G_MESSAGES_DEBUG=all"
+
+# Lockdown
+ProtectSystem=true
+ProtectControlGroups=true
+ProtectHome=true
+ProtectKernelModules=true
+PrivateTmp=true
+RestrictAddressFamilies=AF_UNIX AF_LOCAL AF_NETLINK
+MemoryDenyWriteExecute=true
+RestrictRealtime=true
diff --git a/data/net.hadess.SensorProxy.conf b/data/net.hadess.SensorProxy.conf
index d489aff..51dcd28 100644
--- a/data/net.hadess.SensorProxy.conf
+++ b/data/net.hadess.SensorProxy.conf
@@ -12,22 +12,22 @@
 
   <!-- Only Geoclue can access the compass -->
   <policy user="geoclue">
-    <allow send_interface="net.hadess.SensorProxy.Compass" send_path="/net/hadess/SensorProxy/Compass"/>
-    <allow send_interface="org.freedesktop.DBus.Introspectable" send_path="/net/hadess/SensorProxy/Compass"/>
-    <allow send_interface="org.freedesktop.DBus.Properties" send_path="/net/hadess/SensorProxy/Compass"/>
-    <allow send_interface="org.freedesktop.DBus.Peer" send_path="/net/hadess/SensorProxy/Compass"/>
+    <allow send_destination="net.hadess.SensorProxy" send_interface="net.hadess.SensorProxy.Compass" send_path="/net/hadess/SensorProxy/Compass"/>
+    <allow send_destination="net.hadess.SensorProxy" send_interface="org.freedesktop.DBus.Introspectable" send_path="/net/hadess/SensorProxy/Compass"/>
+    <allow send_destination="net.hadess.SensorProxy" send_interface="org.freedesktop.DBus.Properties" send_path="/net/hadess/SensorProxy/Compass"/>
+    <allow send_destination="net.hadess.SensorProxy" send_interface="org.freedesktop.DBus.Peer" send_path="/net/hadess/SensorProxy/Compass"/>
   </policy>
 
   <!-- Anyone can talk to the main interface -->
   <policy context="default">
-    <allow send_interface="net.hadess.SensorProxy"/>
-    <allow send_interface="org.freedesktop.DBus.Introspectable"/>
-    <allow send_interface="org.freedesktop.DBus.Properties"/>
-    <allow send_interface="org.freedesktop.DBus.Peer"/>
-    <deny send_interface="org.freedesktop.DBus.Introspectable" send_path="/net/hadess/SensorProxy/Compass"/>
-    <deny send_interface="org.freedesktop.DBus.Properties" send_path="/net/hadess/SensorProxy/Compass"/>
-    <deny send_interface="org.freedesktop.DBus.Peer" send_path="/net/hadess/SensorProxy/Compass"/>
-    <!-- <deny send_interface="net.hadess.SensorProxy.Compass"/> -->
+    <allow send_destination="net.hadess.SensorProxy" send_interface="net.hadess.SensorProxy"/>
+    <allow send_destination="net.hadess.SensorProxy" send_interface="org.freedesktop.DBus.Introspectable"/>
+    <allow send_destination="net.hadess.SensorProxy" send_interface="org.freedesktop.DBus.Properties"/>
+    <allow send_destination="net.hadess.SensorProxy" send_interface="org.freedesktop.DBus.Peer"/>
+    <deny send_destination="net.hadess.SensorProxy" send_interface="org.freedesktop.DBus.Introspectable" send_path="/net/hadess/SensorProxy/Compass"/>
+    <deny send_destination="net.hadess.SensorProxy" send_interface="org.freedesktop.DBus.Properties" send_path="/net/hadess/SensorProxy/Compass"/>
+    <deny send_destination="net.hadess.SensorProxy" send_interface="org.freedesktop.DBus.Peer" send_path="/net/hadess/SensorProxy/Compass"/>
+    <!-- <deny send_destination="net.hadess.SensorProxy" send_interface="net.hadess.SensorProxy.Compass"/> -->
   </policy>
 
 </busconfig>
diff --git a/docs/Makefile.in b/docs/Makefile.in
index 174595d..32cd900 100644
--- a/docs/Makefile.in
+++ b/docs/Makefile.in
@@ -499,11 +499,11 @@ maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
 	@echo "it deletes files that may require special tools to rebuild."
 	-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
- at ENABLE_GTK_DOC_FALSE@maintainer-clean-local:
- at ENABLE_GTK_DOC_FALSE@install-data-local:
 @ENABLE_GTK_DOC_FALSE at clean-local:
- at ENABLE_GTK_DOC_FALSE@uninstall-local:
 @ENABLE_GTK_DOC_FALSE at distclean-local:
+ at ENABLE_GTK_DOC_FALSE@maintainer-clean-local:
+ at ENABLE_GTK_DOC_FALSE@uninstall-local:
+ at ENABLE_GTK_DOC_FALSE@install-data-local:
 clean: clean-am
 
 clean-am: clean-generic clean-local mostlyclean-am
diff --git a/src/drv-fake-compass.c b/src/drv-fake-compass.c
index b3a9c87..900d197 100644
--- a/src/drv-fake-compass.c
+++ b/src/drv-fake-compass.c
@@ -34,8 +34,8 @@ fake_compass_discover (GUdevDevice *device)
 	if (g_strcmp0 (g_udev_device_get_subsystem (device), "input") != 0)
 		return FALSE;
 
-	/* "Lid switch" is a random input device to latch onto */
-	if (g_strcmp0 (g_udev_device_get_property (device, "NAME"), "\"Lid Switch\"") != 0)
+	/* "Power Button" is a random input device to latch onto */
+	if (g_strcmp0 (g_udev_device_get_property (device, "NAME"), "\"Power Button\"") != 0)
 		return FALSE;
 
 	g_debug ("Found fake compass at %s", g_udev_device_get_sysfs_path (device));
diff --git a/src/iio-sensor-proxy.c b/src/iio-sensor-proxy.c
index 667be26..e4765de 100644
--- a/src/iio-sensor-proxy.c
+++ b/src/iio-sensor-proxy.c
@@ -33,10 +33,11 @@
 
 typedef struct {
 	GMainLoop *loop;
+	GUdevClient *client;
 	GDBusNodeInfo *introspection_data;
 	GDBusConnection *connection;
 	guint name_id;
-	gboolean init_done;
+	int ret;
 
 	SensorDriver *drivers[NUM_SENSOR_TYPES];
 	GUdevDevice  *devices[NUM_SENSOR_TYPES];
@@ -85,6 +86,11 @@ driver_type_to_str (DriverType type)
 #define DRIVER_FOR_TYPE(driver_type) data->drivers[driver_type]
 #define DEVICE_FOR_TYPE(driver_type) data->devices[driver_type]
 
+static void sensor_changes (GUdevClient *client,
+			    gchar       *action,
+			    GUdevDevice *device,
+			    SensorData  *data);
+
 static gboolean
 driver_type_exists (SensorData *data,
 		    DriverType  driver_type)
@@ -540,11 +546,40 @@ name_acquired_handler (GDBusConnection *connection,
 		       gpointer         user_data)
 {
 	SensorData *data = user_data;
+	const gchar * const subsystems[] = { "iio", "input", "platform", NULL };
+	guint i;
+
+	data->client = g_udev_client_new (subsystems);
+	if (!find_sensors (data->client, data))
+		goto bail;
+
+	g_signal_connect (G_OBJECT (data->client), "uevent",
+			  G_CALLBACK (sensor_changes), data);
+
+	for (i = 0; i < NUM_SENSOR_TYPES; i++) {
+		data->clients[i] = create_clients_hash_table ();
+
+		if (!driver_type_exists (data, i))
+			continue;
 
-	if (data->init_done) {
-		send_dbus_event (data, PROP_ALL);
-		send_dbus_event (data, PROP_ALL_COMPASS);
+		if (!driver_open (DRIVER_FOR_TYPE(i), DEVICE_FOR_TYPE(i),
+				  driver_type_to_callback_func (data->drivers[i]->type), data)) {
+			DRIVER_FOR_TYPE(i) = NULL;
+			g_clear_object (&DEVICE_FOR_TYPE(i));
+		}
 	}
+
+	if (!any_sensors_left (data))
+		goto bail;
+
+	send_dbus_event (data, PROP_ALL);
+	send_dbus_event (data, PROP_ALL_COMPASS);
+	return;
+
+bail:
+	data->ret = 0;
+	g_debug ("Could not find any supported sensors");
+	g_main_loop_quit (data->loop);
 }
 
 static gboolean
@@ -686,6 +721,7 @@ free_sensor_data (SensorData *data)
 
 	g_clear_pointer (&data->introspection_data, g_dbus_node_info_unref);
 	g_clear_object (&data->connection);
+	g_clear_object (&data->client);
 	g_clear_pointer (&data->loop, g_main_loop_unref);
 	g_free (data);
 }
@@ -698,6 +734,9 @@ sensor_changes (GUdevClient *client,
 {
 	guint i;
 
+	g_debug ("Sensor changes: action = %s, device = %s",
+		 action, g_udev_device_get_sysfs_path (device));
+
 	if (g_strcmp0 (action, "remove") == 0) {
 		for (i = 0; i < NUM_SENSOR_TYPES; i++) {
 			GUdevDevice *dev = DEVICE_FOR_TYPE(i);
@@ -754,10 +793,7 @@ sensor_changes (GUdevClient *client,
 int main (int argc, char **argv)
 {
 	SensorData *data;
-	GUdevClient *client;
 	int ret = 0;
-	const gchar * const subsystems[] = { "iio", "input", "platform", NULL };
-	guint i;
 
 	g_usleep (G_USEC_PER_SEC * 3);
 
@@ -768,40 +804,9 @@ int main (int argc, char **argv)
 	/* Set up D-Bus */
 	setup_dbus (data);
 
-	client = g_udev_client_new (subsystems);
-	if (!find_sensors (client, data)) {
-		g_debug ("Could not find any supported sensors");
-		return 0;
-	}
-	g_signal_connect (G_OBJECT (client), "uevent",
-			  G_CALLBACK (sensor_changes), data);
-
-	for (i = 0; i < NUM_SENSOR_TYPES; i++) {
-		data->clients[i] = create_clients_hash_table ();
-
-		if (!driver_type_exists (data, i))
-			continue;
-
-		if (!driver_open (DRIVER_FOR_TYPE(i), DEVICE_FOR_TYPE(i),
-				  driver_type_to_callback_func (data->drivers[i]->type), data)) {
-			DRIVER_FOR_TYPE(i) = NULL;
-			g_clear_object (&DEVICE_FOR_TYPE(i));
-		}
-	}
-
-	if (!any_sensors_left (data))
-		goto out;
-
-	data->init_done = TRUE;
-	if (data->connection) {
-		send_dbus_event (data, PROP_ALL);
-		send_dbus_event (data, PROP_ALL_COMPASS);
-	}
-
 	data->loop = g_main_loop_new (NULL, TRUE);
 	g_main_loop_run (data->loop);
-
-out:
+	ret = data->ret;
 	free_sensor_data (data);
 
 	return ret;
diff --git a/src/monitor-sensor.c b/src/monitor-sensor.c
index 8d1e997..7eb35cc 100644
--- a/src/monitor-sensor.c
+++ b/src/monitor-sensor.c
@@ -108,12 +108,17 @@ print_initial_values (void)
 	if (g_variant_get_boolean (v)) {
 		g_variant_unref (v);
 		v = g_dbus_proxy_get_cached_property (iio_proxy, "CompassHeading");
-		g_print ("=== Has compass (heading: %lf)\n",
-			   g_variant_get_double (v));
+		if (v) {
+			g_print ("=== Has compass (heading: %lf)\n",
+				 g_variant_get_double (v));
+			g_variant_unref (v);
+		} else {
+			g_print ("=== Has compass (heading: unset)\n");
+		}
 	} else {
 		g_print ("=== No compass\n");
 	}
-	g_variant_unref (v);
+	g_clear_pointer (&v, g_variant_unref);
 }
 
 static void



More information about the Neon-commits mailing list