Files
snapd/dirs/export_test.go
Zygmunt Krynicki f9cbb18bb6 dirs: fix SnapMountDir inside a Fedora base snap
This patch fixes the algorithm that dertermines the mount point for snaps.  The
old code used to work because it was looking at /etc/os-release and looking for
specific ID or ID_LIKE values. With the introduction of base snaps that can
have arbitrary os-release files we cannot rely on this information alone.

When a process is inside a snap mount namespace that has a base snap mounted as
the root filesystem then the os-release level information is not useful and
must not be used anymore. Inside that environment the snaps are always mounted
at /snap.

On the outside of a mount namespace the current algorithm is correct, it will
identify the distribution and apply any differences mandated by the
distribution policy.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2018-08-09 14:38:12 +02:00

33 lines
872 B
Go

// -*- Mode: Go; indent-tabs-mode: t -*-
/*
* Copyright (C) 2018 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package dirs
var (
IsInsideBaseSnap = isInsideBaseSnap
)
func MockMetaSnapPath(path string) (restore func()) {
old := metaSnapPath
metaSnapPath = path
return func() {
metaSnapPath = old
}
}