all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Giacomo Leidi <goodoldpaul@autistici.org>
Cc: 72337@debbugs.gnu.org,
	Maxim Cournoyer <maxim.cournoyer@gmail.com>,
	Florian Pelz <pelzflorian@pelzflorian.de>,
	Matthew Trzcinski <matt@excalamus.com>
Subject: [bug#72337] Add /etc/subuid and /etc/subgid support
Date: Wed, 04 Sep 2024 23:20:06 +0200	[thread overview]
Message-ID: <87zfon9kvt.fsf_-_@gnu.org> (raw)
In-Reply-To: <8b0b9421e1347e0f0d6ce88c8eb66a5b6296cc0c.1724192097.git.goodoldpaul@autistici.org> (Giacomo Leidi's message of "Wed, 21 Aug 2024 00:14:57 +0200")

Giacomo Leidi <goodoldpaul@autistici.org> skribis:

> This commit adds a Guix System service to handle allocation of subuid
> and subgid requests.  Users that don't care can just add themselves as a
> subid-range and don't need to specify anything but their user name.
> Users that care about specific ranges, such as possibly LXD, can specify
> a start and a count.
>
> * doc/guix.texi: Document the new service.
> * gnu/build/activation.scm (activate-subuids+subgids): New variable.
> * gnu/local.mk: Add gnu/tests/shadow.scm.
> * gnu/system/accounts.scm (sexp->subid-range): New variable.
> * gnu/system/shadow.scm (%root-subid): New variable;
> (subids-configuration): new record;
> (subid-range->gexp): new variable;
> (assert-valid-subids): new variable;
> (delete-duplicate-ranges): new variable;
> (subids-activation): new variable;
> (subids-extension): new record;
> (append-subid-ranges): new variable;
> (subids-extension-merge): new variable;
> (subids-service-type): new variable.
> * gnu/tests/shadow.scm (subids): New system test.
>
> Change-Id: I3755e1c75771220c74fe8ae5de1a7d90f2376635

Nice.

> +The @code{(gnu system shadow)} module exposes the
> +@code{subids-service-type}, its configuration record
> +@code{subids-configuration} and its extension record
> +@code{subids-extension}.

I think this section should start by defining briefly what a
“subordinate ID” is, with a cross-reference to a primary source for that
(unfortunately glibc’s manual has nothing about it, so that’d be Linux
man pages I guess), and by giving an idea of what it’s used for.

It should use “subuid” and “subgid” only after it has introduced them as
abbreviations of “subordinate UID”.

> +for the root account to both @code{/etc/subuid} and @code{/etc/subgid}, possibly

s/@code/@file/

> +(define %sub-id-min
> +  (@@ (gnu build accounts) %sub-id-min))
> +(define %sub-id-max
> +  (@@ (gnu build accounts) %sub-id-max))
> +(define %sub-id-count
> +  (@@ (gnu build accounts) %sub-id-count))

Use single ‘@’ or, better yet, #:use-module the thing.

> +(define (assert-valid-subids ranges)
> +  (cond ((>= (fold + 0 (map subid-range-count ranges))
> +             (- %sub-id-max %sub-id-min -1))
> +         (raise
> +          (string-append
> +           "The configured ranges are more than the "
> +           (number->string
> +            (- %sub-id-max %sub-id-min -1)) " max allowed.")))

Same comment as before regarding ‘raise’.

In this case, you could do: (raise (formatted-message (G_ …) …)).
This is done elsewhere in the code.

> +                (define slurp
> +                  (lambda args
> +                    (let* ((port (apply open-pipe* OPEN_READ args))
> +                           (output (read-lines port))
> +                           (status (close-pipe port)))
> +                      output)))
> +                (let* ((response1 (slurp
> +                                   ,(string-append #$coreutils "/bin/cat")
> +                                   "/etc/subgid"))
> +                       (response2 (slurp
> +                                   ,(string-append #$coreutils "/bin/cat")
> +                                   "/etc/subuid")))
> +                  (list (string-join response1 "\n") (string-join response2 "\n"))))

Instead of running ‘cat’, I would suggest using:

  (call-with-input-file "/etc/subuid" get-string-all)

or similar; it’s much simpler.

Also, it would be nice if the test could actually exercise subordinate
IDs, with ‘newuidmap’ or some such.  Is that within reach?

Thanks,
Ludo’.




  reply	other threads:[~2024-09-04 21:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-28 15:25 [bug#72337] Add /etc/subuid and /etc/subgid support paul via Guix-patches via
2024-07-28 15:29 ` [bug#72337] [PATCH 1/3] accounts: " Giacomo Leidi via Guix-patches via
2024-07-28 15:29   ` [bug#72337] [PATCH 2/3] account: Add /etc/subid and /etc/subgid allocation logic Giacomo Leidi via Guix-patches via
2024-07-28 15:29   ` [bug#72337] [PATCH 3/3] system: Add /etc/subuid and /etc/subgid support Giacomo Leidi via Guix-patches via
2024-08-19 21:32 ` [bug#72337] " paul via Guix-patches via
2024-08-20 22:12   ` paul via Guix-patches via
2024-08-19 22:08 ` [bug#72337] [PATCH v2 1/3] accounts: " Giacomo Leidi via Guix-patches via
2024-08-19 22:08   ` [bug#72337] [PATCH v2 2/3] account: Add /etc/subid and /etc/subgid allocation logic Giacomo Leidi via Guix-patches via
2024-08-19 22:08   ` [bug#72337] [PATCH v2 3/3] system: Add /etc/subuid and /etc/subgid support Giacomo Leidi via Guix-patches via
2024-08-20 22:14 ` [bug#72337] [PATCH v3 1/3] accounts: " Giacomo Leidi via Guix-patches via
2024-08-20 22:14   ` [bug#72337] [PATCH v3 2/3] account: Add /etc/subid and /etc/subgid allocation logic Giacomo Leidi via Guix-patches via
2024-09-04 21:00     ` [bug#72337] Add /etc/subuid and /etc/subgid support Ludovic Courtès
2024-08-20 22:14   ` [bug#72337] [PATCH v3 3/3] system: " Giacomo Leidi via Guix-patches via
2024-09-04 21:20     ` Ludovic Courtès [this message]
2024-09-07 20:44       ` [bug#72337] " paul via Guix-patches via
2024-09-04 20:34   ` Ludovic Courtès
2024-09-07 20:51 ` [bug#72337] [PATCH v4 1/3] accounts: " Giacomo Leidi via Guix-patches via
2024-09-07 20:51   ` [bug#72337] [PATCH v4 2/3] account: Add /etc/subid and /etc/subgid allocation logic Giacomo Leidi via Guix-patches via
2024-09-19 11:14     ` [bug#72337] Add /etc/subuid and /etc/subgid support Ludovic Courtès
2024-09-07 20:51   ` [bug#72337] [PATCH v4 3/3] system: " Giacomo Leidi via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zfon9kvt.fsf_-_@gnu.org \
    --to=ludo@gnu.org \
    --cc=72337@debbugs.gnu.org \
    --cc=goodoldpaul@autistici.org \
    --cc=matt@excalamus.com \
    --cc=maxim.cournoyer@gmail.com \
    --cc=pelzflorian@pelzflorian.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.