[-- Attachment #1: Type: text/plain, Size: 449 bytes --] There is a new pull request by tornaria against master on the void-packages repository https://github.com/tornaria/void-packages libmtp https://github.com/void-linux/void-packages/pull/34757 libmtp: update to 1.1.19. Also add a group _libmtp with r/w permission to accesss mtp devices. #### Testing the changes - I tested the changes in this PR: **YES** A patch file from https://github.com/void-linux/void-packages/pull/34757.patch is attached [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: github-pr-libmtp-34757.patch --] [-- Type: text/x-diff, Size: 1476 bytes --] From a20e47eb61bce327d104f0ad3abc4af0bcc12e1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy> Date: Wed, 29 Dec 2021 18:36:58 -0300 Subject: [PATCH] libmtp: update to 1.1.19. Also add a group _libmtp with r/w permission to accesss mtp devices. --- srcpkgs/libmtp/template | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/srcpkgs/libmtp/template b/srcpkgs/libmtp/template index 5bf05cd6bbe3..0ec1366dc11d 100644 --- a/srcpkgs/libmtp/template +++ b/srcpkgs/libmtp/template @@ -1,9 +1,10 @@ # Template file for 'libmtp' pkgname=libmtp -version=1.1.18 +version=1.1.19 revision=1 build_style=gnu-configure -configure_args="--disable-static --with-udev=/usr/lib/udev" +configure_args="--disable-static --with-udev=/usr/lib/udev + --with-udev-group=_libmtp" hostmakedepends="pkg-config" makedepends="libgcrypt-devel libusb-devel" short_desc="Library for Microsoft's Media Transfer Protocol (MTP)" @@ -11,7 +12,10 @@ maintainer="Orphaned <orphan@voidlinux.org>" license="LGPL-2.1-or-later" homepage="http://libmtp.sourceforge.net" distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-${version}.tar.gz" -checksum=7280fe50c044c818a06667f45eabca884deab3193caa8682e0b581e847a281f0 +checksum=deb4af6f63f5e71215cfa7fb961795262920b4ec6cb4b627f55b30b18aa33228 + +# the group that gets r/w permission to access mtp devices +system_groups=_libmtp if [ "$CROSS_BUILD" ]; then # XXX needs host mtp-hotplug
[-- Attachment #1: Type: text/plain, Size: 197 bytes --] New review comment by ericonr on void-packages repository https://github.com/void-linux/void-packages/pull/34757#discussion_r777886152 Comment: Was it using a default group before this? Or none?
[-- Attachment #1: Type: text/plain, Size: 1842 bytes --] New review comment by tornaria on void-packages repository https://github.com/void-linux/void-packages/pull/34757#discussion_r778486761 Comment: The default is "none" which means there's no group. The only change with this seems to be in the file `/usr/lib/udev/rules.d/69-libmtp.rules`: ```diff --- 69-libmtp.rules.old 2020-11-05 23:30:09.000000000 -0300 +++ 69-libmtp.rules.new 2021-12-29 18:26:43.895937081 -0300 @@ -9,7 +9,7 @@ LABEL="libmtp_usb_rules" # If we have a hwdb entry for this device, act immediately! -ENV{ID_MTP_DEVICE}=="1", SYMLINK+="libmtp-%k", GOTO="libmtp_rules_end" +ENV{ID_MTP_DEVICE}=="1", SYMLINK+="libmtp-%k", GROUP="_libmtp", GOTO="libmtp_rules_end" # Fall back to probing. # Some sensitive devices we surely don't wanna probe @@ -36,6 +36,6 @@ ENV{ID_USB_INTERFACES}=="*:0701??:*", GOTO="libmtp_rules_end" # Autoprobe vendor-specific, communication and PTP devices -ENV{ID_MTP_DEVICE}!="1", ENV{MTP_NO_PROBE}!="1", ENV{COLOR_MEASUREMENT_DEVICE}!="1", ENV{ID_GPHOTO}!="1", ENV{libsane_matched}!="yes", ATTR{bDeviceClass}=="00|02|06|ef|ff", PROGRAM="/usr/lib/udev/mtp-probe /sys$env{DEVPATH} $attr{busnum} $attr{devnum}", RESULT=="1", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1" +ENV{ID_MTP_DEVICE}!="1", ENV{MTP_NO_PROBE}!="1", ENV{COLOR_MEASUREMENT_DEVICE}!="1", ENV{ID_GPHOTO}!="1", ENV{libsane_matched}!="yes", ATTR{bDeviceClass}=="00|02|06|ef|ff", PROGRAM="/usr/lib/udev/mtp-probe /sys$env{DEVPATH} $attr{busnum} $attr{devnum}", RESULT=="1", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1", GROUP="_libmtp" LABEL="libmtp_rules_end" ``` The net effect is that the device node that is created in `/dev/bus/usb/...` has its group set to `_libmtp`. These files are created with mode 664 in any case, but with group `root`.
[-- Attachment #1: Type: text/plain, Size: 432 bytes --] New review comment by tornaria on void-packages repository https://github.com/void-linux/void-packages/pull/34757#discussion_r788756826 Comment: ping @ericonr Besides the update, this is solving an issue: libmtp doesn't work out-of-the-box unless it is run on sudo, and I don't want to run gtk apps on sudo. E.g. I'm using gmtp: with this patch and me on the _libmtp group it works fine, otherwise it cannot access the device.
[-- Attachment #1: Type: text/plain, Size: 196 bytes --] New review comment by Piraty on void-packages repository https://github.com/void-linux/void-packages/pull/34757#discussion_r815180100 Comment: neither Alpine, Arch nor Debian don't set this...?
[-- Attachment #1: Type: text/plain, Size: 182 bytes --] New review comment by Piraty on void-packages repository https://github.com/void-linux/void-packages/pull/34757#discussion_r815181418 Comment: maybe a different group makes sense?
[-- Attachment #1: Type: text/plain, Size: 204 bytes --] New review comment by tornaria on void-packages repository https://github.com/void-linux/void-packages/pull/34757#discussion_r815184220 Comment: > maybe a different group makes sense? Maybe audio?
[-- Attachment #1: Type: text/plain, Size: 442 bytes --] New review comment by tornaria on void-packages repository https://github.com/void-linux/void-packages/pull/34757#discussion_r815189756 Comment: Gentoo uses `plugdev`: https://gitweb.gentoo.org/repo/gentoo.git/tree/media-libs/libmtp/libmtp-1.1.19.ebuild#n58 Arch documentation claims to use `uucp` but I don't think the pkgbuild actually sets that: https://wiki.archlinux.org/title/Media_Transfer_Protocol#libmtp Debian I don't know.
[-- Attachment #1: Type: text/plain, Size: 182 bytes --] New review comment by Piraty on void-packages repository https://github.com/void-linux/void-packages/pull/34757#discussion_r815181418 Comment: maybe a different group makes sense?
[-- Attachment #1: Type: text/plain, Size: 203 bytes --] New review comment by Piraty on void-packages repository https://github.com/void-linux/void-packages/pull/34757#discussion_r815236434 Comment: I checked their build templates, all of them don't set it
[-- Attachment #1: Type: text/plain, Size: 535 bytes --] New review comment by tornaria on void-packages repository https://github.com/void-linux/void-packages/pull/34757#discussion_r815311712 Comment: > I checked their build templates, all of them don't set it So, how do they solve the problem I described above: > libmtp doesn't work out-of-the-box unless it is run on sudo, and I don't want to run gtk apps on sudo. E.g. I'm using gmtp: with this patch and me on the _libmtp group it works fine, otherwise it cannot access the device. What's the downside of setting this option?
[-- Attachment #1: Type: text/plain, Size: 286 bytes --] New review comment by Piraty on void-packages repository https://github.com/void-linux/void-packages/pull/34757#discussion_r815358503 Comment: so libmtp is broken on all the other distros then? i would go with what gentoo does (`plugdev`), as that's used in some templates already
[-- Attachment #1: Type: text/plain, Size: 1518 bytes --] New review comment by tornaria on void-packages repository https://github.com/void-linux/void-packages/pull/34757#discussion_r815470055 Comment: > so libmtp is broken on all the other distros then? I don't know, I don't use other distros. Is there a different method to give users access to usb devices? The only methods that come to my mind are: (a) make the device group-readable by a well known group (b) run the programs that need to access the device as root (either setuid or sudo) (c) have a daemon running as root that the programs talk to. I don't think libmtp has (c) and (b) seems unsafe so (a) is the only reasonable choice AFAICT. > i would go with what gentoo does (`plugdev`), as that's used in some templates already - `plugdev` is not documented here: https://docs.voidlinux.org/config/users-and-groups.html#default-groups - I see three packages create group `plugdev`, namely `openocd`, `openrazer-meta` and `wally-udev-rules`, so maybe it's ok to use `plugdev` without underscore (the policy says to use underscore: "System accounts and groups must be prefixed with an underscore to prevent clashing with names of user accounts." except for old packages). - debian says `plugdev` "Allows members to mount (only with the options nodev and nosuid, for security reasons) and umount removable devices through pmount." (https://wiki.debian.org/SystemGroups) - in void pmount is setuid root instead. My rationale for `_libmtp` was that it is unambiguous what you are getting access to.
[-- Attachment #1: Type: text/plain, Size: 456 bytes --] There is an updated pull request by tornaria against master on the void-packages repository https://github.com/tornaria/void-packages libmtp https://github.com/void-linux/void-packages/pull/34757 libmtp: update to 1.1.19. Also add a group `_libmtp` with r/w permission to accesss mtp devices. #### Testing the changes - I tested the changes in this PR: **YES** A patch file from https://github.com/void-linux/void-packages/pull/34757.patch is attached [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: github-pr-libmtp-34757.patch --] [-- Type: text/x-diff, Size: 1383 bytes --] From d04020978e51b1bc86158f35c213f716a3d9deaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy> Date: Wed, 29 Dec 2021 18:36:58 -0300 Subject: [PATCH] libmtp: update to 1.1.19. Also: use group `plugdev` to grant r/w permission to mtp devices. --- srcpkgs/libmtp/template | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/srcpkgs/libmtp/template b/srcpkgs/libmtp/template index 5bf05cd6bbe3..1114a4d7bb85 100644 --- a/srcpkgs/libmtp/template +++ b/srcpkgs/libmtp/template @@ -1,9 +1,10 @@ # Template file for 'libmtp' pkgname=libmtp -version=1.1.18 +version=1.1.19 revision=1 build_style=gnu-configure -configure_args="--disable-static --with-udev=/usr/lib/udev" +configure_args="--disable-static --with-udev=/usr/lib/udev + --with-udev-group=plugdev" hostmakedepends="pkg-config" makedepends="libgcrypt-devel libusb-devel" short_desc="Library for Microsoft's Media Transfer Protocol (MTP)" @@ -11,7 +12,7 @@ maintainer="Orphaned <orphan@voidlinux.org>" license="LGPL-2.1-or-later" homepage="http://libmtp.sourceforge.net" distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-${version}.tar.gz" -checksum=7280fe50c044c818a06667f45eabca884deab3193caa8682e0b581e847a281f0 +checksum=deb4af6f63f5e71215cfa7fb961795262920b4ec6cb4b627f55b30b18aa33228 if [ "$CROSS_BUILD" ]; then # XXX needs host mtp-hotplug
[-- Attachment #1: Type: text/plain, Size: 243 bytes --] New review comment by tornaria on void-packages repository https://github.com/void-linux/void-packages/pull/34757#discussion_r830536934 Comment: After this discussion and a chat with @0x5c on irc, it seems using `plugdev` is the better way.
[-- Attachment #1: Type: text/plain, Size: 444 bytes --] New comment by tornaria on void-packages repository https://github.com/void-linux/void-packages/pull/34757#issuecomment-1073128104 Comment: As per comments above, I pushed a new version using `plugdev` as the group with r/w permission to mtp devices. Moreover @0x5c is working on a PR to add `plugdev` group to the default system groups. Hence, the new version does not use the system group trigger, and it should be merged after that PR.
[-- Attachment #1: Type: text/plain, Size: 240 bytes --] New comment by 0x5c on void-packages repository https://github.com/void-linux/void-packages/pull/34757#issuecomment-1090891564 Comment: @tornaria https://github.com/void-linux/void-packages/pull/36238 landed so your PR should be good now
[-- Attachment #1: Type: text/plain, Size: 540 bytes --] New comment by tornaria on void-packages repository https://github.com/void-linux/void-packages/pull/34757#issuecomment-1094365227 Comment: @q66 since you merged #36238 (plugdev standard group), could you please take a look at this? The update itself is uninteresting, but I changed the template so that libmtp uses `plugdev` group for r/w permission to mtp devices (before this change, there was no way to use libmtp without root). I've been using this without any trouble (I use it via `gmtp` to upload music to my garmin watch).
[-- Attachment #1: Type: text/plain, Size: 348 bytes --] There's a merged pull request on the void-packages repository libmtp: update to 1.1.19, use plugdev group for r/w access to mtp devices. https://github.com/void-linux/void-packages/pull/34757 Description: Also add a group `_libmtp` with r/w permission to accesss mtp devices. #### Testing the changes - I tested the changes in this PR: **YES**