Skip to content

Commit 2e91544

Browse files
authored
Merge pull request #1806 from cyphar/cgroup-ignorable-error-fixup
cgroup: clean up isIgnorableError for skippable EROFS
2 parents ecd55a4 + 939d5a3 commit 2e91544

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

libcontainer/cgroups/fs/apply_raw.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,17 @@ type cgroupData struct {
106106
// sense of the word). This includes EROFS (which for an unprivileged user is
107107
// basically a permission error) and EACCES (for similar reasons) as well as
108108
// the normal EPERM.
109-
func isIgnorableError(err error) bool {
109+
func isIgnorableError(rootless bool, err error) bool {
110+
// We do not ignore errors if we are root.
111+
if !rootless {
112+
return false
113+
}
114+
// Is it an ordinary EPERM?
110115
if os.IsPermission(errors.Cause(err)) {
111116
return true
112117
}
113118

119+
// Try to handle other errnos.
114120
var errno error
115121
switch err := errors.Cause(err).(type) {
116122
case *os.PathError:
@@ -172,7 +178,7 @@ func (m *Manager) Apply(pid int) (err error) {
172178
// been set, we don't bail on error in case of permission problems.
173179
// Cases where limits have been set (and we couldn't create our own
174180
// cgroup) are handled by Set.
175-
if m.Rootless && isIgnorableError(err) && m.Cgroups.Path == "" {
181+
if isIgnorableError(m.Rootless, err) && m.Cgroups.Path == "" {
176182
delete(m.Paths, sys.Name())
177183
continue
178184
}

0 commit comments

Comments
 (0)