mirror of
https://github.com/containers/podman.git
synced 2025-09-25 07:44:24 +08:00
Bump Buildah to v1.18.0, c/storage to v1.24.0
Update to Buildah v1.18.0 and c/storage to v1.24 Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
This commit is contained in:
2
vendor/github.com/containers/storage/VERSION
generated
vendored
2
vendor/github.com/containers/storage/VERSION
generated
vendored
@ -1 +1 @@
|
||||
1.23.9
|
||||
1.24.0
|
||||
|
1
vendor/github.com/containers/storage/drivers/driver.go
generated
vendored
1
vendor/github.com/containers/storage/drivers/driver.go
generated
vendored
@ -60,6 +60,7 @@ type ApplyDiffOpts struct {
|
||||
Mappings *idtools.IDMappings
|
||||
MountLabel string
|
||||
IgnoreChownErrors bool
|
||||
ForceMask *os.FileMode
|
||||
}
|
||||
|
||||
// InitFunc initializes the storage driver.
|
||||
|
71
vendor/github.com/containers/storage/drivers/overlay/overlay.go
generated
vendored
71
vendor/github.com/containers/storage/drivers/overlay/overlay.go
generated
vendored
@ -93,6 +93,7 @@ type overlayOptions struct {
|
||||
skipMountHome bool
|
||||
mountOptions string
|
||||
ignoreChownErrors bool
|
||||
forceMask *os.FileMode
|
||||
}
|
||||
|
||||
// Driver contains information about the home directory and the list of active mounts that are created using this driver.
|
||||
@ -143,6 +144,9 @@ func Init(home string, options graphdriver.Options) (graphdriver.Driver, error)
|
||||
|
||||
// check if they are running over btrfs, aufs, zfs, overlay, or ecryptfs
|
||||
if opts.mountProgram == "" {
|
||||
if opts.forceMask != nil {
|
||||
return nil, errors.New("'force_mask' is supported only with 'mount_program'")
|
||||
}
|
||||
switch fsMagic {
|
||||
case graphdriver.FsMagicAufs, graphdriver.FsMagicZfs, graphdriver.FsMagicOverlay, graphdriver.FsMagicEcryptfs:
|
||||
return nil, errors.Wrapf(graphdriver.ErrIncompatibleFS, "'overlay' is not supported over %s, a mount_program is required", backingFs)
|
||||
@ -328,6 +332,22 @@ func parseOptions(options []string) (*overlayOptions, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case "force_mask":
|
||||
logrus.Debugf("overlay: force_mask=%s", val)
|
||||
var mask int64
|
||||
switch val {
|
||||
case "shared":
|
||||
mask = 0755
|
||||
case "private":
|
||||
mask = 0700
|
||||
default:
|
||||
mask, err = strconv.ParseInt(val, 8, 32)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
m := os.FileMode(mask)
|
||||
o.forceMask = &m
|
||||
default:
|
||||
return nil, fmt.Errorf("overlay: Unknown option %s", key)
|
||||
}
|
||||
@ -573,17 +593,15 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
|
||||
if err := idtools.MkdirAllAs(path.Dir(dir), 0700, rootUID, rootGID); err != nil {
|
||||
return err
|
||||
}
|
||||
perms := defaultPerms
|
||||
if parent != "" {
|
||||
st, err := system.Stat(d.dir(parent))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
perms = os.FileMode(st.Mode())
|
||||
rootUID = int(st.UID())
|
||||
rootGID = int(st.GID())
|
||||
}
|
||||
if err := idtools.MkdirAs(dir, perms, rootUID, rootGID); err != nil {
|
||||
if err := idtools.MkdirAs(dir, 0700, rootUID, rootGID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -608,6 +626,18 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
|
||||
}
|
||||
}
|
||||
|
||||
perms := defaultPerms
|
||||
if d.options.forceMask != nil {
|
||||
perms = *d.options.forceMask
|
||||
}
|
||||
if parent != "" {
|
||||
st, err := system.Stat(filepath.Join(d.dir(parent), "diff"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
perms = os.FileMode(st.Mode())
|
||||
}
|
||||
|
||||
if err := idtools.MkdirAs(path.Join(dir, "diff"), perms, rootUID, rootGID); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -852,15 +882,24 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO
|
||||
}
|
||||
diffN := 1
|
||||
perms := defaultPerms
|
||||
if d.options.forceMask != nil {
|
||||
perms = *d.options.forceMask
|
||||
}
|
||||
permsKnown := false
|
||||
st, err := os.Stat(filepath.Join(dir, nameWithSuffix("diff", diffN)))
|
||||
if err == nil {
|
||||
perms = os.FileMode(st.Mode())
|
||||
permsKnown = true
|
||||
}
|
||||
for err == nil {
|
||||
absLowers = append(absLowers, filepath.Join(dir, nameWithSuffix("diff", diffN)))
|
||||
relLowers = append(relLowers, dumbJoin(string(link), "..", nameWithSuffix("diff", diffN)))
|
||||
diffN++
|
||||
_, err = os.Stat(filepath.Join(dir, nameWithSuffix("diff", diffN)))
|
||||
st, err = os.Stat(filepath.Join(dir, nameWithSuffix("diff", diffN)))
|
||||
if err == nil && !permsKnown {
|
||||
perms = os.FileMode(st.Mode())
|
||||
permsKnown = true
|
||||
}
|
||||
}
|
||||
|
||||
// For each lower, resolve its path, and append it and any additional diffN
|
||||
@ -871,10 +910,14 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO
|
||||
}
|
||||
lower := ""
|
||||
newpath := path.Join(d.home, l)
|
||||
if _, err := os.Stat(newpath); err != nil {
|
||||
if st, err := os.Stat(newpath); err != nil {
|
||||
for _, p := range d.AdditionalImageStores() {
|
||||
lower = path.Join(p, d.name, l)
|
||||
if _, err2 := os.Stat(lower); err2 == nil {
|
||||
if st2, err2 := os.Stat(lower); err2 == nil {
|
||||
if !permsKnown {
|
||||
perms = os.FileMode(st2.Mode())
|
||||
permsKnown = true
|
||||
}
|
||||
break
|
||||
}
|
||||
lower = ""
|
||||
@ -892,6 +935,10 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO
|
||||
return "", fmt.Errorf("Can't stat lower layer %q: %v", newpath, err)
|
||||
}
|
||||
} else {
|
||||
if !permsKnown {
|
||||
perms = os.FileMode(st.Mode())
|
||||
permsKnown = true
|
||||
}
|
||||
lower = newpath
|
||||
}
|
||||
absLowers = append(absLowers, lower)
|
||||
@ -1122,6 +1169,9 @@ func (d *Driver) ApplyDiff(id, parent string, options graphdriver.ApplyDiffOpts)
|
||||
if d.options.ignoreChownErrors {
|
||||
options.IgnoreChownErrors = d.options.ignoreChownErrors
|
||||
}
|
||||
if d.options.forceMask != nil {
|
||||
options.ForceMask = d.options.forceMask
|
||||
}
|
||||
return d.naiveDiff.ApplyDiff(id, parent, options)
|
||||
}
|
||||
|
||||
@ -1138,6 +1188,7 @@ func (d *Driver) ApplyDiff(id, parent string, options graphdriver.ApplyDiffOpts)
|
||||
UIDMaps: idMappings.UIDs(),
|
||||
GIDMaps: idMappings.GIDs(),
|
||||
IgnoreChownErrors: d.options.ignoreChownErrors,
|
||||
ForceMask: d.options.forceMask,
|
||||
WhiteoutFormat: d.getWhiteoutFormat(),
|
||||
InUserNS: rsystem.RunningInUserNS(),
|
||||
}); err != nil {
|
||||
@ -1251,8 +1302,12 @@ func (d *Driver) UpdateLayerIDMap(id string, toContainer, toHost *idtools.IDMapp
|
||||
i := 0
|
||||
perms := defaultPerms
|
||||
st, err := os.Stat(nameWithSuffix(diffDir, i))
|
||||
if err == nil {
|
||||
perms = os.FileMode(st.Mode())
|
||||
if d.options.forceMask != nil {
|
||||
perms = *d.options.forceMask
|
||||
} else {
|
||||
if err == nil {
|
||||
perms = os.FileMode(st.Mode())
|
||||
}
|
||||
}
|
||||
for err == nil {
|
||||
i++
|
||||
|
2
vendor/github.com/containers/storage/drivers/windows/windows.go
generated
vendored
2
vendor/github.com/containers/storage/drivers/windows/windows.go
generated
vendored
@ -3,6 +3,7 @@
|
||||
package windows
|
||||
|
||||
import (
|
||||
"archive/tar"
|
||||
"bufio"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
@ -21,7 +22,6 @@ import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/Microsoft/go-winio"
|
||||
"github.com/Microsoft/go-winio/archive/tar"
|
||||
"github.com/Microsoft/go-winio/backuptar"
|
||||
"github.com/Microsoft/hcsshim"
|
||||
"github.com/containers/storage/drivers"
|
||||
|
2
vendor/github.com/containers/storage/go.mod
generated
vendored
2
vendor/github.com/containers/storage/go.mod
generated
vendored
@ -4,7 +4,7 @@ module github.com/containers/storage
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v0.3.1
|
||||
github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5
|
||||
github.com/Microsoft/go-winio v0.4.15
|
||||
github.com/Microsoft/hcsshim v0.8.9
|
||||
github.com/docker/go-units v0.4.0
|
||||
github.com/hashicorp/go-multierror v1.1.0
|
||||
|
2
vendor/github.com/containers/storage/go.sum
generated
vendored
2
vendor/github.com/containers/storage/go.sum
generated
vendored
@ -3,6 +3,8 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5 h1:ygIc8M6trr62pF5DucadTWGdEB4mEyvzi0e2nbcmcyA=
|
||||
github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw=
|
||||
github.com/Microsoft/go-winio v0.4.15 h1:qkLXKzb1QoVatRyd/YlXZ/Kg0m5K3SPuoD82jjSOaBc=
|
||||
github.com/Microsoft/go-winio v0.4.15/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw=
|
||||
github.com/Microsoft/hcsshim v0.8.9 h1:VrfodqvztU8YSOvygU+DN1BGaSGxmrNfqOv5oOuX2Bk=
|
||||
github.com/Microsoft/hcsshim v0.8.9/go.mod h1:5692vkUqntj1idxauYlpoINNKeqCiG6Sg38RRsjT5y8=
|
||||
github.com/checkpoint-restore/go-criu/v4 v4.0.2 h1:jt+rnBIhFtPw0fhtpYGcUOilh4aO9Hj7r+YLEtf30uA=
|
||||
|
41
vendor/github.com/containers/storage/pkg/archive/archive.go
generated
vendored
41
vendor/github.com/containers/storage/pkg/archive/archive.go
generated
vendored
@ -65,13 +65,16 @@ type (
|
||||
// from the traditional behavior/format to get features like subsecond
|
||||
// precision in timestamps.
|
||||
CopyPass bool
|
||||
// ForceMask, if set, indicates the permission mask used for created files.
|
||||
ForceMask *os.FileMode
|
||||
}
|
||||
)
|
||||
|
||||
const (
|
||||
tarExt = "tar"
|
||||
solaris = "solaris"
|
||||
windows = "windows"
|
||||
tarExt = "tar"
|
||||
solaris = "solaris"
|
||||
windows = "windows"
|
||||
containersOverrideXattr = "user.containers.override_stat"
|
||||
)
|
||||
|
||||
// Archiver allows the reuse of most utility functions of this package with a
|
||||
@ -603,18 +606,23 @@ func (ta *tarAppender) addTarFile(path, name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, Lchown bool, chownOpts *idtools.IDPair, inUserns, ignoreChownErrors bool, buffer []byte) error {
|
||||
func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, Lchown bool, chownOpts *idtools.IDPair, inUserns, ignoreChownErrors bool, forceMask *os.FileMode, buffer []byte) error {
|
||||
// hdr.Mode is in linux format, which we can use for sycalls,
|
||||
// but for os.Foo() calls we need the mode converted to os.FileMode,
|
||||
// so use hdrInfo.Mode() (they differ for e.g. setuid bits)
|
||||
hdrInfo := hdr.FileInfo()
|
||||
|
||||
mask := hdrInfo.Mode()
|
||||
if forceMask != nil {
|
||||
mask = *forceMask
|
||||
}
|
||||
|
||||
switch hdr.Typeflag {
|
||||
case tar.TypeDir:
|
||||
// Create directory unless it exists as a directory already.
|
||||
// In that case we just want to merge the two
|
||||
if fi, err := os.Lstat(path); !(err == nil && fi.IsDir()) {
|
||||
if err := os.Mkdir(path, hdrInfo.Mode()); err != nil {
|
||||
if err := os.Mkdir(path, mask); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -623,7 +631,7 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, L
|
||||
// Source is regular file. We use system.OpenFileSequential to use sequential
|
||||
// file access to avoid depleting the standby list on Windows.
|
||||
// On Linux, this equates to a regular os.OpenFile
|
||||
file, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY, hdrInfo.Mode())
|
||||
file, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY, mask)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -680,6 +688,13 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, L
|
||||
return fmt.Errorf("unhandled tar header type %d", hdr.Typeflag)
|
||||
}
|
||||
|
||||
if forceMask != nil && hdr.Typeflag != tar.TypeSymlink {
|
||||
value := fmt.Sprintf("%d:%d:0%o", hdr.Uid, hdr.Gid, hdrInfo.Mode()&07777)
|
||||
if err := system.Lsetxattr(path, containersOverrideXattr, []byte(value), 0); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Lchown is not supported on Windows.
|
||||
if Lchown && runtime.GOOS != windows {
|
||||
if chownOpts == nil {
|
||||
@ -697,7 +712,7 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, L
|
||||
|
||||
// There is no LChmod, so ignore mode for symlink. Also, this
|
||||
// must happen after chown, as that can modify the file mode
|
||||
if err := handleLChmod(hdr, path, hdrInfo); err != nil {
|
||||
if err := handleLChmod(hdr, path, hdrInfo, forceMask); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -946,6 +961,16 @@ func Unpack(decompressedArchive io.Reader, dest string, options *TarOptions) err
|
||||
whiteoutConverter := getWhiteoutConverter(options.WhiteoutFormat, options.WhiteoutData)
|
||||
buffer := make([]byte, 1<<20)
|
||||
|
||||
if options.ForceMask != nil {
|
||||
uid, gid, mode, err := getFileOwner(dest)
|
||||
if err == nil {
|
||||
value := fmt.Sprintf("%d:%d:0%o", uid, gid, mode)
|
||||
if err := system.Lsetxattr(dest, containersOverrideXattr, []byte(value), 0); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate through the files in the archive.
|
||||
loop:
|
||||
for {
|
||||
@ -1041,7 +1066,7 @@ loop:
|
||||
chownOpts = &idtools.IDPair{UID: hdr.Uid, GID: hdr.Gid}
|
||||
}
|
||||
|
||||
if err := createTarFile(path, dest, hdr, trBuf, !options.NoLchown, chownOpts, options.InUserNS, options.IgnoreChownErrors, buffer); err != nil {
|
||||
if err := createTarFile(path, dest, hdr, trBuf, !options.NoLchown, chownOpts, options.InUserNS, options.IgnoreChownErrors, options.ForceMask, buffer); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
61
vendor/github.com/containers/storage/pkg/archive/archive_ffjson.go
generated
vendored
61
vendor/github.com/containers/storage/pkg/archive/archive_ffjson.go
generated
vendored
@ -10,6 +10,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/containers/storage/pkg/idtools"
|
||||
fflib "github.com/pquerna/ffjson/fflib/v1"
|
||||
"os"
|
||||
)
|
||||
|
||||
// MarshalJSON marshal bytes to json - template
|
||||
@ -501,6 +502,12 @@ func (j *TarOptions) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
|
||||
} else {
|
||||
buf.WriteString(`,"CopyPass":false`)
|
||||
}
|
||||
if j.ForceMask != nil {
|
||||
buf.WriteString(`,"ForceMask":`)
|
||||
fflib.FormatBits2(buf, uint64(*j.ForceMask), 10, false)
|
||||
} else {
|
||||
buf.WriteString(`,"ForceMask":null`)
|
||||
}
|
||||
buf.WriteByte('}')
|
||||
return nil
|
||||
}
|
||||
@ -538,6 +545,8 @@ const (
|
||||
ffjtTarOptionsInUserNS
|
||||
|
||||
ffjtTarOptionsCopyPass
|
||||
|
||||
ffjtTarOptionsForceMask
|
||||
)
|
||||
|
||||
var ffjKeyTarOptionsIncludeFiles = []byte("IncludeFiles")
|
||||
@ -570,6 +579,8 @@ var ffjKeyTarOptionsInUserNS = []byte("InUserNS")
|
||||
|
||||
var ffjKeyTarOptionsCopyPass = []byte("CopyPass")
|
||||
|
||||
var ffjKeyTarOptionsForceMask = []byte("ForceMask")
|
||||
|
||||
// UnmarshalJSON umarshall json - template of ffjson
|
||||
func (j *TarOptions) UnmarshalJSON(input []byte) error {
|
||||
fs := fflib.NewFFLexer(input)
|
||||
@ -657,6 +668,14 @@ mainparse:
|
||||
goto mainparse
|
||||
}
|
||||
|
||||
case 'F':
|
||||
|
||||
if bytes.Equal(ffjKeyTarOptionsForceMask, kn) {
|
||||
currentKey = ffjtTarOptionsForceMask
|
||||
state = fflib.FFParse_want_colon
|
||||
goto mainparse
|
||||
}
|
||||
|
||||
case 'G':
|
||||
|
||||
if bytes.Equal(ffjKeyTarOptionsGIDMaps, kn) {
|
||||
@ -732,6 +751,12 @@ mainparse:
|
||||
|
||||
}
|
||||
|
||||
if fflib.EqualFoldRight(ffjKeyTarOptionsForceMask, kn) {
|
||||
currentKey = ffjtTarOptionsForceMask
|
||||
state = fflib.FFParse_want_colon
|
||||
goto mainparse
|
||||
}
|
||||
|
||||
if fflib.EqualFoldRight(ffjKeyTarOptionsCopyPass, kn) {
|
||||
currentKey = ffjtTarOptionsCopyPass
|
||||
state = fflib.FFParse_want_colon
|
||||
@ -884,6 +909,9 @@ mainparse:
|
||||
case ffjtTarOptionsCopyPass:
|
||||
goto handle_CopyPass
|
||||
|
||||
case ffjtTarOptionsForceMask:
|
||||
goto handle_ForceMask
|
||||
|
||||
case ffjtTarOptionsnosuchkey:
|
||||
err = fs.SkipField(tok)
|
||||
if err != nil {
|
||||
@ -1597,6 +1625,39 @@ handle_CopyPass:
|
||||
state = fflib.FFParse_after_value
|
||||
goto mainparse
|
||||
|
||||
handle_ForceMask:
|
||||
|
||||
/* handler: j.ForceMask type=os.FileMode kind=uint32 quoted=false*/
|
||||
|
||||
{
|
||||
if tok != fflib.FFTok_integer && tok != fflib.FFTok_null {
|
||||
return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for FileMode", tok))
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
if tok == fflib.FFTok_null {
|
||||
|
||||
j.ForceMask = nil
|
||||
|
||||
} else {
|
||||
|
||||
tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 32)
|
||||
|
||||
if err != nil {
|
||||
return fs.WrapErr(err)
|
||||
}
|
||||
|
||||
ttypval := os.FileMode(tval)
|
||||
j.ForceMask = &ttypval
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
state = fflib.FFParse_after_value
|
||||
goto mainparse
|
||||
|
||||
wantedvalue:
|
||||
return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok))
|
||||
wrongtokenerror:
|
||||
|
12
vendor/github.com/containers/storage/pkg/archive/archive_linux.go
generated
vendored
12
vendor/github.com/containers/storage/pkg/archive/archive_linux.go
generated
vendored
@ -142,3 +142,15 @@ func isWhiteOut(stat os.FileInfo) bool {
|
||||
s := stat.Sys().(*syscall.Stat_t)
|
||||
return major(uint64(s.Rdev)) == 0 && minor(uint64(s.Rdev)) == 0
|
||||
}
|
||||
|
||||
func getFileOwner(path string) (uint32, uint32, uint32, error) {
|
||||
f, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return 0, 0, 0, err
|
||||
}
|
||||
s, ok := f.Sys().(*syscall.Stat_t)
|
||||
if ok {
|
||||
return s.Uid, s.Gid, s.Mode & 07777, nil
|
||||
}
|
||||
return 0, 0, uint32(f.Mode()), nil
|
||||
}
|
||||
|
4
vendor/github.com/containers/storage/pkg/archive/archive_other.go
generated
vendored
4
vendor/github.com/containers/storage/pkg/archive/archive_other.go
generated
vendored
@ -5,3 +5,7 @@ package archive
|
||||
func getWhiteoutConverter(format WhiteoutFormat, data interface{}) tarWhiteoutConverter {
|
||||
return nil
|
||||
}
|
||||
|
||||
func getFileOwner(path string) (uint32, uint32, uint32, error) {
|
||||
return 0, 0, 0, nil
|
||||
}
|
||||
|
10
vendor/github.com/containers/storage/pkg/archive/archive_unix.go
generated
vendored
10
vendor/github.com/containers/storage/pkg/archive/archive_unix.go
generated
vendored
@ -106,15 +106,19 @@ func handleTarTypeBlockCharFifo(hdr *tar.Header, path string) error {
|
||||
return system.Mknod(path, mode, int(system.Mkdev(hdr.Devmajor, hdr.Devminor)))
|
||||
}
|
||||
|
||||
func handleLChmod(hdr *tar.Header, path string, hdrInfo os.FileInfo) error {
|
||||
func handleLChmod(hdr *tar.Header, path string, hdrInfo os.FileInfo, forceMask *os.FileMode) error {
|
||||
permissionsMask := hdrInfo.Mode()
|
||||
if forceMask != nil {
|
||||
permissionsMask = *forceMask
|
||||
}
|
||||
if hdr.Typeflag == tar.TypeLink {
|
||||
if fi, err := os.Lstat(hdr.Linkname); err == nil && (fi.Mode()&os.ModeSymlink == 0) {
|
||||
if err := os.Chmod(path, hdrInfo.Mode()); err != nil {
|
||||
if err := os.Chmod(path, permissionsMask); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else if hdr.Typeflag != tar.TypeSymlink {
|
||||
if err := os.Chmod(path, hdrInfo.Mode()); err != nil {
|
||||
if err := os.Chmod(path, permissionsMask); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
2
vendor/github.com/containers/storage/pkg/archive/archive_windows.go
generated
vendored
2
vendor/github.com/containers/storage/pkg/archive/archive_windows.go
generated
vendored
@ -69,7 +69,7 @@ func handleTarTypeBlockCharFifo(hdr *tar.Header, path string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func handleLChmod(hdr *tar.Header, path string, hdrInfo os.FileInfo) error {
|
||||
func handleLChmod(hdr *tar.Header, path string, hdrInfo os.FileInfo, forceMask *os.FileMode) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
4
vendor/github.com/containers/storage/pkg/archive/diff.go
generated
vendored
4
vendor/github.com/containers/storage/pkg/archive/diff.go
generated
vendored
@ -106,7 +106,7 @@ func UnpackLayer(dest string, layer io.Reader, options *TarOptions) (size int64,
|
||||
}
|
||||
defer os.RemoveAll(aufsTempdir)
|
||||
}
|
||||
if err := createTarFile(filepath.Join(aufsTempdir, basename), dest, hdr, tr, true, nil, options.InUserNS, options.IgnoreChownErrors, buffer); err != nil {
|
||||
if err := createTarFile(filepath.Join(aufsTempdir, basename), dest, hdr, tr, true, nil, options.InUserNS, options.IgnoreChownErrors, options.ForceMask, buffer); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
@ -197,7 +197,7 @@ func UnpackLayer(dest string, layer io.Reader, options *TarOptions) (size int64,
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if err := createTarFile(path, dest, srcHdr, srcData, true, nil, options.InUserNS, options.IgnoreChownErrors, buffer); err != nil {
|
||||
if err := createTarFile(path, dest, srcHdr, srcData, true, nil, options.InUserNS, options.IgnoreChownErrors, options.ForceMask, buffer); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
|
9
vendor/github.com/containers/storage/pkg/chrootarchive/archive.go
generated
vendored
9
vendor/github.com/containers/storage/pkg/chrootarchive/archive.go
generated
vendored
@ -5,7 +5,9 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
@ -15,6 +17,13 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// initialize nss libraries in Glibc so that the dynamic libraries are loaded in the host
|
||||
// environment not in the chroot from untrusted files.
|
||||
_, _ = user.Lookup("storage")
|
||||
_, _ = net.LookupHost("localhost")
|
||||
}
|
||||
|
||||
// NewArchiver returns a new Archiver which uses chrootarchive.Untar
|
||||
func NewArchiver(idMappings *idtools.IDMappings) *archive.Archiver {
|
||||
archiver := archive.NewArchiver(idMappings)
|
||||
|
13
vendor/github.com/containers/storage/pkg/config/config.go
generated
vendored
13
vendor/github.com/containers/storage/pkg/config/config.go
generated
vendored
@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
// ThinpoolOptionsConfig represents the "storage.options.thinpool"
|
||||
@ -94,6 +95,9 @@ type OverlayOptionsConfig struct {
|
||||
Size string `toml:"size"`
|
||||
// Do not create a bind mount on the storage home
|
||||
SkipMountHome string `toml:"skip_mount_home"`
|
||||
// ForceMask indicates the permissions mask (e.g. "0755") to use for new
|
||||
// files and directories
|
||||
ForceMask string `toml:"force_mask"`
|
||||
}
|
||||
|
||||
type VfsOptionsConfig struct {
|
||||
@ -129,6 +133,10 @@ type OptionsConfig struct {
|
||||
// ignored when building an image.
|
||||
IgnoreChownErrors string `toml:"ignore_chown_errors"`
|
||||
|
||||
// ForceMask indicates the permissions mask (e.g. "0755") to use for new
|
||||
// files and directories.
|
||||
ForceMask os.FileMode `toml:"force_mask"`
|
||||
|
||||
// RemapUser is the name of one or more entries in /etc/subuid which
|
||||
// should be used to set up default UID mappings.
|
||||
RemapUser string `toml:"remap-user"`
|
||||
@ -279,6 +287,11 @@ func GetGraphDriverOptions(driverName string, options OptionsConfig) []string {
|
||||
} else if options.SkipMountHome != "" {
|
||||
doptions = append(doptions, fmt.Sprintf("%s.skip_mount_home=%s", driverName, options.SkipMountHome))
|
||||
}
|
||||
if options.Overlay.ForceMask != "" {
|
||||
doptions = append(doptions, fmt.Sprintf("%s.force_mask=%s", driverName, options.Overlay.ForceMask))
|
||||
} else if options.ForceMask != 0 {
|
||||
doptions = append(doptions, fmt.Sprintf("%s.force_mask=%s", driverName, options.ForceMask))
|
||||
}
|
||||
case "vfs":
|
||||
if options.Vfs.IgnoreChownErrors != "" {
|
||||
doptions = append(doptions, fmt.Sprintf("%s.ignore_chown_errors=%s", driverName, options.Vfs.IgnoreChownErrors))
|
||||
|
33
vendor/github.com/containers/storage/storage.conf
generated
vendored
33
vendor/github.com/containers/storage/storage.conf
generated
vendored
@ -82,6 +82,39 @@ mountopt = "nodev"
|
||||
# Size is used to set a maximum size of the container image.
|
||||
# size = ""
|
||||
|
||||
# ForceMask specifies the permissions mask that is used for new files and
|
||||
# directories.
|
||||
#
|
||||
# The values "shared" and "private" are accepted.
|
||||
# Octal permission masks are also accepted.
|
||||
#
|
||||
# "": No value specified.
|
||||
# All files/directories, get set with the permissions identified within the
|
||||
# image.
|
||||
# "private": it is equivalent to 0700.
|
||||
# All files/directories get set with 0700 permissions. The owner has rwx
|
||||
# access to the files. No other users on the system can access the files.
|
||||
# This setting could be used with networked based homedirs.
|
||||
# "shared": it is equivalent to 0755.
|
||||
# The owner has rwx access to the files and everyone else can read, access
|
||||
# and execute them. This setting is useful for sharing containers storage
|
||||
# with other users. For instance have a storage owned by root but shared
|
||||
# to rootless users as an additional store.
|
||||
# NOTE: All files within the image are made readable and executable by any
|
||||
# user on the system. Even /etc/shadow within your image is now readable by
|
||||
# any user.
|
||||
#
|
||||
# OCTAL: Users can experiment with other OCTAL Permissions.
|
||||
#
|
||||
# Note: The force_mask Flag is an experimental feature, it could change in the
|
||||
# future. When "force_mask" is set the original permission mask is stored in
|
||||
# the "user.containers.override_stat" xattr and the "mount_program" option must
|
||||
# be specified. Mount programs like "/usr/bin/fuse-overlayfs" present the
|
||||
# extended attribute permissions to processes within containers rather then the
|
||||
# "force_mask" permissions.
|
||||
#
|
||||
# force_mask = ""
|
||||
|
||||
[storage.options.thinpool]
|
||||
# Storage Options for thinpool
|
||||
|
||||
|
3
vendor/github.com/containers/storage/store.go
generated
vendored
3
vendor/github.com/containers/storage/store.go
generated
vendored
@ -3551,6 +3551,9 @@ func ReloadConfigurationFile(configFile string, storeOptions *StoreOptions) {
|
||||
if config.Storage.Options.IgnoreChownErrors != "" {
|
||||
storeOptions.GraphDriverOptions = append(storeOptions.GraphDriverOptions, fmt.Sprintf("%s.ignore_chown_errors=%s", config.Storage.Driver, config.Storage.Options.IgnoreChownErrors))
|
||||
}
|
||||
if config.Storage.Options.ForceMask != 0 {
|
||||
storeOptions.GraphDriverOptions = append(storeOptions.GraphDriverOptions, fmt.Sprintf("%s.force_mask=%o", config.Storage.Driver, config.Storage.Options.ForceMask))
|
||||
}
|
||||
if config.Storage.Options.MountOpt != "" {
|
||||
storeOptions.GraphDriverOptions = append(storeOptions.GraphDriverOptions, fmt.Sprintf("%s.mountopt=%s", config.Storage.Driver, config.Storage.Options.MountOpt))
|
||||
}
|
||||
|
Reference in New Issue
Block a user