From aeae1c1620dcd52c362d43394ac3c4cb08705fc3 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Tue, 31 Jan 2017 16:50:24 +0000 Subject: [PATCH 1/3] stage1/fly: use a logging mounter --- stage1_fly/run/main.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/stage1_fly/run/main.go b/stage1_fly/run/main.go index de6fd82818..873d34479a 100644 --- a/stage1_fly/run/main.go +++ b/stage1_fly/run/main.go @@ -32,6 +32,7 @@ import ( "github.com/coreos/rkt/common" "github.com/coreos/rkt/pkg/fileutil" pkgflag "github.com/coreos/rkt/pkg/flag" + "github.com/coreos/rkt/pkg/fs" rktlog "github.com/coreos/rkt/pkg/log" "github.com/coreos/rkt/pkg/mountinfo" "github.com/coreos/rkt/pkg/sys" @@ -358,9 +359,12 @@ func stage1(rp *stage1commontypes.RuntimePod) int { } } + mounter := fs.NewLoggingMounter( + fs.MounterFunc(syscall.Mount), + fs.UnmounterFunc(syscall.Unmount), + diag.Printf, + ) for _, mount := range effectiveMounts { - diag.Printf("Processing %+v", mount) - var ( err error hostPathInfo os.FileInfo @@ -418,7 +422,7 @@ func stage1(rp *stage1commontypes.RuntimePod) int { } } - if err := syscall.Mount(mount.HostPath, absTargetPath, mount.Fs, mount.Flags, ""); err != nil { + if err := mounter.Mount(mount.HostPath, absTargetPath, mount.Fs, mount.Flags, ""); err != nil { log.PrintE(fmt.Sprintf("can't mount %q on %q with flags %v", mount.HostPath, absTargetPath, mount.Flags), err) return 254 } From 7e69e70464693a0514199d0dfa536e9445d042b8 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Tue, 31 Jan 2017 16:52:17 +0000 Subject: [PATCH 2/3] stage1/fly: evaluate symlinks in mount targets --- stage1_fly/run/main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/stage1_fly/run/main.go b/stage1_fly/run/main.go index 873d34479a..23036ddcbd 100644 --- a/stage1_fly/run/main.go +++ b/stage1_fly/run/main.go @@ -39,6 +39,7 @@ import ( "github.com/coreos/rkt/pkg/user" stage1common "github.com/coreos/rkt/stage1/common" stage1commontypes "github.com/coreos/rkt/stage1/common/types" + stage1initcommon "github.com/coreos/rkt/stage1/init/common" ) const ( @@ -380,7 +381,16 @@ func stage1(rp *stage1commontypes.RuntimePod) int { hostPathInfo = nil } - absTargetPath := filepath.Join(mount.TargetPrefixPath, mount.RelTargetPath) + absTargetPath := mount.RelTargetPath + if mount.TargetPrefixPath != "" { + absStage2RootFS := common.AppRootfsPath(p.Root, ra.Name) + targetPath, err := stage1initcommon.EvaluateSymlinksInsideApp(absStage2RootFS, mount.RelTargetPath) + if err != nil { + log.PrintE(fmt.Sprintf("evaluate target path %q in %q", mount.RelTargetPath, absStage2RootFS), err) + return 254 + } + absTargetPath = filepath.Join(absStage2RootFS, targetPath) + } if targetPathInfo, err = os.Stat(absTargetPath); err != nil && !os.IsNotExist(err) { log.PrintE(fmt.Sprintf("stat of target path %s", absTargetPath), err) return 254 From 789a90c8e60030dd3869a4ec3b42c19e27d22c3e Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Tue, 31 Jan 2017 16:52:48 +0000 Subject: [PATCH 3/3] tests: unconditionally run mount tests --- tests/rkt_mount_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/rkt_mount_test.go b/tests/rkt_mount_test.go index 293f74a495..7c09ebc7f5 100644 --- a/tests/rkt_mount_test.go +++ b/tests/rkt_mount_test.go @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build host coreos src - package main import ( @@ -125,7 +123,7 @@ func TestMountSymlink(t *testing.T) { // Read the actual file. rktCmd := fmt.Sprintf( - "%s --insecure-options=image run %s --set-env=FILE=%s %s", + "%s --insecure-options=image --debug run %s --set-env=FILE=%s %s", ctx.Cmd(), paramMount, tt.actualFile, image, ) t.Logf("%s\n", rktCmd)