From 96878efb28df08a77991332d0dbe74e7760036d7 Mon Sep 17 00:00:00 2001 From: David Trudgian Date: Wed, 15 Jan 2025 17:14:30 +0000 Subject: [PATCH 1/4] test: accommodate root user with GECOS != "root" On EL10 the root user GECOS is "Super User`, not `root`. Allow this in `TestPasswd`. Fixes #3454 --- internal/pkg/util/fs/files/passwd_test.go | 28 +++++++++++------- .../testdata/passwd.root.customhome.golden | 29 ------------------- 2 files changed, 17 insertions(+), 40 deletions(-) delete mode 100644 internal/pkg/util/fs/files/testdata/passwd.root.customhome.golden diff --git a/internal/pkg/util/fs/files/passwd_test.go b/internal/pkg/util/fs/files/passwd_test.go index d6adf34ee0..1ed84c5835 100644 --- a/internal/pkg/util/fs/files/passwd_test.go +++ b/internal/pkg/util/fs/files/passwd_test.go @@ -6,12 +6,14 @@ package files import ( + "fmt" "os" + "os/user" "path/filepath" + "strings" "testing" "github.com/sylabs/singularity/v4/internal/pkg/test" - "gotest.tools/v3/golden" ) func TestPasswd(t *testing.T) { @@ -26,10 +28,10 @@ func TestPasswd(t *testing.T) { t.Errorf("should have failed with bad passwd file") } - // Test how Passwd() works with an empty file + // Adding current user to an empty file f, err := os.CreateTemp("", "empty-passwd-") if err != nil { - t.Error(err) + t.Fatal(err) } emptyPasswd := f.Name() defer os.Remove(emptyPasswd) @@ -37,18 +39,22 @@ func TestPasswd(t *testing.T) { _, err = Passwd(emptyPasswd, "/home", uid, nil) if err != nil { - t.Error(err) + t.Fatalf("Unexpected error in Passwd() when adding uid %d: %v", uid, err) } + // Modifying root user in test file inputPasswdFilePath := filepath.Join(".", "testdata", "passwd.in") - testUID := 0 - testHomeDir := "/tmp" - testGoldenFile := "passwd.root.customhome.golden" - bytes, err := Passwd(inputPasswdFilePath, testHomeDir, testUID, nil) + outputPasswd, err := Passwd(inputPasswdFilePath, "/tmp", 0, nil) if err != nil { - t.Errorf("Unexpected error encountered calling Passwd(): %v", err) - return + t.Fatalf("Unexpected error in Passwd() when modifying root entry: %v", err) } - golden.Assert(t, string(bytes), testGoldenFile, "mismatch in Passwd() invocation (uid: %d; requested homeDir: %#v)", testUID, testHomeDir) + rootUser, err := user.Lookup("root") + if err != nil { + t.Fatal(err) + } + expectRootEntry := fmt.Sprintf("root:x:0:0:%s:/tmp:/bin/ash\n", rootUser.Name) + if !strings.HasPrefix(string(outputPasswd), expectRootEntry) { + t.Errorf("Expected root entry %q, not found in:\n%s", expectRootEntry, string(outputPasswd)) + } } diff --git a/internal/pkg/util/fs/files/testdata/passwd.root.customhome.golden b/internal/pkg/util/fs/files/testdata/passwd.root.customhome.golden deleted file mode 100644 index bf7647336a..0000000000 --- a/internal/pkg/util/fs/files/testdata/passwd.root.customhome.golden +++ /dev/null @@ -1,29 +0,0 @@ -root:x:0:0:root:/tmp:/bin/ash -bin:x:1:1:bin:/bin:/sbin/nologin -daemon:x:2:2:daemon:/sbin:/sbin/nologin -adm:x:3:4:adm:/var/adm:/sbin/nologin -lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin -sync:x:5:0:sync:/sbin:/bin/sync -shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown -halt:x:7:0:halt:/sbin:/sbin/halt -mail:x:8:12:mail:/var/mail:/sbin/nologin -news:x:9:13:news:/usr/lib/news:/sbin/nologin -uucp:x:10:14:uucp:/var/spool/uucppublic:/sbin/nologin -operator:x:11:0:operator:/root:/sbin/nologin -man:x:13:15:man:/usr/man:/sbin/nologin -postmaster:x:14:12:postmaster:/var/mail:/sbin/nologin -cron:x:16:16:cron:/var/spool/cron:/sbin/nologin -ftp:x:21:21::/var/lib/ftp:/sbin/nologin -sshd:x:22:22:sshd:/dev/null:/sbin/nologin -at:x:25:25:at:/var/spool/cron/atjobs:/sbin/nologin -squid:x:31:31:Squid:/var/cache/squid:/sbin/nologin -xfs:x:33:33:X Font Server:/etc/X11/fs:/sbin/nologin -games:x:35:35:games:/usr/games:/sbin/nologin -cyrus:x:85:12::/usr/cyrus:/sbin/nologin -vpopmail:x:89:89::/var/vpopmail:/sbin/nologin -ntp:x:123:123:NTP:/var/empty:/sbin/nologin -smmsp:x:209:209:smmsp:/var/spool/mqueue:/sbin/nologin -guest:x:405:100:guest:/dev/null:/sbin/nologin -nobody:x:65534:65534:nobody:/:/sbin/nologin -leela:x:3727:3727:Turanga Leela:/home/leela:/usr/bin/zsh -fry:x:3728:3728:Philip J. Fry:/home/fry:/usr/bin/zsh From af64d7e824064a6ceecd196a5ac11e72af4cd19b Mon Sep 17 00:00:00 2001 From: David Trudgian Date: Fri, 17 Jan 2025 13:18:26 +0000 Subject: [PATCH 2/4] chore: bump CI / docs to Go 1.23.5 --- .circleci/config.yml | 2 +- INSTALL.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cc6958d7e8..3118e79165 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,7 +6,7 @@ orbs: parameters: go-version: type: string - default: '1.23.4' + default: '1.23.5' executors: node: diff --git a/INSTALL.md b/INSTALL.md index f615201c29..c59e0fe640 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -143,7 +143,7 @@ _**NOTE:** if you are updating Go from a older version, make sure you remove `/usr/local/go` before reinstalling it._ ```sh -export VERSION=1.23.4 OS=linux ARCH=amd64 # change this as you need +export VERSION=1.23.5 OS=linux ARCH=amd64 # change this as you need wget -O /tmp/go${VERSION}.${OS}-${ARCH}.tar.gz \ https://dl.google.com/go/go${VERSION}.${OS}-${ARCH}.tar.gz From faf7b7a8b239f10b7b0026e8da6987a1bef3ee50 Mon Sep 17 00:00:00 2001 From: David Trudgian Date: Fri, 17 Jan 2025 13:24:23 +0000 Subject: [PATCH 3/4] chore: update conmon submodule to v2.11.12 --- third_party/conmon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/conmon b/third_party/conmon index 2dcd736e46..e889663129 160000 --- a/third_party/conmon +++ b/third_party/conmon @@ -1 +1 @@ -Subproject commit 2dcd736e46ded79a53339462bc251694b150f870 +Subproject commit e8896631295ccb0bfdda4284f1751be19b483264 From 7f70dcf8b833a321e3a52ecdefb7569732e89d17 Mon Sep 17 00:00:00 2001 From: David Trudgian Date: Fri, 17 Jan 2025 13:25:02 +0000 Subject: [PATCH 4/4] chore: update squashfuse submodule to 0.5.2 --- third_party/squashfuse | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/squashfuse b/third_party/squashfuse index 3f4dd2928a..775b4cc72a 160000 --- a/third_party/squashfuse +++ b/third_party/squashfuse @@ -1 +1 @@ -Subproject commit 3f4dd2928ab362f8b20eab2be864d8e622472df5 +Subproject commit 775b4cc72ab47641637897f11ce0da15d5c1f115