Skip to content

Commit

Permalink
cmd/snap: rework CoreLibExecDir dir handling a bit more
Browse files Browse the repository at this point in the history
  • Loading branch information
morphis committed May 17, 2017
1 parent b92eae2 commit 8f9dd95
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions cmd/snap/cmd_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,15 @@ func migrateXauthority(info *snap.Info) (string, error) {

func runSnapConfine(info *snap.Info, securityTag, snapApp, command, hook string, args []string) error {
snapConfine := filepath.Join(dirs.DistroLibExecDir, "snap-confine")
// if we re-exec, we must run the snap-confine from the core snap
// as well, if they get out of sync, havoc will happen
if isReexeced() {
// run snap-confine from the core snap. that will work because
// snap-confine on the core snap is mostly statically linked
// (except libudev and libc)
snapConfine = filepath.Join(dirs.SnapMountDir, "core/current", dirs.CoreLibExecDir, "snap-confine")
}

if !osutil.FileExists(snapConfine) {
if hook != "" {
logger.Noticef("WARNING: skipping running hook %q of snap %q: missing snap-confine", hook, info.Name())
Expand Down Expand Up @@ -401,15 +410,6 @@ func runSnapConfine(info *snap.Info, securityTag, snapApp, command, hook string,
cmd = append(cmd, snapApp)
cmd = append(cmd, args...)

// if we re-exec, we must run the snap-confine from the core snap
// as well, if they get out of sync, havoc will happen
if isReexeced() {
// run snap-confine from the core snap. that will work because
// snap-confine on the core snap is mostly statically linked
// (except libudev and libc)
cmd[0] = filepath.Join(dirs.SnapMountDir, "core/current", dirs.CoreLibExecDir, "snap-confine")
}

extraEnv := make(map[string]string)
if len(xauthPath) > 0 {
extraEnv["XAUTHORITY"] = xauthPath
Expand Down
4 changes: 2 additions & 2 deletions cmd/snap/cmd_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ func (s *SnapSuite) TestSnapRunAppIntegrationFromCore(c *check.C) {
// mock installed snap
dirs.SetRootDir(c.MkDir())
defer func() { dirs.SetRootDir("/") }()
defer mockSnapConfine(dirs.CoreLibExecDir)()
defer mockSnapConfine(filepath.Join(dirs.SnapMountDir, "core", "current", dirs.CoreLibExecDir))()

si := snaptest.MockSnap(c, string(mockYaml), string(mockContents), &snap.SideInfo{
Revision: snap.R("x2"),
Expand All @@ -473,7 +473,7 @@ func (s *SnapSuite) TestSnapRunAppIntegrationFromCore(c *check.C) {

// pretend to be running from core
restorer := snaprun.MockOsReadlink(func(string) (string, error) {
return filepath.Join(dirs.SnapMountDir, "/core/111//usr/bin/snap"), nil
return filepath.Join(dirs.SnapMountDir, "core/111/usr/bin/snap"), nil
})
defer restorer()

Expand Down
2 changes: 1 addition & 1 deletion dirs/dirs.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func SetRootDir(rootdir string) {
DistroLibExecDir = filepath.Join(rootdir, "/usr/lib/snapd")
}

CoreLibExecDir = filepath.Join(rootdir, "/usr/lib/snapd")
CoreLibExecDir = "/usr/lib/snapd"

XdgRuntimeDirBase = filepath.Join(rootdir, "/run/user")
XdgRuntimeDirGlob = filepath.Join(rootdir, XdgRuntimeDirBase, "*/")
Expand Down

0 comments on commit 8f9dd95

Please sign in to comment.