Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(check): add a check for symlinks in roots-dir path #521

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion cmd/stacker/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"io/fs"
"os"
"os/exec"
"path/filepath"

"github.com/pkg/errors"
"github.com/pkg/xattr"
Expand All @@ -26,12 +27,23 @@ func doCheck(ctx *cli.Context) error {
return errors.Wrapf(err, "couldn't get kernel info")
}

log.Infof(kernel)
log.Infof("os/kernel: %s", kernel)

if err := os.MkdirAll(config.RootFSDir, 0700); err != nil {
return errors.Wrapf(err, "couldn't create rootfs dir for testing")
}

// internally there are many checks to avoid symlinks
evalp, err := filepath.EvalSymlinks(config.RootFSDir)
if err != nil {
return errors.Wrapf(err, "%s: unable to evaluate path for symlinks", config.RootFSDir)
}

if evalp != config.RootFSDir {
return errors.Errorf("%s: roots dir (--roots-dir) path uses symbolic links, use %q instead", config.RootFSDir, evalp)
}

// not all underlying filesystems are compatible
fstype, err := stacker.MountInfo(config.RootFSDir)
if err != nil {
return errors.Wrapf(err, "%s: couldn't get fs type", config.RootFSDir)
Expand Down
Loading