diff options
author | Roshan Pius <rpius@chromium.org> | 2014-12-19 10:22:18 -0800 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2014-12-19 20:32:12 +0100 |
commit | bec32bd8d570b66fcfcf1325af8c80752a784b61 (patch) | |
tree | caaa98be5a8441eacab61a27965b66e5565d8a38 | |
parent | b84db57fe24652238a06c8aaff70f769ccfa6a0e (diff) | |
download | external_libqmi-bec32bd8d570b66fcfcf1325af8c80752a784b61.zip external_libqmi-bec32bd8d570b66fcfcf1325af8c80752a784b61.tar.gz external_libqmi-bec32bd8d570b66fcfcf1325af8c80752a784b61.tar.bz2 |
libqmi-glib,proxy: Change ownership of QMI devices to the configured user.
Adding a udev rule to change ownership of all QMI devices to the
configured user specified at compile time using --enable-qmi-username
flag.
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | configure.ac | 33 | ||||
-rw-r--r-- | src/qmi-proxy/76-qmi-proxy-device-ownership.rules.in | 12 | ||||
-rw-r--r-- | src/qmi-proxy/Makefile.am | 9 |
4 files changed, 49 insertions, 9 deletions
diff --git a/Makefile.am b/Makefile.am index 21a6b18..7970fbe 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,7 +3,9 @@ SUBDIRS = . data build-aux src utils docs ACLOCAL_AMFLAGS = -I m4 -DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc +DISTCHECK_CONFIGURE_FLAGS = \ + --with-udev-base-dir="$$dc_install_base" \ + --enable-gtk-doc EXTRA_DIST = \ gtester.make \ diff --git a/configure.ac b/configure.ac index 754cbae..c1ca6ef 100644 --- a/configure.ac +++ b/configure.ac @@ -81,9 +81,25 @@ GTK_DOC_CHECK(1.0) # QMI username AC_ARG_ENABLE(qmi-username, - AS_HELP_STRING([--enable-qmi-username=<username>], [user allowed to access QMI devices]),, - enable_qmi_username="root") -AC_DEFINE_UNQUOTED(QMI_USERNAME, "$enable_qmi_username", [Define the QMI username]) + AS_HELP_STRING([--enable-qmi-username=<username>], [user allowed to access QMI devices])) +if test -n "$enable_qmi_username" ; then + QMI_USERNAME="$enable_qmi_username" +else + QMI_USERNAME="root" +fi +AM_CONDITIONAL([INSTALL_QMI_UDEV_RULES], [test "x$enable_qmi_username" = "x$QMI_USERNAME"]) +AC_SUBST(QMI_USERNAME) +AC_DEFINE_UNQUOTED(QMI_USERNAME, "$QMI_USERNAME", [Define the QMI username]) +AM_COND_IF([INSTALL_QMI_UDEV_RULES], [AC_CONFIG_FILES([src/qmi-proxy/76-qmi-proxy-device-ownership.rules])]) + +# udev base directory +AC_ARG_WITH(udev-base-dir, AS_HELP_STRING([--with-udev-base-dir=DIR], [where udev base directory is])) +if test -n "$with_udev_base_dir" ; then + UDEV_BASE_DIR="$with_udev_base_dir" +else + UDEV_BASE_DIR="/lib/udev" +fi +AC_SUBST(UDEV_BASE_DIR) dnl Man page AC_PATH_PROG(HELP2MAN, help2man, false) @@ -116,9 +132,10 @@ echo " libqmi (libqmi-glib, qmicli) $VERSION ============================================== - compiler: ${CC} - cflags: ${CFLAGS} - Maintainer mode: ${USE_MAINTAINER_MODE} - Documentation: ${enable_gtk_doc} - QMI username: ${enable_qmi_username} + compiler: ${CC} + cflags: ${CFLAGS} + Maintainer mode: ${USE_MAINTAINER_MODE} + udev base directory: ${UDEV_BASE_DIR} + Documentation: ${enable_gtk_doc} + QMI username: ${QMI_USERNAME} " diff --git a/src/qmi-proxy/76-qmi-proxy-device-ownership.rules.in b/src/qmi-proxy/76-qmi-proxy-device-ownership.rules.in new file mode 100644 index 0000000..458113d --- /dev/null +++ b/src/qmi-proxy/76-qmi-proxy-device-ownership.rules.in @@ -0,0 +1,12 @@ +# do not edit this file, it will be overwritten on update + +ACTION!="add|change|move", GOTO="qmi_proxy_device_ownership_end" + +# A 'cdc-wdm' device is from a MBIM and QMI-based modems. +KERNEL=="cdc-wdm[0-9]", DRIVERS=="qmi_wwan", SUBSYSTEM=="usbmisc", GOTO="qmi_proxy_device_ownership_change" +GOTO="qmi_proxy_device_ownership_end" + +LABEL="qmi_proxy_device_ownership_change" +OWNER="@QMI_USERNAME@" + +LABEL="qmi_proxy_device_ownership_end" diff --git a/src/qmi-proxy/Makefile.am b/src/qmi-proxy/Makefile.am index 709f712..3eb532e 100644 --- a/src/qmi-proxy/Makefile.am +++ b/src/qmi-proxy/Makefile.am @@ -14,3 +14,12 @@ qmi_proxy_SOURCES = qmi-proxy.c qmi_proxy_LDADD = \ $(GLIB_LIBS) \ $(top_builddir)/src/libqmi-glib/libqmi-glib.la + +#Install udev rules only if configured with --enable-qmi-username +if INSTALL_QMI_UDEV_RULES +udevrulesdir = $(UDEV_BASE_DIR)/rules.d +udevrules_DATA = 76-qmi-proxy-device-ownership.rules + +EXTRA_DIST = \ + 76-qmi-proxy-device-ownership.rules.in +endif |