mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 21:38:07 -05:00
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'.
This commit is contained in:
parent
416a691cff
commit
0406df0b9b
1 changed files with 11 additions and 4 deletions
|
@ -728,14 +728,21 @@ (define fhs-mappings
|
|||
(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))
|
||||
|
|
Loading…
Reference in a new issue