context: Normalize home/path to ~/path, and ~ to home

Historically we didn't accept them, but there's no real reason why not.
They're normalized to the form in which earlier Flatpak releases would
want to see them.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(backported from commit 09424423b9)
This commit is contained in:
Simon McVittie
2020-08-11 00:00:17 +01:00
committed by Alexander Larsson
parent ceea3cefad
commit fc64778fb3
3 changed files with 39 additions and 0 deletions

View File

@@ -826,6 +826,22 @@ flatpak_context_parse_filesystem (const char *filesystem_and_mode,
return TRUE;
}
if (strcmp (filesystem, "~") == 0)
{
if (filesystem_out != NULL)
*filesystem_out = g_strdup ("home");
return TRUE;
}
if (g_str_has_prefix (filesystem, "home/"))
{
if (filesystem_out != NULL)
*filesystem_out = g_strconcat ("~/", filesystem + 5, NULL);
return TRUE;
}
g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED,
_("Unknown filesystem location %s, valid locations are: host, host-os, host-etc, home, xdg-*[/…], ~/dir, /dir"), filesystem);
return FALSE;

View File

@@ -210,6 +210,14 @@
Available since 0.3.
</para></listitem></varlistentry>
<varlistentry><term><option>home/<replaceable>path</replaceable></option></term><listitem><para>
Alias for <filename>~/path</filename>
Available since 1.8.7.
For better compatibility with older
Flatpak versions, prefer to write this
as <filename>~/path</filename>.
</para></listitem></varlistentry>
<varlistentry><term><option>host</option></term>
<listitem><para>
The entire host file system, except for
@@ -382,6 +390,15 @@
directory. Available since 0.3.
</para></listitem></varlistentry>
<varlistentry><term><option>~</option></term>
<listitem><para>
The same as <option>home</option>.
Available since 1.8.7.
For better compatibility with older
Flatpak versions, prefer to write this
as <option>home</option>.
</para></listitem></varlistentry>
<varlistentry><term>
One of the above followed by
<option>:ro</option>

View File

@@ -298,6 +298,12 @@ static const Filesystem filesystems[] =
{ "xdg-config/././///.///././.", FLATPAK_FILESYSTEM_MODE_READ_WRITE, "xdg-config" },
{ "xdg-config/////", FLATPAK_FILESYSTEM_MODE_READ_WRITE, "xdg-config" },
{ "xdg-run/dbus", FLATPAK_FILESYSTEM_MODE_READ_WRITE },
{ "~", FLATPAK_FILESYSTEM_MODE_READ_WRITE, "home" },
{ "~/.", FLATPAK_FILESYSTEM_MODE_READ_WRITE, "home" },
{ "~/", FLATPAK_FILESYSTEM_MODE_READ_WRITE, "home" },
{ "~///././//", FLATPAK_FILESYSTEM_MODE_READ_WRITE, "home" },
{ "home/", FLATPAK_FILESYSTEM_MODE_READ_WRITE, "home" },
{ "home/Projects", FLATPAK_FILESYSTEM_MODE_READ_WRITE, "~/Projects" },
};
static void