Académique Documents
Professionnel Documents
Culture Documents
GitHub is home to over 50 million developers working together to host and review code,
manage projects, and build software together.
Sign up
master
44 branches 237 tags
Go to file Code
Latest commit
mvo5 Merge pull request #9290 from mvo5/release-2.46.1
…
eaa9fb916 hours ago
Git stats
45,007 commits
Files
snapdtool: helper to check whether the current binary is reexeced
fro…
…m a snap
Add a helper for checking whether the current binary is running from a snap.
master
(#8898)
2.46.1
2.46
Unified Split
Showing 3 changed files with 54 additions and 1 deletion.
12 snapdtool/tool_linux.go
// IsReexecd returns true when the current process binary is running from a snap.
func IsReexecd() (bool, error) {
exe, err := osReadlink(selfExe)
if err != nil {
return false, err
}
if strings.HasPrefix(exe, dirs.SnapMountDir) {
return true, nil
}
return false, nil
}
11 snapdtool/tool_other.go
"errors"
)
//
// On this OS this is a stub and always returns an error.
func InternalToolPath(tool string) (string, error) {
return "", errors.New("unsupported on non-Linux systems")
return "", errUnsupported
}
// IsReexecd returns true when the current process binary is running from a snap.
//
// On this OS this is a stub and always returns an error.
func IsReexecd() (bool, error) {
return false, errUnsupported
}
32 snapdtool/tool_test.go
snapdtool.ExecInSnapdOrCoreSnap()
c.Check(s.execCalled, Equals, 0)
}
err = os.Remove(mockedSelfExe)
c.Assert(err, IsNil)
// now it's not
err = os.Symlink(filepath.Join(dirs.DistroLibExecDir, "snapd"), mockedSelfExe)
c.Assert(err, IsNil)