Skip to content

Commit 01fdd97

Browse files
authored
Merge pull request #268 from dtrudg/pick267
Pick #267 to release-3.8
2 parents 1c2ec99 + 4ee799a commit 01fdd97

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
in `~/.singularity/remote.yaml`.
2020
- Avoid panic when mountinfo line has a blank field.
2121
- Properly escape single quotes in Docker `CMD` / `ENTRYPOINT` translation.
22+
- Use host uid when choosing unsquashfs flags, to avoid selinux xattr errors
23+
with `--fakeroot` on non-EL/Fedora distributions with recent squashfs-tools.
2224

2325
## v3.8.1 [2021-07-20]
2426

pkg/image/unpacker/squashfs.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ func (s *Squashfs) extract(files []string, reader io.Reader, dest string) (err e
110110
// 2. Must check (user) xattrs are supported on the FS as unsquashfs >=4.4 will give a non-zero error code if
111111
// it cannot set them, e.g. on tmpfs (#5668)
112112
opts := []string{}
113-
rootless := os.Geteuid() != 0
113+
hostuid, err := namespaces.HostUID()
114+
if err != nil {
115+
return fmt.Errorf("could not get host UID: %s", err)
116+
}
117+
rootless := hostuid != 0
114118

115119
// Do we support user xattrs?
116120
ok, err := TestUserXattr(filepath.Dir(dest))
@@ -129,15 +133,11 @@ func (s *Squashfs) extract(files []string, reader io.Reader, dest string) (err e
129133

130134
// non real root users could not create pseudo devices so we compare
131135
// the host UID (to include fake root user) and apply a filter at extraction (#5690)
132-
hostuid, err := namespaces.HostUID()
133-
if err != nil {
134-
return fmt.Errorf("could not get host UID: %s", err)
135-
}
136136
filter := ""
137137

138138
// exclude dev directory only if there no specific files provided for extraction
139139
// as globbing won't work with POSIX regex enabled
140-
if hostuid != 0 && len(files) == 0 {
140+
if rootless && len(files) == 0 {
141141
sylog.Debugf("Excluding /dev directory during root filesystem extraction (non root user)")
142142
// filter requires POSIX regex
143143
opts = append(opts, "-r")

0 commit comments

Comments
 (0)