From 2820d64cba31359ff2dc0f3c4a9a144386d75cfa Mon Sep 17 00:00:00 2001 From: Dennis Klein Date: Thu, 7 Dec 2023 21:17:31 +0100 Subject: [PATCH] Fix empty user's shell field in `/etc/passwd` This regression was introduced by 4a0d2b81b1c2784d7df196575dfffb47478532a7 Signed-off-by: Dennis Klein --- CHANGELOG.md | 4 ++++ CONTRIBUTORS.md | 1 + .../pkg/runtime/engine/singularity/prepare_linux.go | 11 ++++------- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4082da3252..6025031a55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Changes Since Last Release +### Bug Fixes + +- Fix regression that led to an empty shell field in the `/etc/passwd` file. + ## 4.2.0 \[2024-09-04\] ### New Features & Functionality diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 3f2b1cc58b..e6ac2ad04a 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -38,6 +38,7 @@ The following have contributed code and/or documentation to this repository. - Dave Godlove , - Dave Love - David Trudgian , +- Dennis Klein - Diana Langenbach - Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> - Divya Cote diff --git a/internal/pkg/runtime/engine/singularity/prepare_linux.go b/internal/pkg/runtime/engine/singularity/prepare_linux.go index c10adfa46e..fe0344d2cb 100644 --- a/internal/pkg/runtime/engine/singularity/prepare_linux.go +++ b/internal/pkg/runtime/engine/singularity/prepare_linux.go @@ -1547,17 +1547,14 @@ func (e *EngineOperations) setUserInfo(useTargetIDs bool) { if useTargetIDs { pw, err = user.GetPwUID(uint32(e.EngineConfig.GetTargetUID())) - if err == nil { - e.EngineConfig.JSON.UserInfo.Username = pw.Name - e.EngineConfig.JSON.UserInfo.Gecos = pw.Gecos - e.EngineConfig.JSON.UserInfo.UID = int(pw.UID) - e.EngineConfig.JSON.UserInfo.GID = int(pw.GID) - } - } else { + } + + if err == nil { e.EngineConfig.JSON.UserInfo.Username = pw.Name e.EngineConfig.JSON.UserInfo.Gecos = pw.Gecos e.EngineConfig.JSON.UserInfo.UID = int(pw.UID) e.EngineConfig.JSON.UserInfo.GID = int(pw.GID) + e.EngineConfig.JSON.UserInfo.Shell = pw.Shell } e.EngineConfig.JSON.UserInfo.Groups = make(map[int]string)