pkg/system: MkdirAllWithACL: remove stubs and unused os.FileMode arg

Remove the stub implementation for non-Windows platforms, and remove the
os.FileMode argument, which is ignored on Windows.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-07-29 00:18:20 +02:00
parent 6f9e099fd3
commit 03f44e6d14
4 changed files with 4 additions and 14 deletions

View File

@@ -37,7 +37,7 @@ func (daemon *Daemon) setupConfigDir(ctr *container.Container) (setupErr error)
log.G(context.TODO()).Debugf("configs: setting up config dir: %s", localPath)
// create local config root
if err := system.MkdirAllWithACL(localPath, 0, system.SddlAdministratorsLocalSystem); err != nil {
if err := system.MkdirAllWithACL(localPath, system.SddlAdministratorsLocalSystem); err != nil {
return errors.Wrap(err, "error creating config dir")
}
@@ -112,7 +112,7 @@ func (daemon *Daemon) setupSecretDir(ctr *container.Container) (setupErr error)
log.G(context.TODO()).Debugf("secrets: setting up secret dir: %s", localMountPath)
// create local secret root
if err := system.MkdirAllWithACL(localMountPath, 0, system.SddlAdministratorsLocalSystem); err != nil {
if err := system.MkdirAllWithACL(localMountPath, system.SddlAdministratorsLocalSystem); err != nil {
return errors.Wrap(err, "error creating secret local directory")
}

View File

@@ -486,7 +486,7 @@ func setupRemappedRoot(config *config.Config) (user.IdentityMapping, error) {
func setupDaemonRoot(config *config.Config, rootDir string, uid, gid int) error {
config.Root = rootDir
// Create the root directory if it doesn't exists
if err := system.MkdirAllWithACL(config.Root, 0, system.SddlAdministratorsLocalSystem); err != nil {
if err := system.MkdirAllWithACL(config.Root, system.SddlAdministratorsLocalSystem); err != nil {
return err
}
return nil

View File

@@ -1,10 +0,0 @@
//go:build !windows
package system
import "os"
// MkdirAllWithACL is a wrapper for os.MkdirAll on unix systems.
func MkdirAllWithACL(path string, perm os.FileMode, _ string) error {
return os.MkdirAll(path, perm)
}

View File

@@ -15,7 +15,7 @@ const SddlAdministratorsLocalSystem = "D:P(A;OICI;GA;;;BA)(A;OICI;GA;;;SY)"
// MkdirAllWithACL is a custom version of os.MkdirAll modified for use on Windows
// so that it is both volume path aware, and can create a directory with
// an appropriate SDDL defined ACL.
func MkdirAllWithACL(path string, _ os.FileMode, sddl string) error {
func MkdirAllWithACL(path string, sddl string) error {
sa, err := makeSecurityAttributes(sddl)
if err != nil {
return &os.PathError{Op: "mkdirall", Path: path, Err: err}