mirror of
https://github.com/mudler/luet.git
synced 2025-09-01 23:37:07 +00:00
🔧 Preserve suid,sgid and sticky bits when extracting images
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
"archive/tar"
|
||||
"context"
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -208,6 +209,7 @@ func ExtractReader(ctx *types.Context, reader io.ReadCloser, output string, keep
|
||||
PAX, Xattrs map[string]string
|
||||
Uid, Gid int
|
||||
Name string
|
||||
FileMode fs.FileMode
|
||||
}
|
||||
|
||||
permstore, err := ctx.Config.System.TempDir("permstore")
|
||||
@@ -222,8 +224,9 @@ func ExtractReader(ctx *types.Context, reader io.ReadCloser, output string, keep
|
||||
perms.SetValue(h.Name, permData{
|
||||
PAX: h.PAXRecords,
|
||||
Uid: h.Uid, Gid: h.Gid,
|
||||
Xattrs: h.Xattrs,
|
||||
Name: h.Name,
|
||||
Xattrs: h.Xattrs,
|
||||
Name: h.Name,
|
||||
FileMode: h.FileInfo().Mode(),
|
||||
})
|
||||
//perms = append(perms, })
|
||||
}
|
||||
@@ -249,6 +252,10 @@ func ExtractReader(ctx *types.Context, reader io.ReadCloser, output string, keep
|
||||
if err := os.Lchown(ff, p.Uid, p.Gid); err != nil {
|
||||
ctx.Warning(err, "failed chowning file")
|
||||
}
|
||||
ctx.Debug("Set", p.Name, p.FileMode)
|
||||
if err := os.Chmod(ff, p.FileMode); err != nil {
|
||||
ctx.Warning(err, "failed chmod file")
|
||||
}
|
||||
}
|
||||
for _, attrs := range []map[string]string{p.Xattrs, p.PAX} {
|
||||
for k, attr := range attrs {
|
||||
|
Reference in New Issue
Block a user