flatpak-context.c (flatpak-1.15.1.tar.xz) | : | flatpak-context.c (flatpak-1.15.2.tar.xz) | ||
---|---|---|---|---|
skipping to change at line 1615 | skipping to change at line 1615 | |||
FLATPAK_METADATA_KEY_SH ARED, NULL, error); | FLATPAK_METADATA_KEY_SH ARED, NULL, error); | |||
if (shares == NULL) | if (shares == NULL) | |||
return FALSE; | return FALSE; | |||
for (i = 0; shares[i] != NULL; i++) | for (i = 0; shares[i] != NULL; i++) | |||
{ | { | |||
FlatpakContextShares share; | FlatpakContextShares share; | |||
share = flatpak_context_share_from_string (parse_negated (shares[i], & remove), NULL); | share = flatpak_context_share_from_string (parse_negated (shares[i], & remove), NULL); | |||
if (share == 0) | if (share == 0) | |||
g_debug ("Unknown share type %s", shares[i]); | g_info ("Unknown share type %s", shares[i]); | |||
else | else | |||
{ | { | |||
if (remove) | if (remove) | |||
flatpak_context_remove_shares (context, share); | flatpak_context_remove_shares (context, share); | |||
else | else | |||
flatpak_context_add_shares (context, share); | flatpak_context_add_shares (context, share); | |||
} | } | |||
} | } | |||
} | } | |||
skipping to change at line 1637 | skipping to change at line 1637 | |||
{ | { | |||
g_auto(GStrv) sockets = g_key_file_get_string_list (metakey, FLATPAK_METAD ATA_GROUP_CONTEXT, | g_auto(GStrv) sockets = g_key_file_get_string_list (metakey, FLATPAK_METAD ATA_GROUP_CONTEXT, | |||
FLATPAK_METADATA_KEY_S OCKETS, NULL, error); | FLATPAK_METADATA_KEY_S OCKETS, NULL, error); | |||
if (sockets == NULL) | if (sockets == NULL) | |||
return FALSE; | return FALSE; | |||
for (i = 0; sockets[i] != NULL; i++) | for (i = 0; sockets[i] != NULL; i++) | |||
{ | { | |||
FlatpakContextSockets socket = flatpak_context_socket_from_string (par se_negated (sockets[i], &remove), NULL); | FlatpakContextSockets socket = flatpak_context_socket_from_string (par se_negated (sockets[i], &remove), NULL); | |||
if (socket == 0) | if (socket == 0) | |||
g_debug ("Unknown socket type %s", sockets[i]); | g_info ("Unknown socket type %s", sockets[i]); | |||
else | else | |||
{ | { | |||
if (remove) | if (remove) | |||
flatpak_context_remove_sockets (context, socket); | flatpak_context_remove_sockets (context, socket); | |||
else | else | |||
flatpak_context_add_sockets (context, socket); | flatpak_context_add_sockets (context, socket); | |||
} | } | |||
} | } | |||
} | } | |||
skipping to change at line 1659 | skipping to change at line 1659 | |||
{ | { | |||
g_auto(GStrv) devices = g_key_file_get_string_list (metakey, FLATPAK_METAD ATA_GROUP_CONTEXT, | g_auto(GStrv) devices = g_key_file_get_string_list (metakey, FLATPAK_METAD ATA_GROUP_CONTEXT, | |||
FLATPAK_METADATA_KEY_D EVICES, NULL, error); | FLATPAK_METADATA_KEY_D EVICES, NULL, error); | |||
if (devices == NULL) | if (devices == NULL) | |||
return FALSE; | return FALSE; | |||
for (i = 0; devices[i] != NULL; i++) | for (i = 0; devices[i] != NULL; i++) | |||
{ | { | |||
FlatpakContextDevices device = flatpak_context_device_from_string (par se_negated (devices[i], &remove), NULL); | FlatpakContextDevices device = flatpak_context_device_from_string (par se_negated (devices[i], &remove), NULL); | |||
if (device == 0) | if (device == 0) | |||
g_debug ("Unknown device type %s", devices[i]); | g_info ("Unknown device type %s", devices[i]); | |||
else | else | |||
{ | { | |||
if (remove) | if (remove) | |||
flatpak_context_remove_devices (context, device); | flatpak_context_remove_devices (context, device); | |||
else | else | |||
flatpak_context_add_devices (context, device); | flatpak_context_add_devices (context, device); | |||
} | } | |||
} | } | |||
} | } | |||
skipping to change at line 1681 | skipping to change at line 1681 | |||
{ | { | |||
g_auto(GStrv) features = g_key_file_get_string_list (metakey, FLATPAK_META DATA_GROUP_CONTEXT, | g_auto(GStrv) features = g_key_file_get_string_list (metakey, FLATPAK_META DATA_GROUP_CONTEXT, | |||
FLATPAK_METADATA_KEY_ FEATURES, NULL, error); | FLATPAK_METADATA_KEY_ FEATURES, NULL, error); | |||
if (features == NULL) | if (features == NULL) | |||
return FALSE; | return FALSE; | |||
for (i = 0; features[i] != NULL; i++) | for (i = 0; features[i] != NULL; i++) | |||
{ | { | |||
FlatpakContextFeatures feature = flatpak_context_feature_from_string ( parse_negated (features[i], &remove), NULL); | FlatpakContextFeatures feature = flatpak_context_feature_from_string ( parse_negated (features[i], &remove), NULL); | |||
if (feature == 0) | if (feature == 0) | |||
g_debug ("Unknown feature type %s", features[i]); | g_info ("Unknown feature type %s", features[i]); | |||
else | else | |||
{ | { | |||
if (remove) | if (remove) | |||
flatpak_context_remove_features (context, feature); | flatpak_context_remove_features (context, feature); | |||
else | else | |||
flatpak_context_add_features (context, feature); | flatpak_context_add_features (context, feature); | |||
} | } | |||
} | } | |||
} | } | |||
skipping to change at line 1707 | skipping to change at line 1707 | |||
return FALSE; | return FALSE; | |||
for (i = 0; filesystems[i] != NULL; i++) | for (i = 0; filesystems[i] != NULL; i++) | |||
{ | { | |||
const char *fs = parse_negated (filesystems[i], &remove); | const char *fs = parse_negated (filesystems[i], &remove); | |||
g_autofree char *filesystem = NULL; | g_autofree char *filesystem = NULL; | |||
FlatpakFilesystemMode mode; | FlatpakFilesystemMode mode; | |||
if (!flatpak_context_parse_filesystem (fs, remove, | if (!flatpak_context_parse_filesystem (fs, remove, | |||
&filesystem, &mode, NULL)) | &filesystem, &mode, NULL)) | |||
g_debug ("Unknown filesystem type %s", filesystems[i]); | g_info ("Unknown filesystem type %s", filesystems[i]); | |||
else | else | |||
{ | { | |||
g_assert (mode == FLATPAK_FILESYSTEM_MODE_NONE || !remove); | g_assert (mode == FLATPAK_FILESYSTEM_MODE_NONE || !remove); | |||
flatpak_context_take_filesystem (context, g_steal_pointer (&filesy stem), mode); | flatpak_context_take_filesystem (context, g_steal_pointer (&filesy stem), mode); | |||
} | } | |||
} | } | |||
} | } | |||
if (g_key_file_has_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METAD ATA_KEY_PERSISTENT, NULL)) | if (g_key_file_has_key (metakey, FLATPAK_METADATA_GROUP_CONTEXT, FLATPAK_METAD ATA_KEY_PERSISTENT, NULL)) | |||
{ | { | |||
skipping to change at line 2434 | skipping to change at line 2434 | |||
context->features &= context->features_valid; | context->features &= context->features_valid; | |||
g_hash_table_remove_all (context->persistent); | g_hash_table_remove_all (context->persistent); | |||
g_hash_table_remove_all (context->filesystems); | g_hash_table_remove_all (context->filesystems); | |||
g_hash_table_remove_all (context->session_bus_policy); | g_hash_table_remove_all (context->session_bus_policy); | |||
g_hash_table_remove_all (context->system_bus_policy); | g_hash_table_remove_all (context->system_bus_policy); | |||
g_hash_table_remove_all (context->generic_policy); | g_hash_table_remove_all (context->generic_policy); | |||
} | } | |||
const char *dont_mount_in_root[] = { | const char *dont_mount_in_root[] = { | |||
".", "..", "lib", "lib32", "lib64", "bin", "sbin", "usr", "boot", "efi", | ".", | |||
"root", "tmp", "etc", "app", "run", "proc", "sys", "dev", "var", NULL | "..", | |||
"app", | ||||
"bin", | ||||
"boot", | ||||
"dev", | ||||
"efi", | ||||
"etc", | ||||
"lib", | ||||
"lib32", | ||||
"lib64", | ||||
"proc", | ||||
"root", | ||||
"run", | ||||
"sbin", | ||||
"sys", | ||||
"tmp", | ||||
"usr", | ||||
"var", | ||||
NULL | ||||
}; | }; | |||
static void | static void | |||
log_cannot_export_error (FlatpakFilesystemMode mode, | ||||
const char *path, | ||||
const GError *error) | ||||
{ | ||||
GLogLevelFlags level = G_LOG_LEVEL_MESSAGE; | ||||
/* By default we don't show a log message if the reason we are not sharing | ||||
* something with the sandbox is simply "it doesn't exist" (or something | ||||
* very close): otherwise it would be very noisy to launch apps that | ||||
* opportunistically share things they might benefit from, like Steam | ||||
* having access to $XDG_RUNTIME_DIR/app/com.discordapp.Discord if it | ||||
* happens to exist. */ | ||||
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) | ||||
level = G_LOG_LEVEL_INFO; | ||||
/* Some callers specifically suppress warnings for particular errors | ||||
* by setting this code. */ | ||||
else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_FAILED_HANDLED)) | ||||
level = G_LOG_LEVEL_INFO; | ||||
switch (mode) | ||||
{ | ||||
case FLATPAK_FILESYSTEM_MODE_NONE: | ||||
g_log (G_LOG_DOMAIN, level, _("Not replacing \"%s\" with tmpfs: %s"), | ||||
path, error->message); | ||||
break; | ||||
case FLATPAK_FILESYSTEM_MODE_CREATE: | ||||
case FLATPAK_FILESYSTEM_MODE_READ_ONLY: | ||||
case FLATPAK_FILESYSTEM_MODE_READ_WRITE: | ||||
g_log (G_LOG_DOMAIN, level, | ||||
_("Not sharing \"%s\" with sandbox: %s"), | ||||
path, error->message); | ||||
break; | ||||
} | ||||
} | ||||
static void | ||||
flatpak_context_export (FlatpakContext *context, | flatpak_context_export (FlatpakContext *context, | |||
FlatpakExports *exports, | FlatpakExports *exports, | |||
GFile *app_id_dir, | GFile *app_id_dir, | |||
GPtrArray *extra_app_id_dirs, | GPtrArray *extra_app_id_dirs, | |||
gboolean do_create, | gboolean do_create, | |||
gchar **xdg_dirs_conf_out, | gchar **xdg_dirs_conf_out, | |||
gboolean *home_access_out) | gboolean *home_access_out) | |||
{ | { | |||
gboolean home_access = FALSE; | gboolean home_access = FALSE; | |||
g_autoptr(GString) xdg_dirs_conf = NULL; | g_autoptr(GString) xdg_dirs_conf = NULL; | |||
FlatpakFilesystemMode fs_mode, os_mode, etc_mode, home_mode; | FlatpakFilesystemMode fs_mode, os_mode, etc_mode, home_mode; | |||
GHashTableIter iter; | GHashTableIter iter; | |||
gpointer key, value; | gpointer key, value; | |||
g_autoptr(GError) local_error = NULL; | ||||
if (xdg_dirs_conf_out != NULL) | if (xdg_dirs_conf_out != NULL) | |||
xdg_dirs_conf = g_string_new (""); | xdg_dirs_conf = g_string_new (""); | |||
fs_mode = GPOINTER_TO_INT (g_hash_table_lookup (context->filesystems, "host")) ; | fs_mode = GPOINTER_TO_INT (g_hash_table_lookup (context->filesystems, "host")) ; | |||
if (fs_mode != FLATPAK_FILESYSTEM_MODE_NONE) | if (fs_mode != FLATPAK_FILESYSTEM_MODE_NONE) | |||
{ | { | |||
DIR *dir; | DIR *dir; | |||
struct dirent *dirent; | struct dirent *dirent; | |||
g_debug ("Allowing host-fs access"); | g_info ("Allowing host-fs access"); | |||
home_access = TRUE; | home_access = TRUE; | |||
/* Bind mount most dirs in / into the new root */ | /* Bind mount most dirs in / into the new root */ | |||
dir = opendir ("/"); | dir = opendir ("/"); | |||
if (dir != NULL) | if (dir != NULL) | |||
{ | { | |||
while ((dirent = readdir (dir))) | while ((dirent = readdir (dir))) | |||
{ | { | |||
g_autofree char *path = NULL; | g_autofree char *path = NULL; | |||
if (g_strv_contains (dont_mount_in_root, dirent->d_name)) | if (g_strv_contains (dont_mount_in_root, dirent->d_name)) | |||
continue; | continue; | |||
path = g_build_filename ("/", dirent->d_name, NULL); | path = g_build_filename ("/", dirent->d_name, NULL); | |||
flatpak_exports_add_path_expose (exports, fs_mode, path); | ||||
if (!flatpak_exports_add_path_expose (exports, fs_mode, path, &loc | ||||
al_error)) | ||||
{ | ||||
/* Failure to share something like /lib32 because it's | ||||
* actually a symlink to /usr/lib32 is less of a problem | ||||
* here than it would be for an explicit | ||||
* --filesystem=/lib32, so the warning that would normally | ||||
* be produced in that situation is downgraded to a | ||||
* debug message. */ | ||||
if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_M | ||||
OUNTABLE_FILE)) | ||||
local_error->code = G_IO_ERROR_FAILED_HANDLED; | ||||
log_cannot_export_error (fs_mode, path, local_error); | ||||
g_clear_error (&local_error); | ||||
} | ||||
} | } | |||
closedir (dir); | closedir (dir); | |||
} | } | |||
flatpak_exports_add_path_expose (exports, fs_mode, "/run/media"); | ||||
if (!flatpak_exports_add_path_expose (exports, fs_mode, "/run/media", &loc | ||||
al_error)) | ||||
{ | ||||
log_cannot_export_error (fs_mode, "/run/media", local_error); | ||||
g_clear_error (&local_error); | ||||
} | ||||
} | } | |||
os_mode = MAX (GPOINTER_TO_INT (g_hash_table_lookup (context->filesystems, "ho st-os")), | os_mode = MAX (GPOINTER_TO_INT (g_hash_table_lookup (context->filesystems, "ho st-os")), | |||
fs_mode); | fs_mode); | |||
if (os_mode != FLATPAK_FILESYSTEM_MODE_NONE) | if (os_mode != FLATPAK_FILESYSTEM_MODE_NONE) | |||
flatpak_exports_add_host_os_expose (exports, os_mode); | flatpak_exports_add_host_os_expose (exports, os_mode); | |||
etc_mode = MAX (GPOINTER_TO_INT (g_hash_table_lookup (context->filesystems, "h ost-etc")), | etc_mode = MAX (GPOINTER_TO_INT (g_hash_table_lookup (context->filesystems, "h ost-etc")), | |||
fs_mode); | fs_mode); | |||
if (etc_mode != FLATPAK_FILESYSTEM_MODE_NONE) | if (etc_mode != FLATPAK_FILESYSTEM_MODE_NONE) | |||
flatpak_exports_add_host_etc_expose (exports, etc_mode); | flatpak_exports_add_host_etc_expose (exports, etc_mode); | |||
home_mode = GPOINTER_TO_INT (g_hash_table_lookup (context->filesystems, "home" )); | home_mode = GPOINTER_TO_INT (g_hash_table_lookup (context->filesystems, "home" )); | |||
if (home_mode != FLATPAK_FILESYSTEM_MODE_NONE) | if (home_mode != FLATPAK_FILESYSTEM_MODE_NONE) | |||
{ | { | |||
g_debug ("Allowing homedir access"); | g_info ("Allowing homedir access"); | |||
home_access = TRUE; | home_access = TRUE; | |||
flatpak_exports_add_path_expose (exports, MAX (home_mode, fs_mode), g_get_ | if (!flatpak_exports_add_path_expose (exports, MAX (home_mode, fs_mode), g | |||
home_dir ()); | _get_home_dir (), &local_error)) | |||
{ | ||||
/* Even if the error is one that we would normally silence, like | ||||
* the path not existing, it seems reasonable to make more of a fuss | ||||
* about the home directory not existing or otherwise being unusable, | ||||
* so this is intentionally not using cannot_export() */ | ||||
g_warning (_("Not allowing home directory access: %s"), | ||||
local_error->message); | ||||
g_clear_error (&local_error); | ||||
} | ||||
} | } | |||
g_hash_table_iter_init (&iter, context->filesystems); | g_hash_table_iter_init (&iter, context->filesystems); | |||
while (g_hash_table_iter_next (&iter, &key, &value)) | while (g_hash_table_iter_next (&iter, &key, &value)) | |||
{ | { | |||
const char *filesystem = key; | const char *filesystem = key; | |||
FlatpakFilesystemMode mode = GPOINTER_TO_INT (value); | FlatpakFilesystemMode mode = GPOINTER_TO_INT (value); | |||
if (g_strv_contains (flatpak_context_special_filesystems, filesystem)) | if (g_strv_contains (flatpak_context_special_filesystems, filesystem)) | |||
continue; | continue; | |||
skipping to change at line 2534 | skipping to change at line 2618 | |||
} | } | |||
if (path == NULL) | if (path == NULL) | |||
continue; /* Unconfigured, ignore */ | continue; /* Unconfigured, ignore */ | |||
if (strcmp (path, g_get_home_dir ()) == 0) | if (strcmp (path, g_get_home_dir ()) == 0) | |||
{ | { | |||
/* xdg-user-dirs sets disabled dirs to $HOME, and its in general n ot a good | /* xdg-user-dirs sets disabled dirs to $HOME, and its in general n ot a good | |||
idea to set full access to $HOME other than explicitly, so we i gnore | idea to set full access to $HOME other than explicitly, so we i gnore | |||
these */ | these */ | |||
g_debug ("Xdg dir %s is $HOME (i.e. disabled), ignoring", filesyst em); | g_info ("Xdg dir %s is $HOME (i.e. disabled), ignoring", filesyste m); | |||
continue; | continue; | |||
} | } | |||
subpath = g_build_filename (path, rest, NULL); | subpath = g_build_filename (path, rest, NULL); | |||
if (mode == FLATPAK_FILESYSTEM_MODE_CREATE && do_create) | if (mode == FLATPAK_FILESYSTEM_MODE_CREATE && do_create) | |||
{ | { | |||
if (g_mkdir_with_parents (subpath, 0755) != 0) | if (g_mkdir_with_parents (subpath, 0755) != 0) | |||
g_debug ("Unable to create directory %s", subpath); | g_info ("Unable to create directory %s", subpath); | |||
} | } | |||
if (g_file_test (subpath, G_FILE_TEST_EXISTS)) | if (g_file_test (subpath, G_FILE_TEST_EXISTS)) | |||
{ | { | |||
if (config_key && xdg_dirs_conf) | if (config_key && xdg_dirs_conf) | |||
g_string_append_printf (xdg_dirs_conf, "%s=\"%s\"\n", | g_string_append_printf (xdg_dirs_conf, "%s=\"%s\"\n", | |||
config_key, path); | config_key, path); | |||
flatpak_exports_add_path_expose_or_hide (exports, mode, subpath); | if (!flatpak_exports_add_path_expose_or_hide (exports, mode, subpa | |||
th, &local_error)) | ||||
{ | ||||
log_cannot_export_error (mode, subpath, local_error); | ||||
g_clear_error (&local_error); | ||||
} | ||||
} | } | |||
} | } | |||
else if (g_str_has_prefix (filesystem, "~/")) | else if (g_str_has_prefix (filesystem, "~/")) | |||
{ | { | |||
g_autofree char *path = NULL; | g_autofree char *path = NULL; | |||
path = g_build_filename (g_get_home_dir (), filesystem + 2, NULL); | path = g_build_filename (g_get_home_dir (), filesystem + 2, NULL); | |||
if (mode == FLATPAK_FILESYSTEM_MODE_CREATE && do_create) | if (mode == FLATPAK_FILESYSTEM_MODE_CREATE && do_create) | |||
{ | { | |||
if (g_mkdir_with_parents (path, 0755) != 0) | if (g_mkdir_with_parents (path, 0755) != 0) | |||
g_debug ("Unable to create directory %s", path); | g_info ("Unable to create directory %s", path); | |||
} | } | |||
if (g_file_test (path, G_FILE_TEST_EXISTS)) | if (!flatpak_exports_add_path_expose_or_hide (exports, mode, path, &lo | |||
flatpak_exports_add_path_expose_or_hide (exports, mode, path); | cal_error)) | |||
{ | ||||
log_cannot_export_error (mode, path, local_error); | ||||
g_clear_error (&local_error); | ||||
} | ||||
} | } | |||
else if (g_str_has_prefix (filesystem, "/")) | else if (g_str_has_prefix (filesystem, "/")) | |||
{ | { | |||
if (mode == FLATPAK_FILESYSTEM_MODE_CREATE && do_create) | if (mode == FLATPAK_FILESYSTEM_MODE_CREATE && do_create) | |||
{ | { | |||
if (g_mkdir_with_parents (filesystem, 0755) != 0) | if (g_mkdir_with_parents (filesystem, 0755) != 0) | |||
g_debug ("Unable to create directory %s", filesystem); | g_info ("Unable to create directory %s", filesystem); | |||
} | } | |||
if (g_file_test (filesystem, G_FILE_TEST_EXISTS)) | if (!flatpak_exports_add_path_expose_or_hide (exports, mode, filesyste | |||
flatpak_exports_add_path_expose_or_hide (exports, mode, filesystem); | m, &local_error)) | |||
{ | ||||
log_cannot_export_error (mode, filesystem, local_error); | ||||
g_clear_error (&local_error); | ||||
} | ||||
} | } | |||
else | else | |||
{ | { | |||
g_warning ("Unexpected filesystem arg %s", filesystem); | g_warning ("Unexpected filesystem arg %s", filesystem); | |||
} | } | |||
} | } | |||
if (app_id_dir) | if (app_id_dir) | |||
{ | { | |||
g_autoptr(GFile) apps_dir = g_file_get_parent (app_id_dir); | g_autoptr(GFile) apps_dir = g_file_get_parent (app_id_dir); | |||
int i; | int i; | |||
/* Hide the .var/app dir by default (unless explicitly made visible) */ | /* Hide the .var/app dir by default (unless explicitly made visible) */ | |||
flatpak_exports_add_path_tmpfs (exports, flatpak_file_get_path_cached (app | if (!flatpak_exports_add_path_tmpfs (exports, | |||
s_dir)); | flatpak_file_get_path_cached (apps_di | |||
r), | ||||
&local_error)) | ||||
{ | ||||
log_cannot_export_error (FLATPAK_FILESYSTEM_MODE_NONE, | ||||
flatpak_file_get_path_cached (apps_dir), | ||||
local_error); | ||||
g_clear_error (&local_error); | ||||
} | ||||
/* But let the app write to the per-app dir in it */ | /* But let the app write to the per-app dir in it */ | |||
flatpak_exports_add_path_expose (exports, FLATPAK_FILESYSTEM_MODE_READ_WRI | if (!flatpak_exports_add_path_expose (exports, FLATPAK_FILESYSTEM_MODE_REA | |||
TE, | D_WRITE, | |||
flatpak_file_get_path_cached (app_id_dir) | flatpak_file_get_path_cached (app_id | |||
); | _dir), | |||
&local_error)) | ||||
{ | ||||
log_cannot_export_error (FLATPAK_FILESYSTEM_MODE_READ_WRITE, | ||||
flatpak_file_get_path_cached (apps_dir), | ||||
local_error); | ||||
g_clear_error (&local_error); | ||||
} | ||||
if (extra_app_id_dirs != NULL) | if (extra_app_id_dirs != NULL) | |||
{ | { | |||
for (i = 0; i < extra_app_id_dirs->len; i++) | for (i = 0; i < extra_app_id_dirs->len; i++) | |||
{ | { | |||
GFile *extra_app_id_dir = g_ptr_array_index (extra_app_id_dirs, i) ; | GFile *extra_app_id_dir = g_ptr_array_index (extra_app_id_dirs, i) ; | |||
flatpak_exports_add_path_expose (exports, FLATPAK_FILESYSTEM_MODE_ | if (!flatpak_exports_add_path_expose (exports, | |||
READ_WRITE, | FLATPAK_FILESYSTEM_MODE_READ | |||
flatpak_file_get_path_cached (ext | _WRITE, | |||
ra_app_id_dir)); | flatpak_file_get_path_cached | |||
(extra_app_id_dir), | ||||
&local_error)) | ||||
{ | ||||
log_cannot_export_error (FLATPAK_FILESYSTEM_MODE_READ_WRITE, | ||||
flatpak_file_get_path_cached (extra_a | ||||
pp_id_dir), | ||||
local_error); | ||||
g_clear_error (&local_error); | ||||
} | ||||
} | } | |||
} | } | |||
} | } | |||
if (home_access_out != NULL) | if (home_access_out != NULL) | |||
*home_access_out = home_access; | *home_access_out = home_access; | |||
if (xdg_dirs_conf_out != NULL) | if (xdg_dirs_conf_out != NULL) | |||
{ | { | |||
g_assert (xdg_dirs_conf != NULL); | g_assert (xdg_dirs_conf != NULL); | |||
skipping to change at line 2667 | skipping to change at line 2785 | |||
{ | { | |||
g_autoptr(FlatpakExports) exports = flatpak_exports_new (); | g_autoptr(FlatpakExports) exports = flatpak_exports_new (); | |||
flatpak_context_export (context, exports, | flatpak_context_export (context, exports, | |||
app_id_dir, extra_app_id_dirs, | app_id_dir, extra_app_id_dirs, | |||
do_create, xdg_dirs_conf_out, home_access_out); | do_create, xdg_dirs_conf_out, home_access_out); | |||
if (include_default_dirs) | if (include_default_dirs) | |||
{ | { | |||
g_autoptr(GFile) user_flatpak_dir = NULL; | g_autoptr(GFile) user_flatpak_dir = NULL; | |||
g_autoptr(GError) local_error = NULL; | ||||
/* Hide the flatpak dir by default (unless explicitly made visible) */ | /* Hide the flatpak dir by default (unless explicitly made visible) */ | |||
user_flatpak_dir = flatpak_get_user_base_dir_location (); | user_flatpak_dir = flatpak_get_user_base_dir_location (); | |||
flatpak_exports_add_path_tmpfs (exports, flatpak_file_get_path_cached (use | if (!flatpak_exports_add_path_tmpfs (exports, | |||
r_flatpak_dir)); | flatpak_file_get_path_cached (user_fl | |||
atpak_dir), | ||||
&local_error)) | ||||
{ | ||||
log_cannot_export_error (FLATPAK_FILESYSTEM_MODE_NONE, | ||||
flatpak_file_get_path_cached (user_flatpak_di | ||||
r), | ||||
local_error); | ||||
g_clear_error (&local_error); | ||||
} | ||||
/* Ensure we always have a homedir */ | /* Ensure we always have a homedir */ | |||
flatpak_exports_add_path_dir (exports, g_get_home_dir ()); | if (!flatpak_exports_add_path_dir (exports, g_get_home_dir (), &local_erro | |||
r)) | ||||
{ | ||||
g_warning (_("Unable to provide a temporary home directory in the sand | ||||
box: %s"), | ||||
local_error->message); | ||||
g_clear_error (&local_error); | ||||
} | ||||
} | } | |||
return g_steal_pointer (&exports); | return g_steal_pointer (&exports); | |||
} | } | |||
void | void | |||
flatpak_context_append_bwrap_filesystem (FlatpakContext *context, | flatpak_context_append_bwrap_filesystem (FlatpakContext *context, | |||
FlatpakBwrap *bwrap, | FlatpakBwrap *bwrap, | |||
const char *app_id, | const char *app_id, | |||
GFile *app_id_dir, | GFile *app_id_dir, | |||
skipping to change at line 2706 | skipping to change at line 2838 | |||
/* Enable persistent mapping only if no access to real home dir */ | /* Enable persistent mapping only if no access to real home dir */ | |||
g_hash_table_iter_init (&iter, context->persistent); | g_hash_table_iter_init (&iter, context->persistent); | |||
while (g_hash_table_iter_next (&iter, &key, NULL)) | while (g_hash_table_iter_next (&iter, &key, NULL)) | |||
{ | { | |||
const char *persist = key; | const char *persist = key; | |||
g_autofree char *src = g_build_filename (g_get_home_dir (), ".var/app" , app_id, persist, NULL); | g_autofree char *src = g_build_filename (g_get_home_dir (), ".var/app" , app_id, persist, NULL); | |||
g_autofree char *dest = g_build_filename (g_get_home_dir (), persist, NULL); | g_autofree char *dest = g_build_filename (g_get_home_dir (), persist, NULL); | |||
if (g_mkdir_with_parents (src, 0755) != 0) | if (g_mkdir_with_parents (src, 0755) != 0) | |||
g_debug ("Unable to create directory %s", src); | g_info ("Unable to create directory %s", src); | |||
flatpak_bwrap_add_bind_arg (bwrap, "--bind", src, dest); | flatpak_bwrap_add_bind_arg (bwrap, "--bind", src, dest); | |||
} | } | |||
} | } | |||
if (app_id_dir != NULL) | if (app_id_dir != NULL) | |||
{ | { | |||
g_autofree char *user_runtime_dir = flatpak_get_real_xdg_runtime_dir (); | g_autofree char *user_runtime_dir = flatpak_get_real_xdg_runtime_dir (); | |||
g_autofree char *run_user_app_dst = g_strdup_printf ("/run/flatpak/app/%s" , app_id); | g_autofree char *run_user_app_dst = g_strdup_printf ("/run/flatpak/app/%s" , app_id); | |||
g_autofree char *run_user_app_src = g_build_filename (user_runtime_dir, "a pp", app_id, NULL); | g_autofree char *run_user_app_src = g_build_filename (user_runtime_dir, "a pp", app_id, NULL); | |||
End of changes. 27 change blocks. | ||||
36 lines changed or deleted | 178 lines changed or added |