Documentation
¶
Overview ¶
Package sandbox reads a Flatpak sandbox's file grants and explains a file error that they cause (docs/design/app.md#the-flatpak). A vault outside the grants fails with a plain "no such file or directory" or "permission denied", which does not tell a person that a narrowed --filesystem is the cause. Grants reads the [Context] filesystems of /.flatpak-info and says how far a path is covered; Explain turns a file error on an uncovered path into one that names the fix, and only when it is sure: a grant it cannot decode or resolve, or a path that Flatpak always exposes, leaves the plain error.
Index ¶
Constants ¶
const AppID = "org.frostyard.Frostnotes"
AppID is the Frostnotes Flatpak's application ID, as internal/config.AppID.
const InfoPath = "/.flatpak-info"
InfoPath is the file that a Flatpak sandbox holds at its root.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Env ¶
type Env struct {
// Home is the home directory, what the grant "home" and "~" name.
Home string
// RuntimeDir is $XDG_RUNTIME_DIR, what "xdg-run" names.
RuntimeDir string
// ConfigHome is the sandbox's $XDG_CONFIG_HOME (in a Flatpak,
// ~/.var/app/<ID>/config), where Flatpak puts a copy of the host's
// user-dirs.dirs; it is read before Home's .config/user-dirs.dirs.
ConfigHome string
// HostDataHome, HostConfigHome, HostCacheHome and HostStateHome are the
// host's $XDG_*_HOME, which Flatpak passes on as HOST_XDG_*_HOME when
// the host sets them; "xdg-data" and its kin name them, and the XDG
// defaults under Home when they are empty.
HostDataHome, HostConfigHome, HostCacheHome, HostStateHome string
}
Env is what the grants depend on besides /.flatpak-info.
type Error ¶
type Error struct {
Path string
ReadOnly bool // the grants cover Path, but read only
App string
Cause error
}
Error says that the sandbox's file access keeps the app from a path.
type Grants ¶
type Grants struct {
// contains filtered or unexported fields
}
Grants are a sandbox's file grants. The zero value, and nil, grant nothing; Explain on nil leaves an error as it is, which is how code outside a Flatpak asks.
func Load ¶
Load reads the file grants of the sandbox described by the file at infoPath. An error that matches fs.ErrNotExist means this is no Flatpak.
func Parse ¶
Parse reads the [Context] filesystems of a /.flatpak-info from r. A value it cannot decode, or an entry it cannot understand or resolve, makes the grants uncertain (Certain).
func (*Grants) Access ¶
Access says how far the grants cover p, an absolute path: the entry with the deepest root that holds p decides, a later entry beating an earlier one of the same root, so "!~/Secret" under "home" leaves ~/Secret out and "~/Notes:rw" under "home:ro" opens it.
func (*Grants) Certain ¶
Certain says whether every grant was decoded and resolved. Explain says nothing when it is not: coverage cannot be disproved.
func (*Grants) Explain ¶
Explain returns err as it is, unless it is a file error that the grants explain for p: no such file, permission denied or not permitted on a path that the grants do not cover, or a read-only file system on one that they cover at most read-only. It then returns an *Error that says what to grant. It says nothing, and returns err, when it cannot be sure: a nil Grants (not in a Flatpak), grants that are not Certain, and a path that Flatpak always exposes (Exposed). A path that the grants cover keeps its plain error too.