[colord] [PATCH] rules: Add daemon_user to acl of sensor devices.

Christopher James Halse Rogers christopher.halse.rogers at canonical.com
Tue Aug 23 21:51:13 PDT 2011


From: Christopher James Halse Rogers <raof at ubuntu.com>

This ensures that the colord daemon can access the sensors when running as a system
user rather than root.

Signed-off-by: Christopher James Halse Rogers <raof at ubuntu.com>
---

This unconditionally adds an acl, even when daemon_user is root and the acl
is superfluous.  I don't think that's a serious problem, but could rework
this if desired.

 configure.ac                 |    1 +
 rules/69-cd-sensors.rules    |   69 ----------------------------------------
 rules/69-cd-sensors.rules.in |   72 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 73 insertions(+), 69 deletions(-)
 delete mode 100644 rules/69-cd-sensors.rules
 create mode 100644 rules/69-cd-sensors.rules.in

diff --git a/configure.ac b/configure.ac
index 6ea95a2..6acf91d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -291,6 +291,7 @@ data/org.freedesktop.ColorManager.conf
 data/tests/Makefile
 policy/Makefile
 rules/Makefile
+rules/69-cd-sensors.rules
 po/Makefile.in
 src/Makefile
 client/Makefile
diff --git a/rules/69-cd-sensors.rules b/rules/69-cd-sensors.rules
deleted file mode 100644
index 77e98f4..0000000
--- a/rules/69-cd-sensors.rules
+++ /dev/null
@@ -1,69 +0,0 @@
-########################################################################
-# Copyright (C) 2009-2010 Richard Hughes <richard at hughsie.com>
-#
-# Licensed under the GNU General Public License Version 2
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# Colorimeter devices used for profiling
-#
-# These are properties defining the behavior:
-#  COLORD_SENSOR		Can measure color
-#  COLORD_SENSOR_KIND		The kind of sensor
-#  COLORD_SENSOR_CAP_LCD	Can profile a LCD display device
-#  COLORD_SENSOR_CAP_LCD	Can profile a CRT display device
-#  COLORD_SENSOR_CAP_PROJECTOR	Can profile a projector device
-#  COLORD_SENSOR_CAP_PRINTER	Can profile a printer device
-#  COLORD_SENSOR_CAP_SPOT	Can be used for spot measurements
-#  COLORD_SENSOR_CAP_AMBIENT	Can be used for ambient measurements
-#
-
-# Skip all this to speed things up if it'a not a usb add.
-ACTION!="add", GOTO="gcm_rules_end"
-SUBSYSTEM!="usb", GOTO="gcm_rules_end"
-
-# DTP20
-ATTRS{idVendor}=="0765", ATTRS{idProduct}=="d020", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="dtp20", ENV{COLORD_SENSOR_CAP_PRINTER}="1", ENV{COLORD_SENSOR_CAP_SPOT}="1"
-
-# DTP92Q (not tested)
-ATTRS{idVendor}=="0765", ATTRS{idProduct}=="d092", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="unknown", ENV{COLORD_SENSOR_CAP_CRT}="1"
-
-# DTP94
-ATTRS{idVendor}=="0765", ATTRS{idProduct}=="d094", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="dtp94", ENV{COLORD_SENSOR_CAP_LCD}="1", ENV{COLORD_SENSOR_CAP_CRT}="1"
-
-# MonacoOPTIX (Same as i1 Display 1)
-ATTRS{idVendor}=="0670", ATTRS{idProduct}=="0001", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="i1-pro", ENV{COLORD_SENSOR_CAP_LCD}="1", ENV{COLORD_SENSOR_CAP_CRT}="1"
-
-# i1Display
-ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2003", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="i1-pro", ENV{COLORD_SENSOR_CAP_LCD}="1", ENV{COLORD_SENSOR_CAP_CRT}="1"
-
-# i1Monitor
-ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2001", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="i1-pro", ENV{COLORD_SENSOR_CAP_LCD}="1", ENV{COLORD_SENSOR_CAP_CRT}="1"
-
-# i1Pro
-ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2000", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="i1-pro", ENV{COLORD_SENSOR_CAP_LCD}="1", ENV{COLORD_SENSOR_CAP_CRT}="1", ENV{COLORD_SENSOR_CAP_PROJECTOR}="1", ENV{COLORD_SENSOR_CAP_PRINTER}="1", ENV{COLORD_SENSOR_CAP_AMBIENT}="1"
-
-# ColorMunki
-ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2007", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="color-munki", ENV{COLORD_SENSOR_CAP_LCD}="1", ENV{COLORD_SENSOR_CAP_CRT}="1", ENV{COLORD_SENSOR_CAP_PROJECTOR}="1", ENV{COLORD_SENSOR_CAP_PRINTER}="1", ENV{COLORD_SENSOR_CAP_SPOT}="1", ENV{COLORD_SENSOR_CAP_AMBIENT}="1"
-
-# Colorimtre HCFR
-ATTRS{idVendor}=="04db", ATTRS{idProduct}=="005b", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="colorimtre-hcfr", ENV{COLORD_SENSOR_CAP_PROJECTOR}="1"
-
-# Spyder 2
-ATTRS{idVendor}=="085c", ATTRS{idProduct}=="0200", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="spyder", ENV{COLORD_SENSOR_CAP_LCD}="1", ENV{COLORD_SENSOR_CAP_CRT}="1"
-
-# Spyder 3
-ATTRS{idVendor}=="085c", ATTRS{idProduct}=="0300", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="spyder", ENV{COLORD_SENSOR_CAP_LCD}="1", ENV{COLORD_SENSOR_CAP_CRT}="1", ENV{COLORD_SENSOR_CAP_AMBIENT}="1"
-
-# Huey
-ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2005", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="huey", ENV{COLORD_SENSOR_CAP_LCD}="1", ENV{COLORD_SENSOR_CAP_CRT}="1", ENV{COLORD_SENSOR_CAP_AMBIENT}="1"
-
-# color calibration device
-ENV{COLORD_SENSOR}=="*?", ENV{COLOR_MEASUREMENT_DEVICE}="1"
-ENV{COLORD_SENSOR}=="*?", ENV{ID_MODEL}=="", IMPORT{program}="usb_id --export %p"
-ENV{COLORD_SENSOR}=="*?", ENV{ID_MODEL_FROM_DATABASE}=="", IMPORT{program}="usb-db %p"
-
-LABEL="gcm_rules_end"
diff --git a/rules/69-cd-sensors.rules.in b/rules/69-cd-sensors.rules.in
new file mode 100644
index 0000000..bd6f2e5
--- /dev/null
+++ b/rules/69-cd-sensors.rules.in
@@ -0,0 +1,72 @@
+########################################################################
+# Copyright (C) 2009-2010 Richard Hughes <richard at hughsie.com>
+#
+# Licensed under the GNU General Public License Version 2
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# Colorimeter devices used for profiling
+#
+# These are properties defining the behavior:
+#  COLORD_SENSOR		Can measure color
+#  COLORD_SENSOR_KIND		The kind of sensor
+#  COLORD_SENSOR_CAP_LCD	Can profile a LCD display device
+#  COLORD_SENSOR_CAP_LCD	Can profile a CRT display device
+#  COLORD_SENSOR_CAP_PROJECTOR	Can profile a projector device
+#  COLORD_SENSOR_CAP_PRINTER	Can profile a printer device
+#  COLORD_SENSOR_CAP_SPOT	Can be used for spot measurements
+#  COLORD_SENSOR_CAP_AMBIENT	Can be used for ambient measurements
+#
+
+# Skip all this to speed things up if it'a not a usb add.
+ACTION!="add", GOTO="gcm_rules_end"
+SUBSYSTEM!="usb", GOTO="gcm_rules_end"
+
+# DTP20
+ATTRS{idVendor}=="0765", ATTRS{idProduct}=="d020", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="dtp20", ENV{COLORD_SENSOR_CAP_PRINTER}="1", ENV{COLORD_SENSOR_CAP_SPOT}="1"
+
+# DTP92Q (not tested)
+ATTRS{idVendor}=="0765", ATTRS{idProduct}=="d092", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="unknown", ENV{COLORD_SENSOR_CAP_CRT}="1"
+
+# DTP94
+ATTRS{idVendor}=="0765", ATTRS{idProduct}=="d094", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="dtp94", ENV{COLORD_SENSOR_CAP_LCD}="1", ENV{COLORD_SENSOR_CAP_CRT}="1"
+
+# MonacoOPTIX (Same as i1 Display 1)
+ATTRS{idVendor}=="0670", ATTRS{idProduct}=="0001", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="i1-pro", ENV{COLORD_SENSOR_CAP_LCD}="1", ENV{COLORD_SENSOR_CAP_CRT}="1"
+
+# i1Display
+ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2003", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="i1-pro", ENV{COLORD_SENSOR_CAP_LCD}="1", ENV{COLORD_SENSOR_CAP_CRT}="1"
+
+# i1Monitor
+ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2001", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="i1-pro", ENV{COLORD_SENSOR_CAP_LCD}="1", ENV{COLORD_SENSOR_CAP_CRT}="1"
+
+# i1Pro
+ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2000", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="i1-pro", ENV{COLORD_SENSOR_CAP_LCD}="1", ENV{COLORD_SENSOR_CAP_CRT}="1", ENV{COLORD_SENSOR_CAP_PROJECTOR}="1", ENV{COLORD_SENSOR_CAP_PRINTER}="1", ENV{COLORD_SENSOR_CAP_AMBIENT}="1"
+
+# ColorMunki
+ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2007", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="color-munki", ENV{COLORD_SENSOR_CAP_LCD}="1", ENV{COLORD_SENSOR_CAP_CRT}="1", ENV{COLORD_SENSOR_CAP_PROJECTOR}="1", ENV{COLORD_SENSOR_CAP_PRINTER}="1", ENV{COLORD_SENSOR_CAP_SPOT}="1", ENV{COLORD_SENSOR_CAP_AMBIENT}="1"
+
+# Colorimtre HCFR
+ATTRS{idVendor}=="04db", ATTRS{idProduct}=="005b", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="colorimtre-hcfr", ENV{COLORD_SENSOR_CAP_PROJECTOR}="1"
+
+# Spyder 2
+ATTRS{idVendor}=="085c", ATTRS{idProduct}=="0200", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="spyder", ENV{COLORD_SENSOR_CAP_LCD}="1", ENV{COLORD_SENSOR_CAP_CRT}="1"
+
+# Spyder 3
+ATTRS{idVendor}=="085c", ATTRS{idProduct}=="0300", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="spyder", ENV{COLORD_SENSOR_CAP_LCD}="1", ENV{COLORD_SENSOR_CAP_CRT}="1", ENV{COLORD_SENSOR_CAP_AMBIENT}="1"
+
+# Huey
+ATTRS{idVendor}=="0971", ATTRS{idProduct}=="2005", ENV{COLORD_SENSOR}="1", ENV{COLORD_SENSOR_KIND}="huey", ENV{COLORD_SENSOR_CAP_LCD}="1", ENV{COLORD_SENSOR_CAP_CRT}="1", ENV{COLORD_SENSOR_CAP_AMBIENT}="1"
+
+# color calibration device
+ENV{COLORD_SENSOR}=="*?", ENV{COLOR_MEASUREMENT_DEVICE}="1"
+ENV{COLORD_SENSOR}=="*?", ENV{ID_MODEL}=="", IMPORT{program}="usb_id --export %p"
+ENV{COLORD_SENSOR}=="*?", ENV{ID_MODEL_FROM_DATABASE}=="", IMPORT{program}="usb-db %p"
+
+# Add daemon user to device acl
+ENV{COLORD_SENSOR}=="*?", RUN+="/bin/setfacl -m u:@daemon_user@:rw $env{DEVNAME}"
+
+LABEL="gcm_rules_end"
-- 
1.7.5.4



More information about the colord mailing list