vendor: update latest common, image, storage

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2026-04-27 12:52:17 +02:00
parent a8c3631856
commit 6d2e083446
14 changed files with 594 additions and 278 deletions

7
go.mod
View File

@@ -64,9 +64,9 @@ require (
github.com/vbauerster/mpb/v8 v8.12.0
github.com/vishvananda/netlink v1.3.1
go.podman.io/buildah v1.42.1-0.20260421143840-0acb6b8cca85
go.podman.io/common v0.67.2-0.20260423135811-cbaa5f41e643
go.podman.io/image/v5 v5.39.3-0.20260423135811-cbaa5f41e643
go.podman.io/storage v1.62.1-0.20260423135811-cbaa5f41e643
go.podman.io/common v0.67.2-0.20260427104901-081c2519fc6a
go.podman.io/image/v5 v5.39.3-0.20260427104901-081c2519fc6a
go.podman.io/storage v1.62.1-0.20260427104901-081c2519fc6a
golang.org/x/crypto v0.50.0
golang.org/x/net v0.53.0
golang.org/x/sync v0.20.0
@@ -140,6 +140,7 @@ require (
github.com/moby/buildkit v0.29.0 // indirect
github.com/moby/go-archive v0.2.0 // indirect
github.com/moby/patternmatcher v0.6.1 // indirect
github.com/moby/sys/devices v0.1.0 // indirect
github.com/moby/sys/mountinfo v0.7.2 // indirect
github.com/moby/sys/sequential v0.6.0 // indirect
github.com/moby/sys/userns v0.1.0 // indirect

14
go.sum
View File

@@ -261,6 +261,8 @@ github.com/moby/patternmatcher v0.6.1 h1:qlhtafmr6kgMIJjKJMDmMWq7WLkKIo23hsrpR3x
github.com/moby/patternmatcher v0.6.1/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
github.com/moby/sys/capability v0.4.0 h1:4D4mI6KlNtWMCM1Z/K0i7RV1FkX+DBDHKVJpCndZoHk=
github.com/moby/sys/capability v0.4.0/go.mod h1:4g9IK291rVkms3LKCDOoYlnV8xKwoDTpIrNEE35Wq0I=
github.com/moby/sys/devices v0.1.0 h1:uaMrDm1U3h0AwUDNWeT5lBV40v0eayt+VuukRbYn5K4=
github.com/moby/sys/devices v0.1.0/go.mod h1:nIV6AO7t0DY2ObAm1GfL4AX9mBRqzxzHwGfvNCR9lfI=
github.com/moby/sys/mountinfo v0.7.2 h1:1shs6aH5s4o5H2zQLn796ADW1wMrIwHsyJ2v9KouLrg=
github.com/moby/sys/mountinfo v0.7.2/go.mod h1:1YOa8w8Ih7uW0wALDUgT1dTTSBrZ+HiBLGws92L2RU4=
github.com/moby/sys/sequential v0.6.0 h1:qrx7XFUd/5DxtqcoH1h438hF5TmOvzC/lspjy7zgvCU=
@@ -429,12 +431,12 @@ go.opentelemetry.io/otel/trace v1.43.0 h1:BkNrHpup+4k4w+ZZ86CZoHHEkohws8AY+WTX09
go.opentelemetry.io/otel/trace v1.43.0/go.mod h1:/QJhyVBUUswCphDVxq+8mld+AvhXZLhe+8WVFxiFff0=
go.podman.io/buildah v1.42.1-0.20260421143840-0acb6b8cca85 h1:rVKRagobPO6kGHOg2NhGNs6xWVgZctiOn4tmxa3cytA=
go.podman.io/buildah v1.42.1-0.20260421143840-0acb6b8cca85/go.mod h1:JjFirF1zlILz55ZkVYYhLRnted7mPlmoS2w2ihYw8iw=
go.podman.io/common v0.67.2-0.20260423135811-cbaa5f41e643 h1:WwUcVKPEUoSDiQ22osdYGqM3q9IDB4viqSASPCdw1K0=
go.podman.io/common v0.67.2-0.20260423135811-cbaa5f41e643/go.mod h1:kBztCGxEhou0OO0O4yJXAKC3JEQTmOxCJPni90+sQKY=
go.podman.io/image/v5 v5.39.3-0.20260423135811-cbaa5f41e643 h1:1LuhuiiXHHteVXULDV/x9qxJtFozQPLEYKHCbYdOuP0=
go.podman.io/image/v5 v5.39.3-0.20260423135811-cbaa5f41e643/go.mod h1:sAszAH18v4KPpzPZdav9ovjEBcIDkmqdhbJV9SmnzfE=
go.podman.io/storage v1.62.1-0.20260423135811-cbaa5f41e643 h1:/zmZ36KkCZumHK0EDH5QpSjyM3fY09YuyIfqoXxEI48=
go.podman.io/storage v1.62.1-0.20260423135811-cbaa5f41e643/go.mod h1:13aOBf6782/fbAzH7QNEqlVzFu+X4sS4MxDM/VdJGZU=
go.podman.io/common v0.67.2-0.20260427104901-081c2519fc6a h1:cWMyBIJJe5g67dRtnzstL/tneqk2zUFDOrWHuX88tfg=
go.podman.io/common v0.67.2-0.20260427104901-081c2519fc6a/go.mod h1:dxkgre+xzxpAUuDsXBeAgTcNR4jN8d/00oHYt8QcNHs=
go.podman.io/image/v5 v5.39.3-0.20260427104901-081c2519fc6a h1:8tXwkOe3xho4XKZcsGu8PPMZi80bwQ/IR0Blr8dH69I=
go.podman.io/image/v5 v5.39.3-0.20260427104901-081c2519fc6a/go.mod h1:sAszAH18v4KPpzPZdav9ovjEBcIDkmqdhbJV9SmnzfE=
go.podman.io/storage v1.62.1-0.20260427104901-081c2519fc6a h1:i1Imee48BwEq66Kkwb2TAUnwDTOeGNLkUsXyjcdYHeA=
go.podman.io/storage v1.62.1-0.20260427104901-081c2519fc6a/go.mod h1:13aOBf6782/fbAzH7QNEqlVzFu+X4sS4MxDM/VdJGZU=
go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0=
go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=

202
vendor/github.com/moby/sys/devices/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

133
vendor/github.com/moby/sys/devices/device_unix.go generated vendored Normal file
View File

@@ -0,0 +1,133 @@
//go:build !windows
// SPDX-License-Identifier: Apache-2.0
/*
* Copyright (C) 2015-2026 Open Containers Initiative Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This code originally comes from runc and was taken from this tree:
// <https://github.com/opencontainers/runc/tree/v1.4.0/libcontainer/devices>.
package devices
import (
"errors"
"os"
"path/filepath"
"github.com/opencontainers/cgroups/devices/config"
"golang.org/x/sys/unix"
)
// ErrNotADevice denotes that a file is not a valid linux device.
var ErrNotADevice = errors.New("not a device node")
// Testing dependencies
var (
unixLstat = unix.Lstat
osReadDir = os.ReadDir
)
// DeviceFromPath takes the path to a device and its cgroup_permissions (which
// cannot be easily queried) to look up the information about a linux device
// and returns that information as a Device struct.
func DeviceFromPath(path, permissions string) (*config.Device, error) {
var stat unix.Stat_t
err := unixLstat(path, &stat)
if err != nil {
return nil, err
}
var (
devType config.Type
mode = stat.Mode
devNumber = uint64(stat.Rdev) //nolint:unconvert // Rdev is uint32 on e.g. MIPS.
major = unix.Major(devNumber)
minor = unix.Minor(devNumber)
)
switch mode & unix.S_IFMT {
case unix.S_IFBLK:
devType = config.BlockDevice
case unix.S_IFCHR:
devType = config.CharDevice
case unix.S_IFIFO:
devType = config.FifoDevice
default:
return nil, ErrNotADevice
}
return &config.Device{
Rule: config.Rule{
Type: devType,
Major: int64(major),
Minor: int64(minor),
Permissions: config.Permissions(permissions),
},
Path: path,
FileMode: os.FileMode(mode &^ unix.S_IFMT),
Uid: stat.Uid,
Gid: stat.Gid,
}, nil
}
// HostDevices returns all devices that can be found under /dev directory.
func HostDevices() ([]*config.Device, error) {
return GetDevices("/dev")
}
// GetDevices recursively traverses a directory specified by path
// and returns all devices found there.
func GetDevices(path string) ([]*config.Device, error) {
files, err := osReadDir(path)
if err != nil {
return nil, err
}
var out []*config.Device
for _, f := range files {
switch {
case f.IsDir():
switch f.Name() {
// ".lxc" & ".lxd-mounts" added to address https://github.com/lxc/lxd/issues/2825
// ".udev" added to address https://github.com/opencontainers/runc/issues/2093
case "pts", "shm", "fd", "mqueue", ".lxc", ".lxd-mounts", ".udev":
continue
default:
sub, err := GetDevices(filepath.Join(path, f.Name()))
if err != nil {
return nil, err
}
out = append(out, sub...)
continue
}
case f.Name() == "console":
continue
}
device, err := DeviceFromPath(filepath.Join(path, f.Name()), "rwm")
if err != nil {
if errors.Is(err, ErrNotADevice) {
continue
}
if errors.Is(err, os.ErrNotExist) {
continue
}
return nil, err
}
if device.Type == config.FifoDevice {
continue
}
out = append(out, device)
}
return out, nil
}

4
vendor/github.com/moby/sys/devices/doc.go generated vendored Normal file
View File

@@ -0,0 +1,4 @@
// Package devices provides some helper functions for constructing device
// configurations for runc. These are exclusively used by higher-level runtimes
// that need to configure runc's device list based on existing devices.
package devices

View File

@@ -15,7 +15,6 @@ import (
"strings"
"text/template"
runcaa "github.com/opencontainers/runc/libcontainer/apparmor"
"github.com/sirupsen/logrus"
"go.podman.io/common/pkg/apparmor/internal/supported"
"go.podman.io/storage/pkg/fileutils"
@@ -271,7 +270,7 @@ func CheckProfileAndLoadDefault(name string) (string, error) {
}
// Check if AppArmor is disabled and error out if a profile is to be set.
if !runcaa.IsEnabled() {
if !supported.IsEnabledOnHost() {
if name == "" {
return "", nil
}

View File

@@ -1,3 +1,5 @@
//go:build linux
package supported
import (
@@ -8,8 +10,8 @@ import (
"path/filepath"
"sync"
runcaa "github.com/opencontainers/runc/libcontainer/apparmor"
"github.com/sirupsen/logrus"
"go.podman.io/storage/pkg/fileutils"
"go.podman.io/storage/pkg/unshare"
)
@@ -102,7 +104,7 @@ func (d *defaultVerifier) UnshareIsRootless() bool {
}
func (d *defaultVerifier) RuncIsEnabled() bool {
return runcaa.IsEnabled()
return IsEnabledOnHost()
}
func (d *defaultVerifier) OsStat(name string) (os.FileInfo, error) {
@@ -112,3 +114,19 @@ func (d *defaultVerifier) OsStat(name string) (os.FileInfo, error) {
func (d *defaultVerifier) ExecLookPath(file string) (string, error) {
return exec.LookPath(file)
}
var isEnabledOnHost = sync.OnceValue(func() bool {
if err := fileutils.Exists("/sys/kernel/security/apparmor"); err != nil {
return false
}
buf, err := os.ReadFile("/sys/module/apparmor/parameters/enabled")
if err != nil {
return false
}
return len(buf) >= 1 && buf[0] == 'Y'
})
// IsEnabled returns true if apparmor is enabled for the host.
func IsEnabledOnHost() bool {
return isEnabledOnHost()
}

View File

@@ -1,5 +1,7 @@
package config
import "go.podman.io/storage/pkg/configfile"
// LoadedModules returns absolute paths to loaded containers.conf modules.
func (c *Config) LoadedModules() []string {
// Required for conmon's callback to Podman's cleanup.
@@ -12,6 +14,9 @@ func (c *Config) LoadedModules() []string {
// 2) /etc/
// 3) /usr/share.
func ModuleDirectories() ([]string, error) { // Public API for shell completions in Podman
// FIXME: expose this again
return nil, nil
conf := defaultConfigFileOpts()
// API needs us to pass an non empty string to trigger module path resolution
conf.Modules = []string{""}
paths, err := configfile.GetSearchPaths(conf)
return paths.ModuleDirectories, err
}

View File

@@ -7,8 +7,8 @@ import (
"os"
"path/filepath"
"github.com/moby/sys/devices"
"github.com/opencontainers/cgroups/devices/config"
"github.com/opencontainers/runc/libcontainer/devices"
"go.podman.io/storage/pkg/unshare"
)

View File

@@ -553,7 +553,7 @@ func ConfigDirPath(ctx *types.SystemContext) string {
//
// Note some env vars like CONTAINERS_REGISTRIES_CONF or $HOME will effect the
// parsing behavior but are not used for the cache key here, if these env change
// at runtime then the cache will result in correct results. This is a known trade
// at runtime then the cache will return incorrect results. This is a known trade
// off as regular callers are not expected to modify the envs at runtime.
// If they do so they should call [InvalidateCache].
type configWrapper struct {

View File

@@ -483,15 +483,20 @@ func (d *Driver) CreateFromTemplate(id, template string, templateIDMappings *idt
// CreateReadWrite creates a layer that is writable for use as a container
// file system.
func (d *Driver) CreateReadWrite(id, parent string, opts *graphdriver.CreateOpts) error {
return d.create(id, parent, opts, true)
return d.create(id, parent, opts, false)
}
// Create the filesystem with given id.
func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) error {
return d.create(id, parent, opts, false)
return d.create(id, parent, opts, true)
}
func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts, applyDriverDefaultQuota bool) error {
func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts, readOnly bool) error {
quota, err := d.parseStorageOpt(opts, readOnly)
if err != nil {
return err
}
quotas := d.quotasDir()
subvolumes := d.subvolumesDir()
if err := os.MkdirAll(subvolumes, 0o700); err != nil {
@@ -518,34 +523,14 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts, applyDr
}
}
var storageOpt map[string]string
if opts != nil {
storageOpt = opts.StorageOpt
}
var quotaSize uint64
var needQuota bool
if _, ok := storageOpt["size"]; ok {
driver := &Driver{}
if err := d.parseStorageOpt(storageOpt, driver); err != nil {
return err
}
quotaSize = driver.options.size
needQuota = true
}
if !needQuota && applyDriverDefaultQuota && d.options.size > 0 {
quotaSize = d.options.size
needQuota = true
}
if needQuota {
layerDriver := &Driver{options: btrfsOptions{size: quotaSize}}
if err := d.setStorageSize(path.Join(subvolumes, id), layerDriver); err != nil {
if quota != nil {
if err := d.setStorageSize(path.Join(subvolumes, id), *quota); err != nil {
return err
}
if err := os.MkdirAll(quotas, 0o700); err != nil {
return err
}
if err := os.WriteFile(path.Join(quotas, id), []byte(fmt.Sprint(quotaSize)), 0o644); err != nil {
if err := os.WriteFile(path.Join(quotas, id), []byte(fmt.Sprint(quota.size)), 0o644); err != nil {
return err
}
}
@@ -558,8 +543,27 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts, applyDr
return label.Relabel(path.Join(subvolumes, id), mountLabel, false)
}
// Parse btrfs storage options
func (d *Driver) parseStorageOpt(storageOpt map[string]string, driver *Driver) error {
// layerQuota contains per-layer quota settings.
type layerQuota struct {
size uint64
}
// parseStorageOpt parses CreateOpts.StorageOpt.
// Returns a *layerQuota if a quota should be applied, nil otherwise.
func (d *Driver) parseStorageOpt(opts *graphdriver.CreateOpts, readOnly bool) (*layerQuota, error) {
var storageOpt map[string]string = nil // Iterating over a nil map is safe
if opts != nil {
storageOpt = opts.StorageOpt
}
res := layerQuota{}
needQuota := false
if !readOnly && d.options.size > 0 {
res.size = d.options.size
needQuota = true
}
// Read size to change the subvolume disk quota per container
for key, val := range storageOpt {
key := strings.ToLower(key)
@@ -567,23 +571,27 @@ func (d *Driver) parseStorageOpt(storageOpt map[string]string, driver *Driver) e
case "size":
size, err := units.RAMInBytes(val)
if err != nil {
return err
return nil, err
}
driver.options.size = uint64(size)
res.size = uint64(size)
needQuota = true
default:
return fmt.Errorf("unknown option %s (%q)", key, storageOpt)
return nil, fmt.Errorf("unknown option %s (%q)", key, storageOpt)
}
}
return nil
if needQuota {
return &res, nil
}
return nil, nil
}
// Set btrfs storage size
func (d *Driver) setStorageSize(dir string, driver *Driver) error {
if driver.options.size <= 0 {
return fmt.Errorf("btrfs: invalid storage size: %s", units.HumanSize(float64(driver.options.size)))
func (d *Driver) setStorageSize(dir string, quota layerQuota) error {
if quota.size <= 0 {
return fmt.Errorf("btrfs: invalid storage size: %s", units.HumanSize(float64(quota.size)))
}
if d.options.minSpace > 0 && driver.options.size < d.options.minSpace {
if d.options.minSpace > 0 && quota.size < d.options.minSpace {
return fmt.Errorf("btrfs: storage size cannot be less than %s", units.HumanSize(float64(d.options.minSpace)))
}
@@ -591,7 +599,7 @@ func (d *Driver) setStorageSize(dir string, driver *Driver) error {
return err
}
if err := subvolLimitQgroup(dir, driver.options.size); err != nil {
if err := subvolLimitQgroup(dir, quota.size); err != nil {
return err
}

View File

@@ -48,8 +48,7 @@ import (
var untar = chrootarchive.UntarUncompressed
const (
defaultPerms = os.FileMode(0o555)
mountProgramFlagFile = ".has-mount-program"
defaultPerms = os.FileMode(0o555)
)
// This backend uses the overlay union filesystem for containers
@@ -79,24 +78,32 @@ const (
// syscall. A hard upper limit of 500 lower layers is enforced to ensure
// that mounts do not fail due to length.
const (
linkDir = "l"
stagingDir = "staging"
tempDirName = "tempdirs"
lowerFile = "lower"
const ( // Paths within the drivers home directory
mountProgramFlagFile = ".has-mount-program"
linkDir = "l"
stagingDir = "staging"
tempDirName = "tempdirs"
)
const ( // Paths within a per-layer directory
lowerFile = "lower"
// lowerLayersFile references lower layers directly by layer ID
// instead of going through the l/ symlinks. The code appends
// "/diff" itself when consuming entries. It is preferred over
// lowerFile when present. The old lowerFile is still written
// for backward compatibility with older tools.
lowerLayersFile = "lower-layers"
maxDepth = 500
stagingLockFile = "staging.lock"
)
const ( // Keys within DriverWithDifferOutput.Artifacts
tocArtifact = "toc"
fsVerityDigestsArtifact = "fs-verity-digests"
)
const stagingLockFile = "staging.lock"
const (
maxDepth = 500
// idLength represents the number of random characters
// which can be used to create the unique link identifier
// for every layer. If this value is too long then the
@@ -991,46 +998,16 @@ func (d *Driver) CreateReadWrite(id, parent string, opts *graphdriver.CreateOpts
return fmt.Errorf("--storage-opt is supported only for overlay over xfs with 'pquota' mount option")
}
if opts == nil {
opts = &graphdriver.CreateOpts{
StorageOpt: map[string]string{},
}
}
if d.options.forceMask != nil && d.options.mountProgram == "" {
return fmt.Errorf("overlay: force_mask option for writeable layers is only supported with a mount_program")
}
if _, ok := opts.StorageOpt["size"]; !ok {
if opts.StorageOpt == nil {
opts.StorageOpt = map[string]string{}
}
opts.StorageOpt["size"] = strconv.FormatUint(d.options.quota.Size, 10)
}
if _, ok := opts.StorageOpt["inodes"]; !ok {
if opts.StorageOpt == nil {
opts.StorageOpt = map[string]string{}
}
opts.StorageOpt["inodes"] = strconv.FormatUint(d.options.quota.Inodes, 10)
}
return d.create(id, parent, opts, false)
}
// Create is used to create the upper, lower, and merge directories required for overlay fs for a given id.
// The parent filesystem is used to configure these directories for the overlay.
func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) (retErr error) {
if opts != nil && len(opts.StorageOpt) != 0 {
if _, ok := opts.StorageOpt["size"]; ok {
return fmt.Errorf("--storage-opt size is only supported for ReadWrite Layers")
}
if _, ok := opts.StorageOpt["inodes"]; ok {
return fmt.Errorf("--storage-opt inodes is only supported for ReadWrite Layers")
}
}
return d.create(id, parent, opts, true)
}
@@ -1078,6 +1055,11 @@ func (d *Driver) getLayerPermissions(parent string, uidMaps, gidMaps []idtools.I
}
func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts, readOnly bool) (retErr error) {
quota, err := d.parseStorageOpt(opts, readOnly) // Do this even for read-only layers, to allow rejecting quota options
if err != nil {
return err
}
dir, homedir, _ := d.dir2(id, readOnly)
disableQuota := readOnly
@@ -1127,19 +1109,6 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts, readOnl
}()
if d.quotaCtl != nil && !disableQuota {
quota := quota.Quota{}
if opts != nil && len(opts.StorageOpt) > 0 {
driver := &Driver{}
if err := d.parseStorageOpt(opts.StorageOpt, driver); err != nil {
return err
}
if driver.options.quota.Size > 0 {
quota.Size = driver.options.quota.Size
}
if driver.options.quota.Inodes > 0 {
quota.Inodes = driver.options.quota.Inodes
}
}
// Set container disk quota limit
// If it is set to 0, we will track the disk usage, but not enforce a limit
if err := d.quotaCtl.SetQuota(dir, quota); err != nil {
@@ -1183,42 +1152,22 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts, readOnl
return idtools.MkdirAndChown(path.Join(dir, "empty"), 0o700, forcedSt.IDs)
}
lower, err := d.getLower(parent)
lower, err := d.getLowerForParent(parent)
if err != nil {
return err
}
if lower != "" {
if err := os.WriteFile(path.Join(dir, lowerFile), []byte(lower), 0o666); err != nil {
return err
}
if err := os.WriteFile(path.Join(dir, lowerFile), []byte(lower), 0o666); err != nil {
return err
}
// Write a lower-layers file referencing layers by ID instead of
// l/ symlink references. The reading side appends "/diff" itself.
parentDir := d.dir(parent)
layerLower := parent
parentLower, err := os.ReadFile(path.Join(parentDir, lowerLayersFile))
if err == nil {
layerLower += ":" + string(parentLower)
} else if !errors.Is(err, unix.ENOENT) {
parentLowerLayerIDs, err := d.getLowerLayerIDs(parent)
if err != nil {
return err
} else {
// Parent has no lower-layers file. Convert old-format lower
// entries (l/ symlinks) to layer IDs.
oldLower, err := os.ReadFile(path.Join(parentDir, lowerFile))
if err == nil {
for _, s := range strings.Split(string(oldLower), ":") {
target, err := os.Readlink(d.dir(s))
if err != nil {
return fmt.Errorf("reading symlink for lower %q: %w", s, err)
}
layerLower += ":" + filepath.Base(filepath.Dir(target))
}
} else if !errors.Is(err, unix.ENOENT) {
return err
}
}
if err := os.WriteFile(path.Join(dir, lowerLayersFile), []byte(layerLower), 0o666); err != nil {
layerLowerLayerIDs := strings.Join(append([]string{parent}, parentLowerLayerIDs...), ":")
if err := os.WriteFile(path.Join(dir, lowerLayersFile), []byte(layerLowerLayerIDs), 0o666); err != nil {
return err
}
@@ -1226,51 +1175,47 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts, readOnl
}
// Parse overlay storage options
func (d *Driver) parseStorageOpt(storageOpt map[string]string, driver *Driver) error {
func (d *Driver) parseStorageOpt(opts *graphdriver.CreateOpts, readOnly bool) (quota.Quota, error) {
var storageOpt map[string]string = nil // Iterating over a nil map is safe
if opts != nil {
storageOpt = opts.StorageOpt
}
res := quota.Quota{}
if !readOnly {
res.Size = d.options.quota.Size
res.Inodes = d.options.quota.Inodes
}
// Read size to set the disk project quota per container
for key, val := range storageOpt {
key := strings.ToLower(key)
switch key {
case "size":
if readOnly {
return quota.Quota{}, fmt.Errorf("--storage-opt size is only supported for ReadWrite Layers")
}
size, err := units.RAMInBytes(val)
if err != nil {
return err
return quota.Quota{}, err
}
driver.options.quota.Size = uint64(size)
res.Size = uint64(size)
case "inodes":
if readOnly {
return quota.Quota{}, fmt.Errorf("--storage-opt inodes is only supported for ReadWrite Layers")
}
inodes, err := strconv.ParseUint(val, 10, 64)
if err != nil {
return err
return quota.Quota{}, err
}
driver.options.quota.Inodes = inodes
res.Inodes = inodes
default:
return fmt.Errorf("unknown option %s", key)
return quota.Quota{}, fmt.Errorf("unknown option %s", key)
}
}
return nil
}
func (d *Driver) getLower(parent string) (string, error) {
parentDir := d.dir(parent)
// Ensure parent exists
if err := fileutils.Lexists(parentDir); err != nil {
return "", err
}
parentLink, err := os.ReadFile(path.Join(parentDir, "link"))
if err != nil {
return "", err
}
lowers := []string{path.Join(linkDir, string(parentLink))}
parentLower, err := os.ReadFile(path.Join(parentDir, lowerFile))
if err == nil {
parentLowers := strings.SplitSeq(string(parentLower), ":")
lowers = slices.AppendSeq(lowers, parentLowers)
}
return strings.Join(lowers, ":"), nil
return res, nil
}
func (d *Driver) dir(id string) string {
@@ -1314,36 +1259,98 @@ func (d *Driver) dir2(id string, useImageStore bool) (string, string, bool) {
return newpath, homedir, false
}
func (d *Driver) getLowerDirs(id string) ([]string, error) {
var lowersArray []string
dir := d.dir(id)
lowers, err := os.ReadFile(path.Join(dir, lowerLayersFile))
// getLowerForParent returns the contents of lowerFile for a child layer of parent.
//
// This should only be used to construct a lowerFile for compatibility;
// new code should rely on lowerLayersFile instead.
func (d *Driver) getLowerForParent(parent string) (string, error) {
parentDir := d.dir(parent)
// Ensure parent exists
if err := fileutils.Lexists(parentDir); err != nil {
return "", err
}
parentLink, err := os.ReadFile(path.Join(parentDir, "link"))
if err != nil {
if !errors.Is(err, unix.ENOENT) {
return "", err
}
lowers := []string{path.Join(linkDir, string(parentLink))}
parentLower, err := os.ReadFile(path.Join(parentDir, lowerFile))
if err == nil {
parentLowers := strings.SplitSeq(string(parentLower), ":")
lowers = slices.AppendSeq(lowers, parentLowers)
}
return strings.Join(lowers, ":"), nil
}
// getLowerLayerIDs returns a list of lower layer IDs for a layer id;
// typically the contents of lowerLayersFile, falling back to lowerFile.
// If the layer has neither of the files, returns an empty list without reporting an error.
func (d *Driver) getLowerLayerIDs(id string) ([]string, error) {
dir := d.dir(id)
lowerLayers, err := os.ReadFile(path.Join(dir, lowerLayersFile))
switch {
case err == nil:
return strings.Split(string(lowerLayers), ":"), nil
case errors.Is(err, fs.ErrNotExist):
lowers, err := os.ReadFile(path.Join(dir, lowerFile))
if err != nil {
if errors.Is(err, fs.ErrNotExist) {
return nil, nil
}
return nil, err
}
lowers, err = os.ReadFile(path.Join(dir, lowerFile))
}
if err == nil {
for s := range strings.SplitSeq(string(lowers), ":") {
lower := d.dir(s)
lp, err := os.Readlink(lower)
var res []string
for relLowerLink := range strings.SplitSeq(string(lowers), ":") {
lowerLink := d.dir(relLowerLink) // This is an invalid use of dir() (the input is supposed to be a layer ID) but pre-existing
lp, err := os.Readlink(lowerLink)
if err != nil {
if errors.Is(err, syscall.EINVAL) {
// Not a symlink: layer ID, append /diff.
lowersArray = append(lowersArray, path.Join(lower, "diff"))
continue
}
return nil, err
}
lowersArray = append(lowersArray, path.Clean(d.dir(path.Join("link", lp))))
lowerID := filepath.Base(filepath.Dir(lp))
res = append(res, lowerID)
}
} else if !errors.Is(err, fs.ErrNotExist) {
return res, nil
default:
return nil, err
}
}
// getLowerDirs returns a list of lower directories for a layer id;
// the directories may be symbolic links (do not call redirectDiffIfAdditionalLayer).
func (d *Driver) getLowerDirs(id string) ([]string, error) {
lowerLayerIDs, err := d.getLowerLayerIDs(id)
if err != nil {
return nil, err
}
lowersArray := make([]string, 0, len(lowerLayerIDs))
for _, lowerID := range lowerLayerIDs {
lowerDir := d.dir(lowerID)
lowersArray = append(lowersArray, path.Join(lowerDir, "diff"))
}
return lowersArray, nil
}
// getLowerDiffPaths returns a list of lower diff paths for a layer id;
// the paths have redirectDiffIfAdditionalLayer applied.
func (d *Driver) getLowerDiffPaths(id string) ([]string, error) {
layers, err := d.getLowerDirs(id)
if err != nil {
return nil, err
}
for i, l := range layers {
layers[i], err = redirectDiffIfAdditionalLayer(l, false)
if err != nil {
return nil, err
}
}
return layers, nil
}
func (d *Driver) optsAppendMappings(opts string, uidMaps, gidMaps []idtools.IDMap) string {
if uidMaps != nil {
var uids, gids bytes.Buffer
@@ -1540,18 +1547,11 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO
readWrite = false
}
lowers, err := os.ReadFile(path.Join(dir, lowerLayersFile))
lowerLayerIDs, err := d.getLowerLayerIDs(id)
if err != nil {
if !errors.Is(err, unix.ENOENT) {
return "", err
}
lowers, err = os.ReadFile(path.Join(dir, lowerFile))
if err != nil && !os.IsNotExist(err) {
return "", err
}
return "", err
}
splitLowers := strings.Split(string(lowers), ":")
if len(splitLowers) > maxDepth {
if len(lowerLayerIDs) > maxDepth {
return "", errors.New("max depth exceeded")
}
@@ -1641,46 +1641,17 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO
// For each lower, resolve its path, and append it and any additional diffN
// directories to the lowers list.
for i, l := range splitLowers {
if l == "" {
continue
}
lower := ""
newpath := path.Join(d.home, l)
if st, err := os.Stat(newpath); err != nil {
for _, p := range d.getAllImageStores() {
lower = path.Join(p, d.name, l)
if st2, err2 := os.Stat(lower); err2 == nil {
if !permsKnown {
perms = st2.Mode()
permsKnown = true
}
break
}
lower = ""
}
if lower == "" {
return "", fmt.Errorf("can't stat lower layer %q: %w", newpath, err)
}
} else {
if !permsKnown {
perms = st.Mode()
permsKnown = true
}
lower = newpath
}
linkContent, err := os.Readlink(lower)
for i, lowerID := range lowerLayerIDs {
lower := filepath.Join(d.dir(lowerID), "diff")
st, err := os.Stat(lower)
if err != nil {
if !errors.Is(err, syscall.EINVAL) {
return "", err
}
// Not a symlink: layer ID from lower-layers, append /diff.
lower = path.Join(lower, "diff")
linkContent = lower
return "", fmt.Errorf("can't stat (or find?) lower layer %q: %w", lower, err)
}
lowerID := filepath.Base(filepath.Dir(linkContent))
if !permsKnown {
perms = st.Mode()
permsKnown = true
}
composefsMount, err := maybeAddComposefsMount(lowerID, i+1, readWrite)
if err != nil {
return "", err
@@ -2050,23 +2021,15 @@ func (d *Driver) ListLayers() ([]string, error) {
// isParent returns if the passed in parent is the direct parent of the passed in layer
func (d *Driver) isParent(id, parent string) bool {
lowers, err := d.getLowerDirs(id)
lowerLayerIDs, err := d.getLowerLayerIDs(id)
if err != nil {
return false
}
if parent == "" && len(lowers) > 0 {
return false
actualParent := ""
if len(lowerLayerIDs) > 0 {
actualParent = lowerLayerIDs[0]
}
parentDir := d.dir(parent)
var ld string
if len(lowers) > 0 {
ld = filepath.Dir(lowers[0])
}
if ld == "" && parent == "" {
return true
}
return ld == parentDir
return parent == actualParent
}
func (d *Driver) getWhiteoutFormat() archive.WhiteoutFormat {
@@ -2450,20 +2413,6 @@ func (d *Driver) getDiffPath(id string) (string, error) {
return redirectDiffIfAdditionalLayer(path.Join(dir, "diff"), false)
}
func (d *Driver) getLowerDiffPaths(id string) ([]string, error) {
layers, err := d.getLowerDirs(id)
if err != nil {
return nil, err
}
for i, l := range layers {
layers[i], err = redirectDiffIfAdditionalLayer(l, false)
if err != nil {
return nil, err
}
}
return layers, nil
}
// DiffSize calculates the changes between the specified id
// and its parent and returns the size in bytes of the changes
// relative to its base filesystem directory.

View File

@@ -7,26 +7,18 @@ import (
"sync"
)
var (
homeDirOnce sync.Once
homeDirErr error
homeDir string
)
var lookupHomeDir = sync.OnceValues(func() (string, error) {
usr, err := user.LookupId(fmt.Sprintf("%d", GetRootlessUID()))
if err != nil {
return "", fmt.Errorf("unable to resolve HOME directory: %w", err)
}
return usr.HomeDir, nil
})
// HomeDir returns the home directory for the current user.
func HomeDir() (string, error) {
homeDirOnce.Do(func() {
home := os.Getenv("HOME")
if home == "" {
usr, err := user.LookupId(fmt.Sprintf("%d", GetRootlessUID()))
if err != nil {
homeDir, homeDirErr = "", fmt.Errorf("unable to resolve HOME directory: %w", err)
return
}
homeDir, homeDirErr = usr.HomeDir, nil
return
}
homeDir, homeDirErr = home, nil
})
return homeDir, homeDirErr
if home := os.Getenv("HOME"); home != "" {
return home, nil
}
return lookupHomeDir()
}

9
vendor/modules.txt vendored
View File

@@ -411,6 +411,9 @@ github.com/moby/patternmatcher
# github.com/moby/sys/capability v0.4.0
## explicit; go 1.21
github.com/moby/sys/capability
# github.com/moby/sys/devices v0.1.0
## explicit; go 1.24
github.com/moby/sys/devices
# github.com/moby/sys/mountinfo v0.7.2
## explicit; go 1.17
github.com/moby/sys/mountinfo
@@ -733,7 +736,7 @@ go.podman.io/buildah/pkg/sshagent
go.podman.io/buildah/pkg/util
go.podman.io/buildah/pkg/volumes
go.podman.io/buildah/util
# go.podman.io/common v0.67.2-0.20260423135811-cbaa5f41e643
# go.podman.io/common v0.67.2-0.20260427104901-081c2519fc6a
## explicit; go 1.25.6
go.podman.io/common/internal
go.podman.io/common/libimage
@@ -799,7 +802,7 @@ go.podman.io/common/pkg/umask
go.podman.io/common/pkg/util
go.podman.io/common/pkg/version
go.podman.io/common/version
# go.podman.io/image/v5 v5.39.3-0.20260423135811-cbaa5f41e643
# go.podman.io/image/v5 v5.39.3-0.20260427104901-081c2519fc6a
## explicit; go 1.25.6
go.podman.io/image/v5/copy
go.podman.io/image/v5/directory
@@ -876,7 +879,7 @@ go.podman.io/image/v5/transports
go.podman.io/image/v5/transports/alltransports
go.podman.io/image/v5/types
go.podman.io/image/v5/version
# go.podman.io/storage v1.62.1-0.20260423135811-cbaa5f41e643
# go.podman.io/storage v1.62.1-0.20260427104901-081c2519fc6a
## explicit; go 1.25.0
go.podman.io/storage
go.podman.io/storage/drivers