elogind does not set ACLs promptly

OpenSubmitted by Chris Marusich.
Details
One participant
  • Chris Marusich
Owner
unassigned
Severity
normal
C
C
Chris Marusich wrote on 1 Jan 2017 23:58
(address . bug-guix@gnu.org)
87k2aewfo5.fsf@gmail.com
Please find attached a description of the bug, which came from thefollowing email thread:
https://lists.gnu.org/archive/html/guix-devel/2016-12/msg01126.html
Return-Path: <cmmarusich@gmail.com>Received: from garuda ([2601:602:9d02:4725:4e0f:6eff:fef6:70b9]) by smtp.gmail.com with ESMTPSA id y29sm107511230pfd.63.2016.12.29.16.41.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 29 Dec 2016 16:41:14 -0800 (PST)From: Chris Marusich <cmmarusich@gmail.com>To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=)Cc: guix-devel@gnu.orgSubject: Re: Let non-root users use MTP devices (Attempt #2)References: <87mvfggv4k.fsf@gmail.com> <20161229090121.3718-1-cmmarusich@gmail.com> <871swrf3cm.fsf@gmail.com> <871swqe4k6.fsf@gnu.org>Date: Thu, 29 Dec 2016 16:41:10 -0800In-Reply-To: <871swqe4k6.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Thu, 29 Dec 2016 23:48:00 +0100")Message-ID: <87ful6xn89.fsf@gmail.com>User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)MIME-Version: 1.0Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature"
--=-=-=Content-Type: text/plain; charset=utf-8Content-Transfer-Encoding: quoted-printable
ludo@gnu.org (Ludovic Court=C3=A8s) writes:
Toggle quote (49 lines)> Chris Marusich <cmmarusich@gmail.com> skribis:>>> Chris Marusich <cmmarusich@gmail.com> writes:>>>>> Here's a second attempt to fix MTP support for GuixSD. It's simple and>>> requires no special group permissions.>>>>>> It turns out that elogind (like systemd's logind) can be compiled with>>> support for ACLs (provided by libacl), in which case elogind will>>> automatically set an ACL on a device file granting access to a user when>>> that user is logged in using a seat to which the device is attached. In>>> short, by adding acl as an input to elogind, users will be able to>>> access devices without running programs as root, and without being a>>> member of any special group.>>>>>> That's just one piece of the puzzle, though. The other piece is the>>> udev rules provided by libmtp. It's necessary to install those udev>>> rules; if we don't, then the MTP device won't be tagged properly, so>>> elogind will not set any ACLs for it. I've chosen to install those>>> rules by modifying the base services in desktop.scm so that all desktops>>> will get the rules, not just GNOME; if you know of a better way to>>> install them, please let me know.>>>>>> This patch has a happy side effect. Namely: because elogind is now>>> setting ACLs, it gives a user access to other devices that are attached>>> to their seat. For instance, after this change, I can access /dev/kvm>>> and /dev/cdrom (and other devices) without being root, and without being>>> in any special group. How nice!>>>> After sending this, I've noticed something odd: sometimes, it can take>> quite a while for elogind to set the ACLs. It's a bit of a mystery to>> me. I'm not sure how/when elogind decides to update the ACLs; I assumed>> it was continuously checking for changes in the hardware or receiving>> notifications about hardware changes, but it seems like elogind isn't>> noticing when I plug in my phone. Even though the device file shows up,>> elogind doesn't set the ACLs unless I do something.>>>> By "do something," I mean: Apparently, logging out and logging back in>> seems to trigger elogind to set the ACLs. Even just switching virtual>> terminals (i.e., Control + F1, followed by Control + F7) seems to>> trigger it, which is weird. Even when elogind has not yet set the ACLs,>> the "uaccess" tag has in fact been correctly set for the device (as>> reported by e.g. "udevadm info /dev/libmtp-1-1"), which leads me to>> suspect that elogind is either failing to notice or just ignoring the>> hardware change. I wonder if this might be a bug of some kind.>>>> What do you think we should do?>> Good question! I don=E2=80=99t know. Does this happen only for MTP devi=
ces or
Toggle quote (2 lines)> also with other things (KVM?)?
Yes, this happens for other devices, too. For example, I observeexactly the same behavior for /dev/sr0 when I plug in an external CD-ROMdrive (via USB cable) after logging in. The ACL doesn't get set untilafter I do something like switch to another virtual terminal and back.
Toggle quote (2 lines)> Does =E2=80=9Cudevadm settle=E2=80=9D trigger the ACL change?
No, neither "udevadm settle" nor "sudo udevadm settle" triggers the ACLchange. I suspect that maybe elogind is ignoring or failing to noticethe new device, or perhaps the mechanism that elogind relies on to learnabout new devices is not working for some reason.
It looks like elogind sets the ACLs via devnode_acl_all, defined insrc/login/logind-acl.c. Ultimately it seems this gets called while inseat_set_active (specifically, invoked at src/login/logind-seat.c:213),under certain conditions. That's as far as I got.
I cannot reproduce this issue on Ubuntu; there, the ACL gets setpromptly.
=2D-=20Chris
--=-=-=Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEEy/WXVcvn5+/vGD+x3UCaFdgiRp0FAlhlrScACgkQ3UCaFdgiRp2VJBAAuIPsrckce8S75IeyJWWvcKE0e/sKjb7fpkmMvQyAiJ4XKWwyGK0xuNHngx+FPH/bIeybaOemJklH4F+TP1O8muCkzhLLPvoP3lrpj7gMuThruzXKVsTYIHYb2Cm9fE9U4stFNCVlUrrRuFqS9grtrd05Z/2Hwr2DYFNiq45y3Dpdr1mus9NEv3iZPAMiZB9tE8NSMoGKevo90XLQUDTBaHGuk9UOphWZ7QijCB/dTfNm7IXVbzpffa4u8XOtsNk3ISimFMx+6P3f/moj27jtmMJnl65ayVgQV7iIKpnlyW7hMJ4gGusRJrV3xQMxwvlrodYzmd0h9i0j7mhk6YutB9ZIWBkXPvYmIWzIHKh9WFDK+vPiZBctcxP15ss5n5DxEKPh6Rv6nQsOcOYUG1EboWhyKWX18iV15cP7+akPdUGifDGYnTStO5R1Aap3X4yRPF/T9x6JcAtDWwEaRK/ry188tYNPZFyjnKIZxGlxTNqzMiFZvVRTUn3xZRQXi+MtElqcnSEkpxlJtxfKc+IsQxtsAkh6+NjlSBv7WXhh8ExvEXjCi5x59FqCDRZkK059zoXIGPtxwPlufghRgHaAJmB2SAdPW36YUjO48roi9eE8mLH2JTBb/00zr9YP4/nzasq99l5znSkjFBzhLMd6bZUeM134Y2yZlls/qFuGbWQ==WczD-----END PGP SIGNATURE-------=-=-=--

-- Chris
-----BEGI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