flatpak-run.c (flatpak-1.15.1.tar.xz) | : | flatpak-run.c (flatpak-1.15.2.tar.xz) | ||
---|---|---|---|---|
skipping to change at line 316 | skipping to change at line 316 | |||
flatpak_bwrap_add_args (bwrap, | flatpak_bwrap_add_args (bwrap, | |||
"--tmpfs", "/tmp/.X11-unix", | "--tmpfs", "/tmp/.X11-unix", | |||
NULL); | NULL); | |||
if (!allowed) | if (!allowed) | |||
{ | { | |||
flatpak_bwrap_unset_env (bwrap, "DISPLAY"); | flatpak_bwrap_unset_env (bwrap, "DISPLAY"); | |||
return; | return; | |||
} | } | |||
g_debug ("Allowing x11 access"); | g_info ("Allowing x11 access"); | |||
display = g_getenv ("DISPLAY"); | display = g_getenv ("DISPLAY"); | |||
if (display != NULL) | if (display != NULL) | |||
{ | { | |||
g_autofree char *remote_host = NULL; | g_autofree char *remote_host = NULL; | |||
g_autofree char *display_nr = NULL; | g_autofree char *display_nr = NULL; | |||
int family = -1; | int family = -1; | |||
if (!flatpak_run_parse_x11_display (display, &family, &x11_socket, | if (!flatpak_run_parse_x11_display (display, &family, &x11_socket, | |||
skipping to change at line 372 | skipping to change at line 372 | |||
g_warning ("X11 access will require --share=network permission."); | g_warning ("X11 access will require --share=network permission."); | |||
} | } | |||
else if (x11_socket != NULL) | else if (x11_socket != NULL) | |||
{ | { | |||
g_warning ("X11 socket %s does not exist in filesystem, " | g_warning ("X11 socket %s does not exist in filesystem, " | |||
"trying to use abstract socket instead.", | "trying to use abstract socket instead.", | |||
x11_socket); | x11_socket); | |||
} | } | |||
else | else | |||
{ | { | |||
flatpak_debug2 ("Assuming --share=network gives access to remote X11") ; | g_debug ("Assuming --share=network gives access to remote X11"); | |||
} | } | |||
#ifdef ENABLE_XAUTH | #ifdef ENABLE_XAUTH | |||
g_auto(GLnxTmpfile) xauth_tmpf = { 0, }; | g_auto(GLnxTmpfile) xauth_tmpf = { 0, }; | |||
if (glnx_open_anonymous_tmpfile_full (O_RDWR | O_CLOEXEC, "/tmp", &xauth_t mpf, NULL)) | if (glnx_open_anonymous_tmpfile_full (O_RDWR | O_CLOEXEC, "/tmp", &xauth_t mpf, NULL)) | |||
{ | { | |||
FILE *output = fdopen (xauth_tmpf.fd, "wb"); | FILE *output = fdopen (xauth_tmpf.fd, "wb"); | |||
if (output != NULL) | if (output != NULL) | |||
{ | { | |||
skipping to change at line 523 | skipping to change at line 523 | |||
{ | { | |||
g_autoptr(GFile) file = g_file_new_for_path (path); | g_autoptr(GFile) file = g_file_new_for_path (path); | |||
g_autoptr(GError) my_error = NULL; | g_autoptr(GError) my_error = NULL; | |||
g_autoptr(GFileInputStream) input_stream = NULL; | g_autoptr(GFileInputStream) input_stream = NULL; | |||
g_autoptr(GDataInputStream) data_stream = NULL; | g_autoptr(GDataInputStream) data_stream = NULL; | |||
size_t len; | size_t len; | |||
input_stream = g_file_read (file, NULL, &my_error); | input_stream = g_file_read (file, NULL, &my_error); | |||
if (my_error) | if (my_error) | |||
{ | { | |||
g_debug ("CUPS configuration file '%s': %s", path, my_error->message); | g_info ("CUPS configuration file '%s': %s", path, my_error->message); | |||
return NULL; | return NULL; | |||
} | } | |||
data_stream = g_data_input_stream_new (G_INPUT_STREAM (input_stream)); | data_stream = g_data_input_stream_new (G_INPUT_STREAM (input_stream)); | |||
while (TRUE) | while (TRUE) | |||
{ | { | |||
g_autofree char *line = g_data_input_stream_read_line (data_stream, &len, NULL, NULL); | g_autofree char *line = g_data_input_stream_read_line (data_stream, &len, NULL, NULL); | |||
if (line == NULL) | if (line == NULL) | |||
break; | break; | |||
skipping to change at line 595 | skipping to change at line 595 | |||
} | } | |||
static void | static void | |||
flatpak_run_add_cups_args (FlatpakBwrap *bwrap) | flatpak_run_add_cups_args (FlatpakBwrap *bwrap) | |||
{ | { | |||
g_autofree char * sandbox_server_name = g_strdup ("/var/run/cups/cups.sock"); | g_autofree char * sandbox_server_name = g_strdup ("/var/run/cups/cups.sock"); | |||
g_autofree char * cups_server_name = flatpak_run_get_cups_server_name (); | g_autofree char * cups_server_name = flatpak_run_get_cups_server_name (); | |||
if (!g_file_test (cups_server_name, G_FILE_TEST_EXISTS)) | if (!g_file_test (cups_server_name, G_FILE_TEST_EXISTS)) | |||
{ | { | |||
g_debug ("Could not find CUPS server"); | g_info ("Could not find CUPS server"); | |||
return; | return; | |||
} | } | |||
flatpak_bwrap_add_args (bwrap, | flatpak_bwrap_add_args (bwrap, | |||
"--ro-bind", cups_server_name, sandbox_server_name, | "--ro-bind", cups_server_name, sandbox_server_name, | |||
NULL); | NULL); | |||
} | } | |||
static void | static void | |||
flatpak_run_add_gpg_agent_args (FlatpakBwrap *bwrap) | flatpak_run_add_gpg_agent_args (FlatpakBwrap *bwrap) | |||
skipping to change at line 620 | skipping to change at line 620 | |||
g_autoptr(GSubprocess) process = NULL; | g_autoptr(GSubprocess) process = NULL; | |||
g_autoptr(GInputStream) base_stream = NULL; | g_autoptr(GInputStream) base_stream = NULL; | |||
g_autoptr(GDataInputStream) data_stream = NULL; | g_autoptr(GDataInputStream) data_stream = NULL; | |||
process = g_subprocess_new (G_SUBPROCESS_FLAGS_STDOUT_PIPE, | process = g_subprocess_new (G_SUBPROCESS_FLAGS_STDOUT_PIPE, | |||
&gpgconf_error, | &gpgconf_error, | |||
"gpgconf", "--list-dir", "agent-socket", NULL); | "gpgconf", "--list-dir", "agent-socket", NULL); | |||
if (gpgconf_error) | if (gpgconf_error) | |||
{ | { | |||
g_debug ("GPG-Agent directories: %s", gpgconf_error->message); | g_info ("GPG-Agent directories: %s", gpgconf_error->message); | |||
return; | return; | |||
} | } | |||
base_stream = g_subprocess_get_stdout_pipe (process); | base_stream = g_subprocess_get_stdout_pipe (process); | |||
data_stream = g_data_input_stream_new (base_stream); | data_stream = g_data_input_stream_new (base_stream); | |||
agent_socket = g_data_input_stream_read_line (data_stream, | agent_socket = g_data_input_stream_read_line (data_stream, | |||
NULL, NULL, | NULL, NULL, | |||
&gpgconf_error); | &gpgconf_error); | |||
if (!agent_socket || gpgconf_error) | if (!agent_socket || gpgconf_error) | |||
{ | { | |||
g_debug ("GPG-Agent directories: %s", gpgconf_error->message); | g_info ("GPG-Agent directories: %s", gpgconf_error->message); | |||
return; | return; | |||
} | } | |||
sandbox_agent_socket = g_strdup_printf ("/run/user/%d/gnupg/S.gpg-agent", getu id ()); | sandbox_agent_socket = g_strdup_printf ("/run/user/%d/gnupg/S.gpg-agent", getu id ()); | |||
flatpak_bwrap_add_args (bwrap, | flatpak_bwrap_add_args (bwrap, | |||
"--ro-bind-try", agent_socket, sandbox_agent_socket, | "--ro-bind-try", agent_socket, sandbox_agent_socket, | |||
NULL); | NULL); | |||
} | } | |||
skipping to change at line 657 | skipping to change at line 657 | |||
{ | { | |||
g_autoptr(GFile) file = g_file_new_for_path (path); | g_autoptr(GFile) file = g_file_new_for_path (path); | |||
g_autoptr(GError) my_error = NULL; | g_autoptr(GError) my_error = NULL; | |||
g_autoptr(GFileInputStream) input_stream = NULL; | g_autoptr(GFileInputStream) input_stream = NULL; | |||
g_autoptr(GDataInputStream) data_stream = NULL; | g_autoptr(GDataInputStream) data_stream = NULL; | |||
size_t len; | size_t len; | |||
input_stream = g_file_read (file, NULL, &my_error); | input_stream = g_file_read (file, NULL, &my_error); | |||
if (my_error) | if (my_error) | |||
{ | { | |||
g_debug ("Pulseaudio user configuration file '%s': %s", path, my_error->me ssage); | g_info ("Pulseaudio user configuration file '%s': %s", path, my_error->mes sage); | |||
return NULL; | return NULL; | |||
} | } | |||
data_stream = g_data_input_stream_new (G_INPUT_STREAM (input_stream)); | data_stream = g_data_input_stream_new (G_INPUT_STREAM (input_stream)); | |||
while (TRUE) | while (TRUE) | |||
{ | { | |||
g_autofree char *line = g_data_input_stream_read_line (data_stream, &len, NULL, NULL); | g_autofree char *line = g_data_input_stream_read_line (data_stream, &len, NULL, NULL); | |||
if (line == NULL) | if (line == NULL) | |||
break; | break; | |||
skipping to change at line 696 | skipping to change at line 696 | |||
else | else | |||
{ | { | |||
g_auto(GStrv) tokens = g_strsplit (line, "=", 2); | g_auto(GStrv) tokens = g_strsplit (line, "=", 2); | |||
if ((tokens[0] != NULL) && (tokens[1] != NULL)) | if ((tokens[0] != NULL) && (tokens[1] != NULL)) | |||
{ | { | |||
g_strchomp (tokens[0]); | g_strchomp (tokens[0]); | |||
if (strcmp ("default-server", tokens[0]) == 0) | if (strcmp ("default-server", tokens[0]) == 0) | |||
{ | { | |||
g_strstrip (tokens[1]); | g_strstrip (tokens[1]); | |||
g_debug ("Found pulseaudio socket from configuration file '%s' : %s", path, tokens[1]); | g_info ("Found pulseaudio socket from configuration file '%s': %s", path, tokens[1]); | |||
return g_strdup (tokens[1]); | return g_strdup (tokens[1]); | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
return NULL; | return NULL; | |||
} | } | |||
static char * | static char * | |||
skipping to change at line 923 | skipping to change at line 923 | |||
flatpak_bwrap_unset_env (bwrap, "PULSE_SERVER"); | flatpak_bwrap_unset_env (bwrap, "PULSE_SERVER"); | |||
if (remote) | if (remote) | |||
{ | { | |||
if ((shares & FLATPAK_CONTEXT_SHARED_NETWORK) == 0) | if ((shares & FLATPAK_CONTEXT_SHARED_NETWORK) == 0) | |||
{ | { | |||
g_warning ("Remote PulseAudio server configured."); | g_warning ("Remote PulseAudio server configured."); | |||
g_warning ("PulseAudio access will require --share=network permission. "); | g_warning ("PulseAudio access will require --share=network permission. "); | |||
} | } | |||
g_debug ("Using remote PulseAudio server \"%s\"", pulseaudio_server); | g_info ("Using remote PulseAudio server \"%s\"", pulseaudio_server); | |||
flatpak_bwrap_set_env (bwrap, "PULSE_SERVER", pulseaudio_server, TRUE); | flatpak_bwrap_set_env (bwrap, "PULSE_SERVER", pulseaudio_server, TRUE); | |||
} | } | |||
else if (pulseaudio_socket && g_file_test (pulseaudio_socket, G_FILE_TEST_EXIS TS)) | else if (pulseaudio_socket && g_file_test (pulseaudio_socket, G_FILE_TEST_EXIS TS)) | |||
{ | { | |||
static const char sandbox_socket_path[] = "/run/flatpak/pulse/native"; | static const char sandbox_socket_path[] = "/run/flatpak/pulse/native"; | |||
static const char pulse_server[] = "unix:/run/flatpak/pulse/native"; | static const char pulse_server[] = "unix:/run/flatpak/pulse/native"; | |||
static const char config_path[] = "/run/flatpak/pulse/config"; | static const char config_path[] = "/run/flatpak/pulse/config"; | |||
gboolean share_shm = FALSE; /* TODO: When do we add this? */ | gboolean share_shm = FALSE; /* TODO: When do we add this? */ | |||
g_autofree char *client_config = g_strdup_printf ("enable-shm=%s\n", share _shm ? "yes" : "no"); | g_autofree char *client_config = g_strdup_printf ("enable-shm=%s\n", share _shm ? "yes" : "no"); | |||
skipping to change at line 947 | skipping to change at line 947 | |||
flatpak_bwrap_add_args (bwrap, | flatpak_bwrap_add_args (bwrap, | |||
"--ro-bind", pulseaudio_socket, sandbox_socket_pat h, | "--ro-bind", pulseaudio_socket, sandbox_socket_pat h, | |||
NULL); | NULL); | |||
flatpak_bwrap_set_env (bwrap, "PULSE_SERVER", pulse_server, TRUE); | flatpak_bwrap_set_env (bwrap, "PULSE_SERVER", pulse_server, TRUE); | |||
flatpak_bwrap_set_env (bwrap, "PULSE_CLIENTCONFIG", config_path, TRUE); | flatpak_bwrap_set_env (bwrap, "PULSE_CLIENTCONFIG", config_path, TRUE); | |||
flatpak_bwrap_add_runtime_dir_member (bwrap, "pulse"); | flatpak_bwrap_add_runtime_dir_member (bwrap, "pulse"); | |||
} | } | |||
else | else | |||
g_debug ("Could not find pulseaudio socket"); | g_info ("Could not find pulseaudio socket"); | |||
/* Also allow ALSA access. This was added in 1.8, and is not ideally named. Ho wever, | /* Also allow ALSA access. This was added in 1.8, and is not ideally named. Ho wever, | |||
* since the practical permission of ALSA and PulseAudio are essentially the s ame, and | * since the practical permission of ALSA and PulseAudio are essentially the s ame, and | |||
* since we don't want to add more permissions for something we plan to replac e with | * since we don't want to add more permissions for something we plan to replac e with | |||
* portals/pipewire going forward we reinterpret pulseaudio to also mean ALSA. | * portals/pipewire going forward we reinterpret pulseaudio to also mean ALSA. | |||
*/ | */ | |||
if (!remote && g_file_test ("/dev/snd", G_FILE_TEST_IS_DIR)) | if (!remote && g_file_test ("/dev/snd", G_FILE_TEST_IS_DIR)) | |||
flatpak_bwrap_add_args (bwrap, "--dev-bind", "/dev/snd", "/dev/snd", NULL); | flatpak_bwrap_add_args (bwrap, "--dev-bind", "/dev/snd", "/dev/snd", NULL); | |||
} | } | |||
skipping to change at line 1033 | skipping to change at line 1033 | |||
FlatpakContext *context, | FlatpakContext *context, | |||
FlatpakRunFlags flags) | FlatpakRunFlags flags) | |||
{ | { | |||
gboolean unrestricted, no_proxy; | gboolean unrestricted, no_proxy; | |||
const char *dbus_address = g_getenv ("DBUS_SYSTEM_BUS_ADDRESS"); | const char *dbus_address = g_getenv ("DBUS_SYSTEM_BUS_ADDRESS"); | |||
g_autofree char *real_dbus_address = NULL; | g_autofree char *real_dbus_address = NULL; | |||
g_autofree char *dbus_system_socket = NULL; | g_autofree char *dbus_system_socket = NULL; | |||
unrestricted = (context->sockets & FLATPAK_CONTEXT_SOCKET_SYSTEM_BUS) != 0; | unrestricted = (context->sockets & FLATPAK_CONTEXT_SOCKET_SYSTEM_BUS) != 0; | |||
if (unrestricted) | if (unrestricted) | |||
g_debug ("Allowing system-dbus access"); | g_info ("Allowing system-dbus access"); | |||
no_proxy = (flags & FLATPAK_RUN_FLAG_NO_SYSTEM_BUS_PROXY) != 0; | no_proxy = (flags & FLATPAK_RUN_FLAG_NO_SYSTEM_BUS_PROXY) != 0; | |||
if (dbus_address != NULL) | if (dbus_address != NULL) | |||
dbus_system_socket = extract_unix_path_from_dbus_address (dbus_address); | dbus_system_socket = extract_unix_path_from_dbus_address (dbus_address); | |||
else if (g_file_test ("/var/run/dbus/system_bus_socket", G_FILE_TEST_EXISTS)) | else if (g_file_test ("/var/run/dbus/system_bus_socket", G_FILE_TEST_EXISTS)) | |||
dbus_system_socket = g_strdup ("/var/run/dbus/system_bus_socket"); | dbus_system_socket = g_strdup ("/var/run/dbus/system_bus_socket"); | |||
if (dbus_system_socket != NULL && unrestricted) | if (dbus_system_socket != NULL && unrestricted) | |||
{ | { | |||
skipping to change at line 1114 | skipping to change at line 1114 | |||
dbus_session_socket = g_build_filename (user_runtime_dir, "bus", NULL); | dbus_session_socket = g_build_filename (user_runtime_dir, "bus", NULL); | |||
if (stat (dbus_session_socket, &statbuf) < 0 | if (stat (dbus_session_socket, &statbuf) < 0 | |||
|| (statbuf.st_mode & S_IFMT) != S_IFSOCK | || (statbuf.st_mode & S_IFMT) != S_IFSOCK | |||
|| statbuf.st_uid != getuid ()) | || statbuf.st_uid != getuid ()) | |||
return FALSE; | return FALSE; | |||
} | } | |||
if (unrestricted) | if (unrestricted) | |||
g_debug ("Allowing session-dbus access"); | g_info ("Allowing session-dbus access"); | |||
no_proxy = (flags & FLATPAK_RUN_FLAG_NO_SESSION_BUS_PROXY) != 0; | no_proxy = (flags & FLATPAK_RUN_FLAG_NO_SESSION_BUS_PROXY) != 0; | |||
if (dbus_session_socket != NULL && unrestricted) | if (dbus_session_socket != NULL && unrestricted) | |||
{ | { | |||
flatpak_bwrap_add_args (app_bwrap, | flatpak_bwrap_add_args (app_bwrap, | |||
"--ro-bind", dbus_session_socket, sandbox_socket_p ath, | "--ro-bind", dbus_session_socket, sandbox_socket_p ath, | |||
NULL); | NULL); | |||
flatpak_bwrap_set_env (app_bwrap, "DBUS_SESSION_BUS_ADDRESS", sandbox_dbus _address, TRUE); | flatpak_bwrap_set_env (app_bwrap, "DBUS_SESSION_BUS_ADDRESS", sandbox_dbus _address, TRUE); | |||
flatpak_bwrap_add_runtime_dir_member (app_bwrap, "bus"); | flatpak_bwrap_add_runtime_dir_member (app_bwrap, "bus"); | |||
skipping to change at line 1367 | skipping to change at line 1367 | |||
/* Note: This steals the fds from proxy_arg_bwrap */ | /* Note: This steals the fds from proxy_arg_bwrap */ | |||
flatpak_bwrap_append_bwrap (proxy_bwrap, proxy_arg_bwrap); | flatpak_bwrap_append_bwrap (proxy_bwrap, proxy_arg_bwrap); | |||
if (!flatpak_bwrap_bundle_args (proxy_bwrap, proxy_start_index, -1, TRUE, erro r)) | if (!flatpak_bwrap_bundle_args (proxy_bwrap, proxy_start_index, -1, TRUE, erro r)) | |||
return FALSE; | return FALSE; | |||
flatpak_bwrap_finish (proxy_bwrap); | flatpak_bwrap_finish (proxy_bwrap); | |||
commandline = flatpak_quote_argv ((const char **) proxy_bwrap->argv->pdata, -1 ); | commandline = flatpak_quote_argv ((const char **) proxy_bwrap->argv->pdata, -1 ); | |||
g_debug ("Running '%s'", commandline); | g_info ("Running '%s'", commandline); | |||
/* We use LEAVE_DESCRIPTORS_OPEN to work around dead-lock, see flatpak_close_f ds_workaround */ | /* We use LEAVE_DESCRIPTORS_OPEN to work around dead-lock, see flatpak_close_f ds_workaround */ | |||
if (!g_spawn_async (NULL, | if (!g_spawn_async (NULL, | |||
(char **) proxy_bwrap->argv->pdata, | (char **) proxy_bwrap->argv->pdata, | |||
NULL, | NULL, | |||
G_SPAWN_SEARCH_PATH | G_SPAWN_LEAVE_DESCRIPTORS_OPEN, | G_SPAWN_SEARCH_PATH | G_SPAWN_LEAVE_DESCRIPTORS_OPEN, | |||
flatpak_bwrap_child_setup_cb, proxy_bwrap->fds, | flatpak_bwrap_child_setup_cb, proxy_bwrap->fds, | |||
NULL, error)) | NULL, error)) | |||
return FALSE; | return FALSE; | |||
skipping to change at line 1600 | skipping to change at line 1600 | |||
g_autoptr(FlatpakExports) exports = NULL; | g_autoptr(FlatpakExports) exports = NULL; | |||
g_autoptr(FlatpakBwrap) proxy_arg_bwrap = flatpak_bwrap_new (flatpak_bwrap_emp ty_env); | g_autoptr(FlatpakBwrap) proxy_arg_bwrap = flatpak_bwrap_new (flatpak_bwrap_emp ty_env); | |||
g_autofree char *xdg_dirs_conf = NULL; | g_autofree char *xdg_dirs_conf = NULL; | |||
gboolean has_wayland = FALSE; | gboolean has_wayland = FALSE; | |||
gboolean allow_x11 = FALSE; | gboolean allow_x11 = FALSE; | |||
gboolean home_access = FALSE; | gboolean home_access = FALSE; | |||
gboolean sandboxed = (flags & FLATPAK_RUN_FLAG_SANDBOX) != 0; | gboolean sandboxed = (flags & FLATPAK_RUN_FLAG_SANDBOX) != 0; | |||
if ((context->shares & FLATPAK_CONTEXT_SHARED_IPC) == 0) | if ((context->shares & FLATPAK_CONTEXT_SHARED_IPC) == 0) | |||
{ | { | |||
g_debug ("Disallowing ipc access"); | g_info ("Disallowing ipc access"); | |||
flatpak_bwrap_add_args (bwrap, "--unshare-ipc", NULL); | flatpak_bwrap_add_args (bwrap, "--unshare-ipc", NULL); | |||
} | } | |||
if ((context->shares & FLATPAK_CONTEXT_SHARED_NETWORK) == 0) | if ((context->shares & FLATPAK_CONTEXT_SHARED_NETWORK) == 0) | |||
{ | { | |||
g_debug ("Disallowing network access"); | g_info ("Disallowing network access"); | |||
flatpak_bwrap_add_args (bwrap, "--unshare-net", NULL); | flatpak_bwrap_add_args (bwrap, "--unshare-net", NULL); | |||
} | } | |||
if (context->devices & FLATPAK_CONTEXT_DEVICE_ALL) | if (context->devices & FLATPAK_CONTEXT_DEVICE_ALL) | |||
{ | { | |||
flatpak_bwrap_add_args (bwrap, | flatpak_bwrap_add_args (bwrap, | |||
"--dev-bind", "/dev", "/dev", | "--dev-bind", "/dev", "/dev", | |||
NULL); | NULL); | |||
/* Don't expose the host /dev/shm, just the device nodes, unless explicitl y allowed */ | /* Don't expose the host /dev/shm, just the device nodes, unless explicitl y allowed */ | |||
if (g_file_test ("/dev/shm", G_FILE_TEST_IS_DIR)) | if (g_file_test ("/dev/shm", G_FILE_TEST_IS_DIR)) | |||
skipping to change at line 1703 | skipping to change at line 1703 | |||
g_warning ("Unexpected /dev/shm symlink %s", link); | g_warning ("Unexpected /dev/shm symlink %s", link); | |||
} | } | |||
} | } | |||
else | else | |||
{ | { | |||
flatpak_bwrap_add_args (bwrap, | flatpak_bwrap_add_args (bwrap, | |||
"--dev", "/dev", | "--dev", "/dev", | |||
NULL); | NULL); | |||
if (context->devices & FLATPAK_CONTEXT_DEVICE_DRI) | if (context->devices & FLATPAK_CONTEXT_DEVICE_DRI) | |||
{ | { | |||
g_debug ("Allowing dri access"); | g_info ("Allowing dri access"); | |||
int i; | int i; | |||
char *dri_devices[] = { | char *dri_devices[] = { | |||
"/dev/dri", | "/dev/dri", | |||
/* mali */ | /* mali */ | |||
"/dev/mali", | "/dev/mali", | |||
"/dev/mali0", | "/dev/mali0", | |||
"/dev/umplock", | "/dev/umplock", | |||
/* nvidia */ | /* nvidia */ | |||
"/dev/nvidiactl", | "/dev/nvidiactl", | |||
"/dev/nvidia-modeset", | "/dev/nvidia-modeset", | |||
skipping to change at line 1738 | skipping to change at line 1738 | |||
for (i = 0; i < 20; i++) | for (i = 0; i < 20; i++) | |||
{ | { | |||
g_snprintf (nvidia_dev, sizeof (nvidia_dev), "/dev/nvidia%d", i); | g_snprintf (nvidia_dev, sizeof (nvidia_dev), "/dev/nvidia%d", i); | |||
if (g_file_test (nvidia_dev, G_FILE_TEST_EXISTS)) | if (g_file_test (nvidia_dev, G_FILE_TEST_EXISTS)) | |||
flatpak_bwrap_add_args (bwrap, "--dev-bind", nvidia_dev, nvidia_ dev, NULL); | flatpak_bwrap_add_args (bwrap, "--dev-bind", nvidia_dev, nvidia_ dev, NULL); | |||
} | } | |||
} | } | |||
if (context->devices & FLATPAK_CONTEXT_DEVICE_KVM) | if (context->devices & FLATPAK_CONTEXT_DEVICE_KVM) | |||
{ | { | |||
g_debug ("Allowing kvm access"); | g_info ("Allowing kvm access"); | |||
if (g_file_test ("/dev/kvm", G_FILE_TEST_EXISTS)) | if (g_file_test ("/dev/kvm", G_FILE_TEST_EXISTS)) | |||
flatpak_bwrap_add_args (bwrap, "--dev-bind", "/dev/kvm", "/dev/kvm", NULL); | flatpak_bwrap_add_args (bwrap, "--dev-bind", "/dev/kvm", "/dev/kvm", NULL); | |||
} | } | |||
if (context->devices & FLATPAK_CONTEXT_DEVICE_SHM) | if (context->devices & FLATPAK_CONTEXT_DEVICE_SHM) | |||
{ | { | |||
/* This is a symlink to /run/shm on debian, so bind to real target */ | /* This is a symlink to /run/shm on debian, so bind to real target */ | |||
g_autofree char *real_dev_shm = realpath ("/dev/shm", NULL); | g_autofree char *real_dev_shm = realpath ("/dev/shm", NULL); | |||
g_debug ("Allowing /dev/shm access (as %s)", real_dev_shm); | g_info ("Allowing /dev/shm access (as %s)", real_dev_shm); | |||
if (real_dev_shm != NULL) | if (real_dev_shm != NULL) | |||
flatpak_bwrap_add_args (bwrap, "--bind", real_dev_shm, "/dev/shm", NULL); | flatpak_bwrap_add_args (bwrap, "--bind", real_dev_shm, "/dev/shm", NULL); | |||
} | } | |||
else if ((context->features & FLATPAK_CONTEXT_FEATURE_PER_APP_DEV_SHM) | else if ((context->features & FLATPAK_CONTEXT_FEATURE_PER_APP_DEV_SHM) | |||
&& per_app_dir_lock_fd >= 0) | && per_app_dir_lock_fd >= 0) | |||
{ | { | |||
g_autofree char *shared_dev_shm = NULL; | g_autofree char *shared_dev_shm = NULL; | |||
if (!flatpak_instance_ensure_per_app_dev_shm (app_id, | if (!flatpak_instance_ensure_per_app_dev_shm (app_id, | |||
per_app_dir_lock_fd, | per_app_dir_lock_fd, | |||
skipping to change at line 1807 | skipping to change at line 1807 | |||
flatpak_bwrap_add_args (bwrap, | flatpak_bwrap_add_args (bwrap, | |||
"--bind", shared_tmp, "/tmp", | "--bind", shared_tmp, "/tmp", | |||
NULL); | NULL); | |||
} | } | |||
flatpak_context_append_bwrap_filesystem (context, bwrap, app_id, app_id_dir, | flatpak_context_append_bwrap_filesystem (context, bwrap, app_id, app_id_dir, | |||
exports, xdg_dirs_conf, home_access); | exports, xdg_dirs_conf, home_access); | |||
if (context->sockets & FLATPAK_CONTEXT_SOCKET_WAYLAND) | if (context->sockets & FLATPAK_CONTEXT_SOCKET_WAYLAND) | |||
{ | { | |||
g_debug ("Allowing wayland access"); | g_info ("Allowing wayland access"); | |||
has_wayland = flatpak_run_add_wayland_args (bwrap); | has_wayland = flatpak_run_add_wayland_args (bwrap); | |||
} | } | |||
if ((context->sockets & FLATPAK_CONTEXT_SOCKET_FALLBACK_X11) != 0) | if ((context->sockets & FLATPAK_CONTEXT_SOCKET_FALLBACK_X11) != 0) | |||
allow_x11 = !has_wayland; | allow_x11 = !has_wayland; | |||
else | else | |||
allow_x11 = (context->sockets & FLATPAK_CONTEXT_SOCKET_X11) != 0; | allow_x11 = (context->sockets & FLATPAK_CONTEXT_SOCKET_X11) != 0; | |||
flatpak_run_add_x11_args (bwrap, allow_x11, context->shares); | flatpak_run_add_x11_args (bwrap, allow_x11, context->shares); | |||
if (context->sockets & FLATPAK_CONTEXT_SOCKET_SSH_AUTH) | if (context->sockets & FLATPAK_CONTEXT_SOCKET_SSH_AUTH) | |||
{ | { | |||
flatpak_run_add_ssh_args (bwrap); | flatpak_run_add_ssh_args (bwrap); | |||
} | } | |||
if (context->sockets & FLATPAK_CONTEXT_SOCKET_PULSEAUDIO) | if (context->sockets & FLATPAK_CONTEXT_SOCKET_PULSEAUDIO) | |||
{ | { | |||
g_debug ("Allowing pulseaudio access"); | g_info ("Allowing pulseaudio access"); | |||
flatpak_run_add_pulseaudio_args (bwrap, context->shares); | flatpak_run_add_pulseaudio_args (bwrap, context->shares); | |||
} | } | |||
if (context->sockets & FLATPAK_CONTEXT_SOCKET_PCSC) | if (context->sockets & FLATPAK_CONTEXT_SOCKET_PCSC) | |||
{ | { | |||
flatpak_run_add_pcsc_args (bwrap); | flatpak_run_add_pcsc_args (bwrap); | |||
} | } | |||
if (context->sockets & FLATPAK_CONTEXT_SOCKET_CUPS) | if (context->sockets & FLATPAK_CONTEXT_SOCKET_CUPS) | |||
{ | { | |||
skipping to change at line 1854 | skipping to change at line 1854 | |||
flatpak_run_add_session_dbus_args (bwrap, proxy_arg_bwrap, context, flags, app _id); | flatpak_run_add_session_dbus_args (bwrap, proxy_arg_bwrap, context, flags, app _id); | |||
flatpak_run_add_system_dbus_args (bwrap, proxy_arg_bwrap, context, flags); | flatpak_run_add_system_dbus_args (bwrap, proxy_arg_bwrap, context, flags); | |||
flatpak_run_add_a11y_dbus_args (bwrap, proxy_arg_bwrap, context, flags); | flatpak_run_add_a11y_dbus_args (bwrap, proxy_arg_bwrap, context, flags); | |||
/* Must run this before spawning the dbus proxy, to ensure it | /* Must run this before spawning the dbus proxy, to ensure it | |||
ends up in the app cgroup */ | ends up in the app cgroup */ | |||
if (!flatpak_run_in_transient_unit (app_id, &my_error)) | if (!flatpak_run_in_transient_unit (app_id, &my_error)) | |||
{ | { | |||
/* We still run along even if we don't get a cgroup, as nothing | /* We still run along even if we don't get a cgroup, as nothing | |||
really depends on it. Its just nice to have */ | really depends on it. Its just nice to have */ | |||
g_debug ("Failed to run in transient scope: %s", my_error->message); | g_info ("Failed to run in transient scope: %s", my_error->message); | |||
g_clear_error (&my_error); | g_clear_error (&my_error); | |||
} | } | |||
if (!flatpak_bwrap_is_empty (proxy_arg_bwrap) && | if (!flatpak_bwrap_is_empty (proxy_arg_bwrap) && | |||
!start_dbus_proxy (bwrap, proxy_arg_bwrap, app_info_path, error)) | !start_dbus_proxy (bwrap, proxy_arg_bwrap, app_info_path, error)) | |||
return FALSE; | return FALSE; | |||
if (exports_out) | if (exports_out) | |||
*exports_out = g_steal_pointer (&exports); | *exports_out = g_steal_pointer (&exports); | |||
skipping to change at line 1913 | skipping to change at line 1913 | |||
{"GST_PLUGIN_PATH", NULL}, | {"GST_PLUGIN_PATH", NULL}, | |||
{"GST_PLUGIN_SYSTEM_PATH", NULL}, | {"GST_PLUGIN_SYSTEM_PATH", NULL}, | |||
{"GST_PLUGIN_SCANNER", NULL}, | {"GST_PLUGIN_SCANNER", NULL}, | |||
{"GST_PLUGIN_SCANNER_1_0", NULL}, | {"GST_PLUGIN_SCANNER_1_0", NULL}, | |||
{"GST_PLUGIN_SYSTEM_PATH_1_0", NULL}, | {"GST_PLUGIN_SYSTEM_PATH_1_0", NULL}, | |||
{"GST_PRESET_PATH", NULL}, | {"GST_PRESET_PATH", NULL}, | |||
{"GST_PTP_HELPER", NULL}, | {"GST_PTP_HELPER", NULL}, | |||
{"GST_PTP_HELPER_1_0", NULL}, | {"GST_PTP_HELPER_1_0", NULL}, | |||
{"GST_INSTALL_PLUGINS_HELPER", NULL}, | {"GST_INSTALL_PLUGINS_HELPER", NULL}, | |||
{"KRB5CCNAME", NULL}, | {"KRB5CCNAME", NULL}, | |||
{"XKB_CONFIG_ROOT", NULL}, | ||||
{"GIO_EXTRA_MODULES", NULL}, | ||||
}; | }; | |||
static const ExportData no_ld_so_cache_exports[] = { | static const ExportData no_ld_so_cache_exports[] = { | |||
{"LD_LIBRARY_PATH", "/app/lib"}, | {"LD_LIBRARY_PATH", "/app/lib"}, | |||
}; | }; | |||
static const ExportData devel_exports[] = { | static const ExportData devel_exports[] = { | |||
{"ACLOCAL_PATH", "/app/share/aclocal"}, | {"ACLOCAL_PATH", "/app/share/aclocal"}, | |||
{"C_INCLUDE_PATH", "/app/include"}, | {"C_INCLUDE_PATH", "/app/include"}, | |||
{"CPLUS_INCLUDE_PATH", "/app/include"}, | {"CPLUS_INCLUDE_PATH", "/app/include"}, | |||
skipping to change at line 2514 | skipping to change at line 2516 | |||
locks_data = g_string_new (""); | locks_data = g_string_new (""); | |||
#ifdef HAVE_DCONF | #ifdef HAVE_DCONF | |||
client = dconf_client_new (); | client = dconf_client_new (); | |||
prefix = flatpak_dconf_path_for_app_id (app_id); | prefix = flatpak_dconf_path_for_app_id (app_id); | |||
if (migrate_path) | if (migrate_path) | |||
{ | { | |||
g_debug ("Add values in dir '%s', prefix is '%s'", migrate_path, prefix); | g_info ("Add values in dir '%s', prefix is '%s'", migrate_path, prefix); | |||
if (flatpak_dconf_path_is_similar (migrate_path, prefix)) | if (flatpak_dconf_path_is_similar (migrate_path, prefix)) | |||
add_dconf_dir_to_keyfile (values_data, client, migrate_path, DCONF_READ_ USER_VALUE); | add_dconf_dir_to_keyfile (values_data, client, migrate_path, DCONF_READ_ USER_VALUE); | |||
else | else | |||
g_warning ("Ignoring D-Conf migrate-path setting %s", migrate_path); | g_warning ("Ignoring D-Conf migrate-path setting %s", migrate_path); | |||
} | } | |||
g_debug ("Add defaults in dir %s", prefix); | g_info ("Add defaults in dir %s", prefix); | |||
add_dconf_dir_to_keyfile (defaults_data, client, prefix, DCONF_READ_DEFAULT_VA LUE); | add_dconf_dir_to_keyfile (defaults_data, client, prefix, DCONF_READ_DEFAULT_VA LUE); | |||
g_debug ("Add locks in dir %s", prefix); | g_info ("Add locks in dir %s", prefix); | |||
add_dconf_locks_to_list (locks_data, client, prefix); | add_dconf_locks_to_list (locks_data, client, prefix); | |||
/* We allow extra paths for defaults and locks, but not for user values */ | /* We allow extra paths for defaults and locks, but not for user values */ | |||
if (paths) | if (paths) | |||
{ | { | |||
int i; | int i; | |||
for (i = 0; paths[i]; i++) | for (i = 0; paths[i]; i++) | |||
{ | { | |||
if (dconf_is_dir (paths[i], NULL)) | if (dconf_is_dir (paths[i], NULL)) | |||
{ | { | |||
g_debug ("Add defaults in dir %s", paths[i]); | g_info ("Add defaults in dir %s", paths[i]); | |||
add_dconf_dir_to_keyfile (defaults_data, client, paths[i], DCONF_R EAD_DEFAULT_VALUE); | add_dconf_dir_to_keyfile (defaults_data, client, paths[i], DCONF_R EAD_DEFAULT_VALUE); | |||
g_debug ("Add locks in dir %s", paths[i]); | g_info ("Add locks in dir %s", paths[i]); | |||
add_dconf_locks_to_list (locks_data, client, paths[i]); | add_dconf_locks_to_list (locks_data, client, paths[i]); | |||
} | } | |||
else if (dconf_is_key (paths[i], NULL)) | else if (dconf_is_key (paths[i], NULL)) | |||
{ | { | |||
g_debug ("Add individual key %s", paths[i]); | g_info ("Add individual key %s", paths[i]); | |||
add_dconf_key_to_keyfile (defaults_data, client, paths[i], DCONF_R EAD_DEFAULT_VALUE); | add_dconf_key_to_keyfile (defaults_data, client, paths[i], DCONF_R EAD_DEFAULT_VALUE); | |||
add_dconf_key_to_keyfile (values_data, client, paths[i], DCONF_REA D_USER_VALUE); | add_dconf_key_to_keyfile (values_data, client, paths[i], DCONF_REA D_USER_VALUE); | |||
} | } | |||
else | else | |||
{ | { | |||
g_warning ("Ignoring settings path '%s': neither dir nor key", pat hs[i]); | g_warning ("Ignoring settings path '%s': neither dir nor key", pat hs[i]); | |||
} | } | |||
} | } | |||
} | } | |||
#endif | #endif | |||
skipping to change at line 2627 | skipping to change at line 2629 | |||
*/ | */ | |||
if (migrate_path) | if (migrate_path) | |||
{ | { | |||
g_autofree char *filename = NULL; | g_autofree char *filename = NULL; | |||
filename = g_build_filename (g_get_home_dir (), | filename = g_build_filename (g_get_home_dir (), | |||
".var/app", app_id, | ".var/app", app_id, | |||
"config/glib-2.0/settings/keyfile", | "config/glib-2.0/settings/keyfile", | |||
NULL); | NULL); | |||
g_debug ("writing D-Conf values to %s", filename); | g_info ("writing D-Conf values to %s", filename); | |||
if (values_size != 0 && !g_file_test (filename, G_FILE_TEST_EXISTS)) | if (values_size != 0 && !g_file_test (filename, G_FILE_TEST_EXISTS)) | |||
{ | { | |||
g_autofree char *dir = g_path_get_dirname (filename); | g_autofree char *dir = g_path_get_dirname (filename); | |||
if (g_mkdir_with_parents (dir, 0700) == -1) | if (g_mkdir_with_parents (dir, 0700) == -1) | |||
{ | { | |||
g_warning ("failed creating dirs for %s", filename); | g_warning ("failed creating dirs for %s", filename); | |||
return FALSE; | return FALSE; | |||
} | } | |||
skipping to change at line 3058 | skipping to change at line 3060 | |||
G_DBUS_SEND_MESSAGE_FLAG S_NONE, | G_DBUS_SEND_MESSAGE_FLAG S_NONE, | |||
30000, | 30000, | |||
NULL, | NULL, | |||
NULL, | NULL, | |||
NULL); | NULL); | |||
if (reply) | if (reply) | |||
{ | { | |||
if (g_dbus_message_to_gerror (reply, &local_error)) | if (g_dbus_message_to_gerror (reply, &local_error)) | |||
{ | { | |||
if (g_error_matches (local_error, G_DBUS_ERROR, G_DBUS_ERROR_SERVI CE_UNKNOWN)) | if (g_error_matches (local_error, G_DBUS_ERROR, G_DBUS_ERROR_SERVI CE_UNKNOWN)) | |||
g_debug ("Document portal not available, not mounting /run/flatp ak/doc"); | g_info ("Document portal not available, not mounting /run/flatpa k/doc"); | |||
else | else | |||
g_message ("Can't get document portal: %s", local_error->message ); | g_message ("Can't get document portal: %s", local_error->message ); | |||
} | } | |||
else | else | |||
{ | { | |||
static const char dst_path[] = "/run/flatpak/doc"; | static const char dst_path[] = "/run/flatpak/doc"; | |||
g_autofree char *src_path = NULL; | g_autofree char *src_path = NULL; | |||
g_variant_get (g_dbus_message_get_body (reply), | g_variant_get (g_dbus_message_get_body (reply), | |||
"(^ay)", &doc_mount_path); | "(^ay)", &doc_mount_path); | |||
skipping to change at line 3350 | skipping to change at line 3352 | |||
r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (errnum), scall, 1, *sysca ll_blocklist[i].arg); | r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (errnum), scall, 1, *sysca ll_blocklist[i].arg); | |||
else | else | |||
r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (errnum), scall, 0); | r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (errnum), scall, 0); | |||
/* EFAULT means "internal libseccomp error", but in practice we get | /* EFAULT means "internal libseccomp error", but in practice we get | |||
* this for syscall numbers added via flatpak-syscalls-private.h | * this for syscall numbers added via flatpak-syscalls-private.h | |||
* when trying to filter them on a non-native architecture, because | * when trying to filter them on a non-native architecture, because | |||
* libseccomp cannot map the syscall number to a name and back to a | * libseccomp cannot map the syscall number to a name and back to a | |||
* number for the non-native architecture. */ | * number for the non-native architecture. */ | |||
if (r == -EFAULT) | if (r == -EFAULT) | |||
flatpak_debug2 ("Unable to block syscall %d: syscall not known to libsec | g_debug ("Unable to block syscall %d: syscall not known to libseccomp?", | |||
comp?", | scall); | |||
scall); | ||||
else if (r < 0) | else if (r < 0) | |||
return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _("Failed to block syscall %d: %s"), scall, flatpak_seccomp_strerror (r)); | return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _("Failed to block syscall %d: %s"), scall, flatpak_seccomp_strerror (r)); | |||
} | } | |||
if (!multiarch) | if (!multiarch) | |||
{ | { | |||
/* modify_ldt is a historic source of interesting information leaks, | /* modify_ldt is a historic source of interesting information leaks, | |||
* so it's disabled as a hardening measure. | * so it's disabled as a hardening measure. | |||
* However, it is required to run old 16-bit applications | * However, it is required to run old 16-bit applications | |||
* as well as some Wine patches, so it's allowed in multiarch. */ | * as well as some Wine patches, so it's allowed in multiarch. */ | |||
int scall = SCMP_SYS (modify_ldt); | int scall = SCMP_SYS (modify_ldt); | |||
r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (EPERM), scall, 0); | r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (EPERM), scall, 0); | |||
/* See above for the meaning of EFAULT. */ | /* See above for the meaning of EFAULT. */ | |||
if (r == -EFAULT) | if (r == -EFAULT) | |||
flatpak_debug2 ("Unable to block syscall %d: syscall not known to libsec | g_debug ("Unable to block syscall %d: syscall not known to libseccomp?", | |||
comp?", | scall); | |||
scall); | ||||
else if (r < 0) | else if (r < 0) | |||
return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _("Failed to block syscall %d: %s"), scall, flatpak_seccomp_strerror (r)); | return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _("Failed to block syscall %d: %s"), scall, flatpak_seccomp_strerror (r)); | |||
} | } | |||
if (!devel) | if (!devel) | |||
{ | { | |||
for (i = 0; i < G_N_ELEMENTS (syscall_nondevel_blocklist); i++) | for (i = 0; i < G_N_ELEMENTS (syscall_nondevel_blocklist); i++) | |||
{ | { | |||
int scall = syscall_nondevel_blocklist[i].scall; | int scall = syscall_nondevel_blocklist[i].scall; | |||
int errnum = syscall_nondevel_blocklist[i].errnum; | int errnum = syscall_nondevel_blocklist[i].errnum; | |||
g_return_val_if_fail (errnum == EPERM || errnum == ENOSYS, FALSE); | g_return_val_if_fail (errnum == EPERM || errnum == ENOSYS, FALSE); | |||
if (syscall_nondevel_blocklist[i].arg) | if (syscall_nondevel_blocklist[i].arg) | |||
r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (errnum), scall, 1, *s yscall_nondevel_blocklist[i].arg); | r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (errnum), scall, 1, *s yscall_nondevel_blocklist[i].arg); | |||
else | else | |||
r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (errnum), scall, 0); | r = seccomp_rule_add (seccomp, SCMP_ACT_ERRNO (errnum), scall, 0); | |||
/* See above for the meaning of EFAULT. */ | /* See above for the meaning of EFAULT. */ | |||
if (r == -EFAULT) | if (r == -EFAULT) | |||
flatpak_debug2 ("Unable to block syscall %d: syscall not known to li | g_debug ("Unable to block syscall %d: syscall not known to libseccom | |||
bseccomp?", | p?", | |||
scall); | scall); | |||
else if (r < 0) | else if (r < 0) | |||
return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _("Fai led to block syscall %d: %s"), scall, flatpak_seccomp_strerror (r)); | return flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _("Fai led to block syscall %d: %s"), scall, flatpak_seccomp_strerror (r)); | |||
} | } | |||
} | } | |||
/* Socket filtering doesn't work on e.g. i386, so ignore failures here | /* Socket filtering doesn't work on e.g. i386, so ignore failures here | |||
* However, we need to user seccomp_rule_add_exact to avoid libseccomp doing | * However, we need to user seccomp_rule_add_exact to avoid libseccomp doing | |||
* something else: https://github.com/seccomp/libseccomp/issues/8 */ | * something else: https://github.com/seccomp/libseccomp/issues/8 */ | |||
last_allowed_family = -1; | last_allowed_family = -1; | |||
for (i = 0; i < G_N_ELEMENTS (socket_family_allowlist); i++) | for (i = 0; i < G_N_ELEMENTS (socket_family_allowlist); i++) | |||
skipping to change at line 3471 | skipping to change at line 3473 | |||
create = g_strconcat (sysroot, subdir, NULL); | create = g_strconcat (sysroot, subdir, NULL); | |||
else | else | |||
create = g_strdup (subdir); | create = g_strdup (subdir); | |||
flatpak_bwrap_add_args (bwrap, | flatpak_bwrap_add_args (bwrap, | |||
"--symlink", link, create, | "--symlink", link, create, | |||
NULL); | NULL); | |||
} | } | |||
else | else | |||
{ | { | |||
g_debug ("%s does not exist", | g_info ("%s does not exist", | |||
flatpak_file_get_path_cached (runtime_subdir)); | flatpak_file_get_path_cached (runtime_subdir)); | |||
} | } | |||
} | } | |||
} | } | |||
gboolean | gboolean | |||
flatpak_run_setup_base_argv (FlatpakBwrap *bwrap, | flatpak_run_setup_base_argv (FlatpakBwrap *bwrap, | |||
GFile *runtime_files, | GFile *runtime_files, | |||
GFile *app_id_dir, | GFile *app_id_dir, | |||
const char *arch, | const char *arch, | |||
FlatpakRunFlags flags, | FlatpakRunFlags flags, | |||
skipping to change at line 3644 | skipping to change at line 3646 | |||
flatpak_run_setup_usr_links (bwrap, runtime_files, NULL); | flatpak_run_setup_usr_links (bwrap, runtime_files, NULL); | |||
add_tzdata_args (bwrap, runtime_files); | add_tzdata_args (bwrap, runtime_files); | |||
pers = PER_LINUX; | pers = PER_LINUX; | |||
if ((flags & FLATPAK_RUN_FLAG_SET_PERSONALITY) && | if ((flags & FLATPAK_RUN_FLAG_SET_PERSONALITY) && | |||
flatpak_is_linux32_arch (arch)) | flatpak_is_linux32_arch (arch)) | |||
{ | { | |||
g_debug ("Setting personality linux32"); | g_info ("Setting personality linux32"); | |||
pers = PER_LINUX32; | pers = PER_LINUX32; | |||
} | } | |||
/* Always set the personallity, and clear all weird flags */ | /* Always set the personallity, and clear all weird flags */ | |||
personality (pers); | personality (pers); | |||
#ifdef ENABLE_SECCOMP | #ifdef ENABLE_SECCOMP | |||
if (!setup_seccomp (bwrap, arch, pers, flags, error)) | if (!setup_seccomp (bwrap, arch, pers, flags, error)) | |||
return FALSE; | return FALSE; | |||
#endif | #endif | |||
skipping to change at line 3798 | skipping to change at line 3800 | |||
doc_path = g_build_filename (doc_mount_path, doc_id, basename, NULL); | doc_path = g_build_filename (doc_mount_path, doc_id, basename, NULL); | |||
if (forwarding_uri) | if (forwarding_uri) | |||
{ | { | |||
g_autofree char *path = doc_path; | g_autofree char *path = doc_path; | |||
doc_path = g_filename_to_uri (path, NULL, NULL); | doc_path = g_filename_to_uri (path, NULL, NULL); | |||
/* This should never fail */ | /* This should never fail */ | |||
g_assert (doc_path != NULL); | g_assert (doc_path != NULL); | |||
} | } | |||
g_debug ("Forwarding file '%s' as '%s' to %s", args[i], doc_path, app_ id); | g_info ("Forwarding file '%s' as '%s' to %s", args[i], doc_path, app_i d); | |||
flatpak_bwrap_add_arg (bwrap, doc_path); | flatpak_bwrap_add_arg (bwrap, doc_path); | |||
} | } | |||
else | else | |||
flatpak_bwrap_add_arg (bwrap, args[i]); | flatpak_bwrap_add_arg (bwrap, args[i]); | |||
} | } | |||
return TRUE; | return TRUE; | |||
} | } | |||
FlatpakContext * | FlatpakContext * | |||
skipping to change at line 3894 | skipping to change at line 3896 | |||
{ | { | |||
g_autoptr(GFile) base_dir = g_file_new_for_path (g_get_user_cache_dir ()); | g_autoptr(GFile) base_dir = g_file_new_for_path (g_get_user_cache_dir ()); | |||
ld_so_dir = g_file_resolve_relative_path (base_dir, "flatpak/ld.so"); | ld_so_dir = g_file_resolve_relative_path (base_dir, "flatpak/ld.so"); | |||
} | } | |||
ld_so_cache = g_file_get_child (ld_so_dir, checksum); | ld_so_cache = g_file_get_child (ld_so_dir, checksum); | |||
ld_so_fd = open (flatpak_file_get_path_cached (ld_so_cache), O_RDONLY); | ld_so_fd = open (flatpak_file_get_path_cached (ld_so_cache), O_RDONLY); | |||
if (ld_so_fd >= 0) | if (ld_so_fd >= 0) | |||
return glnx_steal_fd (&ld_so_fd); | return glnx_steal_fd (&ld_so_fd); | |||
g_debug ("Regenerating ld.so.cache %s", flatpak_file_get_path_cached (ld_so_ca che)); | g_info ("Regenerating ld.so.cache %s", flatpak_file_get_path_cached (ld_so_cac he)); | |||
if (!flatpak_mkdir_p (ld_so_dir, cancellable, error)) | if (!flatpak_mkdir_p (ld_so_dir, cancellable, error)) | |||
return FALSE; | return FALSE; | |||
minimal_envp = flatpak_run_get_minimal_env (FALSE, FALSE); | minimal_envp = flatpak_run_get_minimal_env (FALSE, FALSE); | |||
bwrap = flatpak_bwrap_new (minimal_envp); | bwrap = flatpak_bwrap_new (minimal_envp); | |||
flatpak_bwrap_append_args (bwrap, base_argv_array); | flatpak_bwrap_append_args (bwrap, base_argv_array); | |||
flatpak_run_setup_usr_links (bwrap, runtime_files, NULL); | flatpak_run_setup_usr_links (bwrap, runtime_files, NULL); | |||
skipping to change at line 3942 | skipping to change at line 3944 | |||
if (!flatpak_bwrap_bundle_args (bwrap, 1, -1, FALSE, error)) | if (!flatpak_bwrap_bundle_args (bwrap, 1, -1, FALSE, error)) | |||
return -1; | return -1; | |||
flatpak_bwrap_add_args (bwrap, | flatpak_bwrap_add_args (bwrap, | |||
"ldconfig", "-X", "-C", sandbox_cache_path, NULL); | "ldconfig", "-X", "-C", sandbox_cache_path, NULL); | |||
flatpak_bwrap_finish (bwrap); | flatpak_bwrap_finish (bwrap); | |||
commandline = flatpak_quote_argv ((const char **) bwrap->argv->pdata, -1); | commandline = flatpak_quote_argv ((const char **) bwrap->argv->pdata, -1); | |||
g_debug ("Running: '%s'", commandline); | g_info ("Running: '%s'", commandline); | |||
combined_fd_array = g_array_new (FALSE, TRUE, sizeof (int)); | combined_fd_array = g_array_new (FALSE, TRUE, sizeof (int)); | |||
g_array_append_vals (combined_fd_array, base_fd_array->data, base_fd_array->le n); | g_array_append_vals (combined_fd_array, base_fd_array->data, base_fd_array->le n); | |||
g_array_append_vals (combined_fd_array, bwrap->fds->data, bwrap->fds->len); | g_array_append_vals (combined_fd_array, bwrap->fds->data, bwrap->fds->len); | |||
/* We use LEAVE_DESCRIPTORS_OPEN to work around dead-lock, see flatpak_close_f ds_workaround */ | /* We use LEAVE_DESCRIPTORS_OPEN to work around dead-lock, see flatpak_close_f ds_workaround */ | |||
if (!g_spawn_sync (NULL, | if (!g_spawn_sync (NULL, | |||
(char **) bwrap->argv->pdata, | (char **) bwrap->argv->pdata, | |||
bwrap->envp, | bwrap->envp, | |||
G_SPAWN_SEARCH_PATH | G_SPAWN_LEAVE_DESCRIPTORS_OPEN, | G_SPAWN_SEARCH_PATH | G_SPAWN_LEAVE_DESCRIPTORS_OPEN, | |||
skipping to change at line 4025 | skipping to change at line 4027 | |||
system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, error); | system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, error); | |||
if (system_bus == NULL) | if (system_bus == NULL) | |||
return FALSE; | return FALSE; | |||
manager = mct_manager_new (system_bus); | manager = mct_manager_new (system_bus); | |||
app_filter = mct_manager_get_app_filter (manager, getuid (), | app_filter = mct_manager_get_app_filter (manager, getuid (), | |||
MCT_GET_APP_FILTER_FLAGS_INTERACTIVE, | MCT_GET_APP_FILTER_FLAGS_INTERACTIVE, | |||
cancellable, &local_error); | cancellable, &local_error); | |||
if (g_error_matches (local_error, MCT_APP_FILTER_ERROR, MCT_APP_FILTER_ERROR_D ISABLED)) | if (g_error_matches (local_error, MCT_APP_FILTER_ERROR, MCT_APP_FILTER_ERROR_D ISABLED)) | |||
{ | { | |||
g_debug ("Skipping parental controls check for %s since parental " | g_info ("Skipping parental controls check for %s since parental " | |||
"controls are disabled globally", flatpak_decomposed_get_ref (app | "controls are disabled globally", flatpak_decomposed_get_ref (app_ | |||
_ref)); | ref)); | |||
return TRUE; | return TRUE; | |||
} | } | |||
else if (g_error_matches (local_error, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKN OWN) || | else if (g_error_matches (local_error, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKN OWN) || | |||
g_error_matches (local_error, G_DBUS_ERROR, G_DBUS_ERROR_NAME_HAS_NO_ OWNER)) | g_error_matches (local_error, G_DBUS_ERROR, G_DBUS_ERROR_NAME_HAS_NO_ OWNER)) | |||
{ | { | |||
g_debug ("Skipping parental controls check for %s since a required " | g_info ("Skipping parental controls check for %s since a required " | |||
"service was not found", flatpak_decomposed_get_ref (app_ref)); | "service was not found", flatpak_decomposed_get_ref (app_ref)); | |||
return TRUE; | return TRUE; | |||
} | } | |||
else if (local_error != NULL) | else if (local_error != NULL) | |||
{ | { | |||
g_propagate_error (error, g_steal_pointer (&local_error)); | g_propagate_error (error, g_steal_pointer (&local_error)); | |||
return FALSE; | return FALSE; | |||
} | } | |||
/* Always filter by app ID. Additionally, filter by app info (which runs | /* Always filter by app ID. Additionally, filter by app info (which runs | |||
* multiple checks, including whether the app ID, executable path and | * multiple checks, including whether the app ID, executable path and | |||
skipping to change at line 4719 | skipping to change at line 4721 | |||
doc_mount_path, | doc_mount_path, | |||
args, n_args, error)) | args, n_args, error)) | |||
return FALSE; | return FALSE; | |||
/* Hold onto the lock until we execute bwrap */ | /* Hold onto the lock until we execute bwrap */ | |||
flatpak_bwrap_add_noinherit_fd (bwrap, glnx_steal_fd (&per_app_dir_lock_fd)); | flatpak_bwrap_add_noinherit_fd (bwrap, glnx_steal_fd (&per_app_dir_lock_fd)); | |||
flatpak_bwrap_finish (bwrap); | flatpak_bwrap_finish (bwrap); | |||
commandline = flatpak_quote_argv ((const char **) bwrap->argv->pdata, -1); | commandline = flatpak_quote_argv ((const char **) bwrap->argv->pdata, -1); | |||
g_debug ("Running '%s'", commandline); | g_info ("Running '%s'", commandline); | |||
if ((flags & (FLATPAK_RUN_FLAG_BACKGROUND)) != 0 || | if ((flags & (FLATPAK_RUN_FLAG_BACKGROUND)) != 0 || | |||
g_getenv ("FLATPAK_TEST_COVERAGE") != NULL) | g_getenv ("FLATPAK_TEST_COVERAGE") != NULL) | |||
{ | { | |||
GPid child_pid; | GPid child_pid; | |||
char pid_str[64]; | char pid_str[64]; | |||
g_autofree char *pid_path = NULL; | g_autofree char *pid_path = NULL; | |||
GSpawnFlags spawn_flags; | GSpawnFlags spawn_flags; | |||
spawn_flags = G_SPAWN_SEARCH_PATH; | spawn_flags = G_SPAWN_SEARCH_PATH; | |||
End of changes. 41 change blocks. | ||||
50 lines changed or deleted | 50 lines changed or added |