Skip to content

Commit

Permalink
Removed prefix in overlayfs mounts
Browse files Browse the repository at this point in the history
  • Loading branch information
lebauce committed Oct 10, 2024
1 parent 8802a20 commit 295712e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pkg/util/containerd/containerd_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,22 @@ func (c *ContainerdUtil) getMounts(ctx context.Context, expiration time.Duration
for i := range mounts {
mounts[i].Source = strings.ReplaceAll(mounts[i].Source, "/var/lib", "/host/var/lib")
for j := range mounts[i].Options {

Check failure on line 460 in pkg/util/containerd/containerd_util.go

View workflow job for this annotation

GitHub Actions / CodeQL-Build (javascript)

j declared and not used

Check failure on line 460 in pkg/util/containerd/containerd_util.go

View workflow job for this annotation

GitHub Actions / CodeQL-Build (python)

j declared and not used

Check failure on line 460 in pkg/util/containerd/containerd_util.go

View workflow job for this annotation

GitHub Actions / CodeQL-Build (cpp)

j declared and not used
mounts[i].Options[j] = strings.ReplaceAll(mounts[i].Options[j], "/var/lib", "/host/var/lib")
for j, opt := range mounts[i].Options {
for _, prefix := range []string{"upperdir=", "lowerdir=", "workdir="} {
if strings.HasPrefix(opt, prefix) {
trimmedOpt := strings.TrimPrefix(opt, prefix)
dirs := strings.Split(trimmedOpt, ":")
for n, dir := range dirs {
if index := strings.Index(dir, "/var/lib"); index != -1 {
dirs[n] = "/host" + dir[index:]
}
}
mounts[i].Options[j] = prefix + strings.Join(dirs, ":")
}
}
}

log.Debugf("Sanitized overlayfs mount options to %s", strings.Join(mounts[i].Options, ","))
}
}
}
Expand Down

0 comments on commit 295712e

Please sign in to comment.