|
7 | 7 | package unpacker
|
8 | 8 |
|
9 | 9 | import (
|
10 |
| - "bytes" |
11 | 10 | "fmt"
|
12 | 11 | "io"
|
13 | 12 | "io/ioutil"
|
@@ -104,20 +103,19 @@ func (s *Squashfs) extract(files []string, reader io.Reader, dest string) (err e
|
104 | 103 | }
|
105 | 104 | }
|
106 | 105 |
|
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) |
113 | 111 | opts := []string{}
|
114 | 112 | hostuid, err := namespaces.HostUID()
|
115 | 113 | if err != nil {
|
116 | 114 | return fmt.Errorf("could not get host UID: %s", err)
|
117 | 115 | }
|
118 | 116 | rootless := hostuid != 0
|
119 | 117 |
|
120 |
| - // Do we support user xattrs? |
| 118 | + // Do our target filesystem support user xattrs? |
121 | 119 | ok, err := TestUserXattr(filepath.Dir(dest))
|
122 | 120 | if err != nil {
|
123 | 121 | return err
|
@@ -167,33 +165,10 @@ func (s *Squashfs) extract(files []string, reader io.Reader, dest string) (err e
|
167 | 165 | cmd.Stdin = reader
|
168 | 166 | }
|
169 | 167 |
|
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 |
| - } |
194 | 168 | if o, err := cmd.CombinedOutput(); err != nil {
|
195 | 169 | return fmt.Errorf("extract command failed: %s: %s", string(o), err)
|
196 | 170 | }
|
| 171 | + |
197 | 172 | return nil
|
198 | 173 | }
|
199 | 174 |
|
|
0 commit comments