Skip to content

Commit df23c0a

Browse files
committed
techdebt: Remove workaround for squashfs-tools <4.3
A workaround was in place for squashfs-tools <4.3 which does not support the `user-xattrs` flag. All our target distros use 4.3 or later, so remove the conditionals to simplify the squashfs unpack logic.
1 parent e7f7ef9 commit df23c0a

File tree

3 files changed

+10
-38
lines changed

3 files changed

+10
-38
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
seccomp headers at build time. Run `mconfig` using `--without-seccomp` and
2828
`--without-conmon` to disable seccomp support and building of `conmon`
2929
(which requires seccomp headers).
30+
- SingularityCE now requires squashfs-tools >=4.3, which is satisfied by
31+
current EL / Ubuntu / Debian and other distributions.
3032

3133
### New features / functionalities
3234

e2e/inspect/inspect.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,7 @@ func (c ctx) singularityInspect(t *testing.T) {
7575
// it can't set system xattrs while rootless.
7676
cmd := exec.Command("unsquashfs", "-user-xattrs", "-d", sandboxImage, squashImage)
7777
if res := cmd.Run(t); res.Error != nil {
78-
// If we failed, then try without -user-xattrs for older unsquashfs
79-
// versions that don't have that flag.
80-
cmd := exec.Command("unsquashfs", "-d", sandboxImage, squashImage)
81-
if res := cmd.Run(t); res.Error != nil {
82-
t.Fatalf("Unexpected error while running command.\n%s", res)
83-
}
78+
t.Fatalf("Unexpected error while running command.\n%s", res)
8479
}
8580

8681
compareLabel := func(label, out string, appName string) func(*testing.T, *inspect.Metadata) {

internal/pkg/image/unpacker/squashfs.go

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
package unpacker
88

99
import (
10-
"bytes"
1110
"fmt"
1211
"io"
1312
"io/ioutil"
@@ -104,20 +103,19 @@ func (s *Squashfs) extract(files []string, reader io.Reader, dest string) (err e
104103
}
105104
}
106105

107-
// First we try unsquashfs with appropriate xattr options.
108-
// If we are in rootless mode we need "-user-xattrs" so we don't try to set system xattrs that require root.
109-
// However...
110-
// 1. This isn't supported on unsquashfs 4.0 in RHEL6 so we have to fall back to not using that option on failure.
111-
// 2. Must check (user) xattrs are supported on the FS as unsquashfs >=4.4 will give a non-zero error code if
112-
// it cannot set them, e.g. on tmpfs (#5668)
106+
// First we try unsquashfs with appropriate xattr options. If we are in
107+
// rootless mode we need "-user-xattrs" so we don't try to set system xattrs
108+
// that require root. However we must check (user) xattrs are supported on
109+
// the FS as unsquashfs >=4.4 will give a non-zero error code if it cannot
110+
// set them, e.g. on tmpfs (#5668)
113111
opts := []string{}
114112
hostuid, err := namespaces.HostUID()
115113
if err != nil {
116114
return fmt.Errorf("could not get host UID: %s", err)
117115
}
118116
rootless := hostuid != 0
119117

120-
// Do we support user xattrs?
118+
// Do our target filesystem support user xattrs?
121119
ok, err := TestUserXattr(filepath.Dir(dest))
122120
if err != nil {
123121
return err
@@ -167,33 +165,10 @@ func (s *Squashfs) extract(files []string, reader io.Reader, dest string) (err e
167165
cmd.Stdin = reader
168166
}
169167

170-
o, err := cmd.CombinedOutput()
171-
if err == nil {
172-
return nil
173-
}
174-
175-
// Invalid options give output...
176-
// SYNTAX: unsquashfs [options] filesystem [directories or files to extract]
177-
if bytes.Contains(o, []byte("SYNTAX")) {
178-
sylog.Warningf("unsquashfs does not support %v. Images with xattrs may fail to extract", opts)
179-
} else {
180-
// A different error is fatal
181-
return fmt.Errorf("extract command failed: %s: %s", string(o), err)
182-
}
183-
184-
// Now we fall back to running without additional xattr options - to do the best we can on old 4.0 squashfs that
185-
// does not support them.
186-
cmd, err = cmdFunc(s.UnsquashfsPath, dest, filter, filename)
187-
if err != nil {
188-
return fmt.Errorf("command error: %s", err)
189-
}
190-
cmd.Args = append(cmd.Args, files...)
191-
if stdin {
192-
cmd.Stdin = reader
193-
}
194168
if o, err := cmd.CombinedOutput(); err != nil {
195169
return fmt.Errorf("extract command failed: %s: %s", string(o), err)
196170
}
171+
197172
return nil
198173
}
199174

0 commit comments

Comments
 (0)