diff options
| author | Giacomo Leidi <goodoldpaul@autistici.org> | 2024-10-08 00:40:26 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2024-12-18 18:32:40 +0100 |
| commit | 58f430f69e71f95cedab9912c1c9f2cc8660fad9 (patch) | |
| tree | aa6522c5e928ca36acdf6fc479e86e526a4e4b5c /gnu/system | |
| parent | 478b9ccea854ec4407643a44d40ee61584fbc73d (diff) | |
accounts: Add /etc/subuid and /etc/subgid support.
This commit adds a new record type, <subid-entry> and serializers
and deserializers for it in (gnu build accounts). Each instance of this
record represents one line in either /etc/subuid or /etc/subgid. Since
Shadow uses the same representation for both files, it should be ok if
we do it as well.
This commit adds also <subid-range>, a user facing representation of
<subid-entry>. It is supposed to be usable directly in OS configurations.
* gnu/build/accounts.scm (subid-entry): New record;
(write-subgid): add serializer for subgids;
(write-subuid): add serializer for subuids;
(read-subgid): add serializer for subgids;
(read-subuid): add serializer for subuids.
* gnu/system/accounts.scm (subid-range): New record.
* test/accounts.scm: Test them.
Change-Id: I6b037e40e354c069bf556412bb5b626bd3ea1b2c
Signed-off-by: Giacomo Leidi <goodoldpaul@autistici.org>
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'gnu/system')
| -rw-r--r-- | gnu/system/accounts.scm | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gnu/system/accounts.scm b/gnu/system/accounts.scm index 586cff1842e..9a006c188db 100644 --- a/gnu/system/accounts.scm +++ b/gnu/system/accounts.scm | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org> | 2 | ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org> |
| 3 | ;;; Copyright © 2024 Giacomo Leidi <goodoldpaul@autistici.org> | ||
| 3 | ;;; | 4 | ;;; |
| 4 | ;;; This file is part of GNU Guix. | 5 | ;;; This file is part of GNU Guix. |
| 5 | ;;; | 6 | ;;; |
| @@ -39,6 +40,12 @@ | |||
| 39 | user-group-id | 40 | user-group-id |
| 40 | user-group-system? | 41 | user-group-system? |
| 41 | 42 | ||
| 43 | subid-range | ||
| 44 | subid-range? | ||
| 45 | subid-range-name | ||
| 46 | subid-range-start | ||
| 47 | subid-range-count | ||
| 48 | |||
| 42 | sexp->user-account | 49 | sexp->user-account |
| 43 | sexp->user-group | 50 | sexp->user-group |
| 44 | 51 | ||
| @@ -85,6 +92,16 @@ | |||
| 85 | (system? user-group-system? ; Boolean | 92 | (system? user-group-system? ; Boolean |
| 86 | (default #f))) | 93 | (default #f))) |
| 87 | 94 | ||
| 95 | (define-record-type* <subid-range> | ||
| 96 | subid-range make-subid-range | ||
| 97 | subid-range? | ||
| 98 | (name subid-range-name) | ||
| 99 | (start subid-range-start (default #f)) ; number | ||
| 100 | (count subid-range-count ; number | ||
| 101 | ; from find_new_sub_gids.c and | ||
| 102 | ; find_new_sub_uids.c | ||
| 103 | (default 65536))) | ||
| 104 | |||
| 88 | (define (default-home-directory account) | 105 | (define (default-home-directory account) |
| 89 | "Return the default home directory for ACCOUNT." | 106 | "Return the default home directory for ACCOUNT." |
| 90 | (string-append "/home/" (user-account-name account))) | 107 | (string-append "/home/" (user-account-name account))) |
