USB devices as normal user?

1,028 views
Skip to first unread message

Roland Koebler

unread,
Nov 1, 2017, 6:39:15 PM11/1/17
to nix-...@googlegroups.com
Hi,

I'm using e.g. a scanner and a mtp-connection (via gmtp) to a mobile phone,
both connected via USB, with NixOS. But unfortunately, accessing them currently
only works as root because of some permissions.

What's the right way to solve this in NixOS?
(With Debian, it was a separate group and maybe some udev-rules.)


thanks,
Roland

Samuel Leathers

unread,
Nov 1, 2017, 6:43:42 PM11/1/17
to Roland Koebler, nix-...@googlegroups.com
That's how I would do it. This is what I do for a usb smart card reader:

      services.udev.extraRules = ''                                                                
        # Allow user access to some USB devices.                                          
        SUBSYSTEM=="usb", ATTR{idVendor}=="04e6", ATTR{idProduct}=="e001", TAG+="uaccess", RUN{builtin}+="uaccess"
      '';

--
You received this message because you are subscribed to the Google Groups "nix-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nix-devel+...@googlegroups.com.
To post to this group, send email to nix-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nix-devel/20171101223913.GB3668%40srv03.k-facility.de.
For more options, visit https://groups.google.com/d/optout.

Layus

unread,
Nov 2, 2017, 6:15:43 PM11/2/17
to Samuel Leathers, Roland Koebler, nix-...@googlegroups.com
Hi,

I am using udiskie to perform mounts.
I guess the tool is smart enough to give me access to the mounts I requested, because I never had any issue.

-- Layus.

Roland Koebler

unread,
Dec 15, 2017, 5:35:34 AM12/15/17
to nix-...@googlegroups.com
Hi,

thanks for the hint to udisks. I was able to mount usb flash drives
then with udisksctl (or: alias usbmount='udisksctl mount -b ').

But I think since I updated NixOS recently, I cannot mount the devices
as user any more, but always need the root password:

$ udisksctl mount -b /dev/sdb1
==== AUTHENTICATING FOR org.freedesktop.udisks2.filesystem-mount ===
Authentication is required to mount JetFlash Transcend 8GB (/dev/sdb1)
Authenticating as: System administrator (root)
Password:

And "man udisks" says:
By default, logged-in users in active log-in sessions are permitted to
perform operations (for example, mounting, unlocking or modifying) on
devices attached to the seat their session is on.

So, did anything change recently in NixOS with udisks?
Or do I need special polkit-rules to be able to mount as user?


thanks,
Roland



On 2017-11-02 23:15:40 +0100, Layus wrote:
> Hi,
>
> I am using udiskie to perform mounts.
> I guess the tool is smart enough to give me access to the mounts I
> requested, because I never had any issue.
>
> -- Layus.
>
> On 01/11/17 23:43, Samuel Leathers wrote:
> > That's how I would do it. This is what I do for a usb smart card reader:
> >
> >       services.udev.extraRules = ''
> >         # Allow user access to some USB devices.
> >         SUBSYSTEM=="usb", ATTR{idVendor}=="04e6",
> > ATTR{idProduct}=="e001", TAG+="uaccess", RUN{builtin}+="uaccess"
> >       '';
> >
> > On Wed, Nov 1, 2017 at 6:39 PM Roland Koebler
> > <rk-...@simple-is-better.org <mailto:rk-...@simple-is-better.org>>
> > wrote:
> >
> > Hi,
> >
> > I'm using e.g. a scanner and a mtp-connection (via gmtp) to a
> > mobile phone,
> > both connected via USB, with NixOS. But unfortunately, accessing
> > them currently
> > only works as root because of some permissions.
> >
> > What's the right way to solve this in NixOS?
> > (With Debian, it was a separate group and maybe some udev-rules.)
> >
> >
> > thanks,
> > Roland
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "nix-devel" group.
> > To unsubscribe from this group and stop receiving emails from it,
> > send an email to nix-devel+...@googlegroups.com
> > <mailto:nix-devel%2Bunsu...@googlegroups.com>.
> > To post to this group, send email to nix-...@googlegroups.com
> > <mailto:nix-...@googlegroups.com>.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/nix-devel/20171101223913.GB3668%40srv03.k-facility.de.
> > For more options, visit https://groups.google.com/d/optout.
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "nix-devel" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> > an email to nix-devel+...@googlegroups.com
> > <mailto:nix-devel+...@googlegroups.com>.
> > To post to this group, send email to nix-...@googlegroups.com
> > <mailto:nix-...@googlegroups.com>.
> > To view this discussion on the web visit https://groups.google.com/d/msgid/nix-devel/CAG_rqeufPjcKCm3Jf%3DEqCqh%2BjAQ9G1Td%2BrX0_XLRJFyEwDhqAg%40mail.gmail.com <https://groups.google.com/d/msgid/nix-devel/CAG_rqeufPjcKCm3Jf%3DEqCqh%2BjAQ9G1Td%2BrX0_XLRJFyEwDhqAg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> > For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups "nix-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to nix-devel+...@googlegroups.com.
> To post to this group, send email to nix-...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/nix-devel/d4daf67f-81f4-7296-a1fa-c74eea803ba7%40gmail.com.

Roland Koebler

unread,
Dec 17, 2017, 8:17:13 AM12/17/17
to nix-...@googlegroups.com
Hi,

I've investigated a bit further: The problem was *not* caused by an
update; instead, udisks-mounts only work with some terminals:

- console: works
- X + terminator: works

- X + xterm: fails / requires authentication [1]
- X + urxvt: fails / requires authentication [1]

Does anyone know why this is so and how to solve this?


[1] authentication:
==== AUTHENTICATING FOR org.freedesktop.udisks2.filesystem-mount ===
Authentication is required to mount JetFlash Transcend 8GB (/dev/sdb1)
Authenticating as: System administrator (root)
Password:


thanks,
Roland

Guillaume Maudoux (Layus)

unread,
Dec 17, 2017, 2:54:51 PM12/17/17
to nix-...@googlegroups.com, Roland Koebler
You are asked for auth because your logind session is not recognised. Here is an archlinux thread with a similar issue. It contains many debugging techniques and inspection tools for logind sessions. Sadly, their investigation is still under progress. Without further ado: https://bbs.archlinux.org/viewtopic.php?id=227475

-- layus
Reply all
Reply to author
Forward
0 new messages