@@ -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