[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/06: environment: '-C' doesn't throw when the NSS is dysfunctional.
From: |
guix-commits |
Subject: |
01/06: environment: '-C' doesn't throw when the NSS is dysfunctional. |
Date: |
Fri, 9 Dec 2022 03:05:22 -0500 (EST) |
civodul pushed a commit to branch master
in repository guix.
commit e625e9b194f2de3ff20872f04b5c802c70cb411c
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Thu Dec 8 16:30:52 2022 +0100
environment: '-C' doesn't throw when the NSS is dysfunctional.
Previously, if the name service switch was dysfunctional, as can happen
on foreign distros lacking nscd, "guix shell -C" would crash with a
backtrace on the uncaught 'getpwuid' exception. To address that, catch
the exception and deal with it gracefully.
Reported by remsd1 on #guix.
* guix/scripts/environment.scm (launch-environment/container): Wrap
'getpwuid' call in 'false-if-exception'.
---
guix/scripts/environment.scm | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index 64597f6e9f..ab11b35335 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -728,14 +728,21 @@ WHILE-LIST."
(home (getenv "HOME"))
(uid (if user 1000 (getuid)))
(gid (if user 1000 (getgid)))
- (passwd (let ((pwd (getpwuid (getuid))))
+
+ ;; On a foreign distro, the name service switch might be
+ ;; dysfunctional and 'getpwuid' throws. Don't let that hamper
+ ;; operations.
+ (passwd (let ((pwd (false-if-exception (getpwuid (getuid)))))
(password-entry
- (name (or user (passwd:name pwd)))
- (real-name (if user
+ (name (or user
+ (and=> pwd passwd:name)
+ (getenv "USER")
+ "charlie"))
+ (real-name (if (or user (not pwd))
""
(passwd:gecos pwd)))
(uid uid) (gid gid) (shell bash)
- (directory (if user
+ (directory (if (or user (not pwd))
(string-append "/home/" user)
(passwd:dir pwd))))))
(groups (list (group-entry (name "users") (gid gid))
- branch master updated (3405b2b16c -> b0b1ce9dca), guix-commits, 2022/12/09
- 04/06: gnu: Add rust-kuchiki-0.8., guix-commits, 2022/12/09
- 01/06: environment: '-C' doesn't throw when the NSS is dysfunctional.,
guix-commits <=
- 06/06: gnu: guile-next: Update to a1a8558., guix-commits, 2022/12/09
- 03/06: gnu: Add guile-jtd., guix-commits, 2022/12/09
- 05/06: gnu: Add htmlq., guix-commits, 2022/12/09
- 02/06: gnu: Add buku-run., guix-commits, 2022/12/09