Subject: Re: bug#37931: Cannot guix refresh -ru util-linux to get updated lsblk

From: Marius Bakke <[email-masked]>
Date: Wed, 08 Jan 2020 20:14:50 +0100

Bengt Richter <[email-masked]> writes:

> Hi Marius,
>
> On +2019-11-03 18:28:40 +0100, Marius Bakke wrote:
>> Bengt Richter <[email-masked]> writes:
>> 
>> > On +2019-10-28 23:29:16 +0100, Marius Bakke wrote:
>> >> The `lsblk` program requires root privileges in order to detect file
>> >> systems and UUIDs.  I'm guessing your distribution makes it setuid root?
>> >>
>> >
>> > It doesn't  look like it to me (the following snip is from TTY4, where I enabled guix paths and environment,
>> > so I can see ~/.guix-profile and /usr stuff at the same time):
>> 
>> [...]
>> 
>> 
>> > $ which -a lsblk|xargs readlink -f|xargs stat
>> >   File: /gnu/store/xymkwf57x988q8cny2is1dgzrbr9xdfi-util-linux-2.34/bin/lsblk
>> >   Size: 135560    	Blocks: 272        IO Block: 4096   regular file
>> > Device: 10304h/66308d	Inode: 1186253     Links: 2
>> > Access: (0555/-r-xr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
>> > Access: 2019-11-01 02:38:11.782574923 -0700
>> > Modify: 1969-12-31 16:00:01.000000000 -0800
>> > Change: 2019-10-08 18:18:48.226579757 -0700
>> >  Birth: -
>> >   File: /usr/bin/lsblk
>> >   Size: 124992    	Blocks: 248        IO Block: 4096   regular file
>> > Device: 10304h/66308d	Inode: 264652      Links: 1
>> > Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
>> > Access: 2019-11-01 02:38:55.354524750 -0700
>> > Modify: 2019-06-27 03:04:01.000000000 -0700
>> > Change: 2019-07-06 00:59:13.620416635 -0700
>> >  Birth: -
>> > $ 
>> > ┌───────────────────────────────────────────────────────────────────┐
>> > │ I see Access: is 0555 vs 0755, so doubt if that should be changed │
>> > └───────────────────────────────────────────────────────────────────┘
>> 
>> Indeed, there are no setuid bits there.
>> 
>> I had a look at the lsblkd source code, and found that it has an
>> optional dependency on udev:
>> 
>> https://github.com/karelzak/util-linux/blob/ccafadb7c58865f73d209fcfc74483be96cdf64d/misc-utils/lsblk-properties.c
>> 
>> I tried building util-linux with udev support, and got the same output
>> you expected without needing root privileges:
>>
>
> Sounds great ;-)
>
>> (define-public util-linux/udev
>>   (package/inherit
>>    util-linux
>>    (name "util-linux-with-udev")
>>    (inputs
>>     `(("udev" ,eudev)
>>       ,@(package-inputs util-linux)))))
>> 
>> Now, eudev already depends on util-linux, so adding udev support to the
>> regular 'util-linux' package would introduce a circular dependency.
>> 
>> I'm not sure what the best approach here is.  We could add a
>> 'util-linux-minimal' for use in package inputs, and/or add a
>> udev-enabled variant to %base-packages.
>> 
>> Thoughts?

This was finally committed in 71e0f1e9adbce4a6476a70bddabf13f6d7af2d40
and 01bb039e7b408893009d15f56cfcbdc8af70a4af.

>
> I'm a guix newbie :)
>
> I don't yet understand the internal dependency machinery of guix,
> so I'm wondering about the exact nature of the circularity.
>
> Is it really a kind of (let((... that needs to be a let*((...
> at some level? And which level of dependency are we talking about?

The circular dependency is straightforward: eudev *requires* util-linux
as part of its build process.  Thus, eudev has util-linux as an input.
That version of util-linux can not depend on eudev, because we can not
build eudev without a working util-linux package.

Wrt the rest of the message, I share your sentiment, and think we will
get there.  'guix build --with-git-url' is pretty close already.  :-)