flatpak-portal.c (flatpak-1.15.1.tar.xz) | : | flatpak-portal.c (flatpak-1.15.2.tar.xz) | ||
---|---|---|---|---|
skipping to change at line 136 | skipping to change at line 136 | |||
static gboolean handle_close (PortalFlatpakUpdateMonitor * monitor, | static gboolean handle_close (PortalFlatpakUpdateMonitor * monitor, | |||
GDBusMethodInvocation * invocation); | GDBusMethodInvocation * invocation); | |||
static gboolean handle_update (PortalFlatpakUpdateMonitor * monitor, | static gboolean handle_update (PortalFlatpakUpdateMonitor * monitor, | |||
GDBusMethodInvocation * invocation, | GDBusMethodInvocation * invocation, | |||
const char * arg_window, | const char * arg_window, | |||
GVariant * arg_options); | GVariant * arg_options); | |||
static void | static void | |||
skeleton_died_cb (gpointer data) | skeleton_died_cb (gpointer data) | |||
{ | { | |||
g_debug ("skeleton finalized, exiting"); | g_info ("skeleton finalized, exiting"); | |||
g_main_loop_quit (main_loop); | g_main_loop_quit (main_loop); | |||
} | } | |||
static gboolean | static gboolean | |||
unref_skeleton_in_timeout_cb (gpointer user_data) | unref_skeleton_in_timeout_cb (gpointer user_data) | |||
{ | { | |||
static gboolean unreffed = FALSE; | static gboolean unreffed = FALSE; | |||
g_debug ("unreffing portal main ref"); | g_info ("unreffing portal main ref"); | |||
if (!unreffed) | if (!unreffed) | |||
{ | { | |||
g_object_unref (portal); | g_object_unref (portal); | |||
unreffed = TRUE; | unreffed = TRUE; | |||
} | } | |||
return G_SOURCE_REMOVE; | return G_SOURCE_REMOVE; | |||
} | } | |||
static void | static void | |||
skipping to change at line 179 | skipping to change at line 179 | |||
static guint idle_timeout_id = 0; | static guint idle_timeout_id = 0; | |||
static gboolean | static gboolean | |||
idle_timeout_cb (gpointer user_data) | idle_timeout_cb (gpointer user_data) | |||
{ | { | |||
if (name_owner_id && | if (name_owner_id && | |||
g_hash_table_size (client_pid_data_hash) == 0 && | g_hash_table_size (client_pid_data_hash) == 0 && | |||
!has_update_monitors ()) | !has_update_monitors ()) | |||
{ | { | |||
g_debug ("Idle - unowning name"); | g_info ("Idle - unowning name"); | |||
unref_skeleton_in_timeout (); | unref_skeleton_in_timeout (); | |||
} | } | |||
idle_timeout_id = 0; | idle_timeout_id = 0; | |||
return G_SOURCE_REMOVE; | return G_SOURCE_REMOVE; | |||
} | } | |||
G_LOCK_DEFINE_STATIC (idle); | G_LOCK_DEFINE_STATIC (idle); | |||
static void | static void | |||
schedule_idle_callback (void) | schedule_idle_callback (void) | |||
skipping to change at line 228 | skipping to change at line 228 | |||
} | } | |||
static void | static void | |||
child_watch_died (GPid pid, | child_watch_died (GPid pid, | |||
gint status, | gint status, | |||
gpointer user_data) | gpointer user_data) | |||
{ | { | |||
PidData *pid_data = user_data; | PidData *pid_data = user_data; | |||
g_autoptr(GVariant) signal_variant = NULL; | g_autoptr(GVariant) signal_variant = NULL; | |||
g_debug ("Client Pid %d died", pid_data->pid); | g_info ("Client Pid %d died", pid_data->pid); | |||
signal_variant = g_variant_ref_sink (g_variant_new ("(uu)", pid, status)); | signal_variant = g_variant_ref_sink (g_variant_new ("(uu)", pid, status)); | |||
g_dbus_connection_emit_signal (session_bus, | g_dbus_connection_emit_signal (session_bus, | |||
pid_data->client, | pid_data->client, | |||
FLATPAK_PORTAL_PATH, | FLATPAK_PORTAL_PATH, | |||
FLATPAK_PORTAL_INTERFACE, | FLATPAK_PORTAL_INTERFACE, | |||
"SpawnExited", | "SpawnExited", | |||
signal_variant, | signal_variant, | |||
NULL); | NULL); | |||
skipping to change at line 389 | skipping to change at line 389 | |||
{ | { | |||
gint timeout; | gint timeout; | |||
gboolean readd_timer = FALSE; | gboolean readd_timer = FALSE; | |||
if (data->attempt >= CHILD_STATUS_CHECK_ATTEMPTS) | if (data->attempt >= CHILD_STATUS_CHECK_ATTEMPTS) | |||
/* If too many attempts, use a 1 second timeout */ | /* If too many attempts, use a 1 second timeout */ | |||
timeout = 1000; | timeout = 1000; | |||
else | else | |||
timeout = timeouts[MIN (data->attempt, G_N_ELEMENTS (timeouts) - 1)]; | timeout = timeouts[MIN (data->attempt, G_N_ELEMENTS (timeouts) - 1)]; | |||
g_debug ("Failed to read child PID, trying again in %d ms", timeout); | g_info ("Failed to read child PID, trying again in %d ms", timeout); | |||
/* The timer source only needs to be re-added if the timeout has changed, | /* The timer source only needs to be re-added if the timeout has changed, | |||
which won't happen while staying on the 100 or 1000ms timeouts. | which won't happen while staying on the 100 or 1000ms timeouts. | |||
This test must happen *before* the attempt counter is incremented, sin ce the | This test must happen *before* the attempt counter is incremented, sin ce the | |||
attempt counter represents the *current* timeout. */ | attempt counter represents the *current* timeout. */ | |||
readd_timer = data->attempt <= G_N_ELEMENTS (timeouts) || data->attempt == CHILD_STATUS_CHECK_ATTEMPTS; | readd_timer = data->attempt <= G_N_ELEMENTS (timeouts) || data->attempt == CHILD_STATUS_CHECK_ATTEMPTS; | |||
data->attempt++; | data->attempt++; | |||
/* Make sure the data isn't destroyed */ | /* Make sure the data isn't destroyed */ | |||
skipping to change at line 420 | skipping to change at line 420 | |||
/* Only send the child PID if it's exposed */ | /* Only send the child PID if it's exposed */ | |||
if (pid_data->expose_or_share_pids) | if (pid_data->expose_or_share_pids) | |||
{ | { | |||
g_autoptr(GError) error = NULL; | g_autoptr(GError) error = NULL; | |||
relative_child_pid = get_child_pid_relative_to_parent_sandbox (child_pid, &error); | relative_child_pid = get_child_pid_relative_to_parent_sandbox (child_pid, &error); | |||
if (relative_child_pid == 0) | if (relative_child_pid == 0) | |||
g_warning ("Failed to find relative PID for %d: %s", child_pid, error->m essage); | g_warning ("Failed to find relative PID for %d: %s", child_pid, error->m essage); | |||
} | } | |||
g_debug ("Emitting SpawnStarted(%u, %d)", pid, relative_child_pid); | g_info ("Emitting SpawnStarted(%u, %d)", pid, relative_child_pid); | |||
signal_variant = g_variant_ref_sink (g_variant_new ("(uu)", pid, relative_chil d_pid)); | signal_variant = g_variant_ref_sink (g_variant_new ("(uu)", pid, relative_chil d_pid)); | |||
g_dbus_connection_emit_signal (session_bus, | g_dbus_connection_emit_signal (session_bus, | |||
pid_data->client, | pid_data->client, | |||
FLATPAK_PORTAL_PATH, | FLATPAK_PORTAL_PATH, | |||
FLATPAK_PORTAL_INTERFACE, | FLATPAK_PORTAL_INTERFACE, | |||
"SpawnStarted", | "SpawnStarted", | |||
signal_variant, | signal_variant, | |||
NULL); | NULL); | |||
skipping to change at line 544 | skipping to change at line 544 | |||
if (data->set_tty) | if (data->set_tty) | |||
{ | { | |||
/* data->tty is our from fd which is closed at this point. | /* data->tty is our from fd which is closed at this point. | |||
* so locate the destination fd and use it for the ioctl. | * so locate the destination fd and use it for the ioctl. | |||
*/ | */ | |||
for (i = 0; i < data->fd_map_len; i++) | for (i = 0; i < data->fd_map_len; i++) | |||
{ | { | |||
if (fd_map[i].from == data->tty) | if (fd_map[i].from == data->tty) | |||
{ | { | |||
if (ioctl (fd_map[i].final, TIOCSCTTY, 0) == -1) | if (ioctl (fd_map[i].final, TIOCSCTTY, 0) == -1) | |||
g_debug ("ioctl(%d, TIOCSCTTY, 0) failed: %s", | g_info ("ioctl(%d, TIOCSCTTY, 0) failed: %s", | |||
fd_map[i].final, strerror (errno)); | fd_map[i].final, strerror (errno)); | |||
break; | break; | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
static gboolean | static gboolean | |||
is_valid_expose (const char *expose, | is_valid_expose (const char *expose, | |||
GError **error) | GError **error) | |||
{ | { | |||
skipping to change at line 813 | skipping to change at line 813 | |||
fds = g_unix_fd_list_peek_fds (fd_list, &fds_len); | fds = g_unix_fd_list_peek_fds (fd_list, &fds_len); | |||
app_info = g_object_get_data (G_OBJECT (invocation), "app-info"); | app_info = g_object_get_data (G_OBJECT (invocation), "app-info"); | |||
g_assert (app_info != NULL); | g_assert (app_info != NULL); | |||
app_id = g_key_file_get_string (app_info, | app_id = g_key_file_get_string (app_info, | |||
FLATPAK_METADATA_GROUP_APPLICATION, | FLATPAK_METADATA_GROUP_APPLICATION, | |||
FLATPAK_METADATA_KEY_NAME, NULL); | FLATPAK_METADATA_KEY_NAME, NULL); | |||
g_assert (app_id != NULL); | g_assert (app_id != NULL); | |||
g_debug ("spawn() called from app: '%s'", app_id); | g_info ("spawn() called from app: '%s'", app_id); | |||
if (*app_id == 0 && g_getenv ("FLATPAK_PORTAL_MOCK_FLATPAK") != NULL) | if (*app_id == 0 && g_getenv ("FLATPAK_PORTAL_MOCK_FLATPAK") != NULL) | |||
{ | { | |||
/* Pretend we had been called from an app for test purposes */ | /* Pretend we had been called from an app for test purposes */ | |||
testing = TRUE; | testing = TRUE; | |||
g_debug ("In unit tests, behaving as though app ID was com.example.App"); | g_info ("In unit tests, behaving as though app ID was com.example.App"); | |||
g_clear_pointer (&app_id, g_free); | g_clear_pointer (&app_id, g_free); | |||
app_id = g_strdup ("com.example.App"); | app_id = g_strdup ("com.example.App"); | |||
} | } | |||
if (*app_id == 0) | if (*app_id == 0) | |||
{ | { | |||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, | g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, | |||
G_DBUS_ERROR_INVALID_ARGS, | G_DBUS_ERROR_INVALID_ARGS, | |||
FLATPAK_PORTAL_INTERFACE ".Spawn on ly works in a flatpak"); | FLATPAK_PORTAL_INTERFACE ".Spawn on ly works in a flatpak"); | |||
return G_DBUS_METHOD_INVOCATION_HANDLED; | return G_DBUS_METHOD_INVOCATION_HANDLED; | |||
skipping to change at line 924 | skipping to change at line 924 | |||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, | g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, | |||
G_DBUS_ERROR_INVALID_ARGS, | G_DBUS_ERROR_INVALID_ARGS, | |||
"Invalid sandbox expose, caller has no instance path"); | "Invalid sandbox expose, caller has no instance path"); | |||
return G_DBUS_METHOD_INVOCATION_HANDLED; | return G_DBUS_METHOD_INVOCATION_HANDLED; | |||
} | } | |||
for (i = 0; sandbox_expose != NULL && sandbox_expose[i] != NULL; i++) | for (i = 0; sandbox_expose != NULL && sandbox_expose[i] != NULL; i++) | |||
{ | { | |||
const char *expose = sandbox_expose[i]; | const char *expose = sandbox_expose[i]; | |||
g_debug ("exposing %s", expose); | g_info ("exposing %s", expose); | |||
if (!is_valid_expose (expose, &error)) | if (!is_valid_expose (expose, &error)) | |||
{ | { | |||
g_dbus_method_invocation_return_gerror (invocation, error); | g_dbus_method_invocation_return_gerror (invocation, error); | |||
return G_DBUS_METHOD_INVOCATION_HANDLED; | return G_DBUS_METHOD_INVOCATION_HANDLED; | |||
} | } | |||
} | } | |||
for (i = 0; sandbox_expose_ro != NULL && sandbox_expose_ro[i] != NULL; i++) | for (i = 0; sandbox_expose_ro != NULL && sandbox_expose_ro[i] != NULL; i++) | |||
{ | { | |||
const char *expose = sandbox_expose_ro[i]; | const char *expose = sandbox_expose_ro[i]; | |||
g_debug ("exposing %s", expose); | g_info ("exposing %s", expose); | |||
if (!is_valid_expose (expose, &error)) | if (!is_valid_expose (expose, &error)) | |||
{ | { | |||
g_dbus_method_invocation_return_gerror (invocation, error); | g_dbus_method_invocation_return_gerror (invocation, error); | |||
return G_DBUS_METHOD_INVOCATION_HANDLED; | return G_DBUS_METHOD_INVOCATION_HANDLED; | |||
} | } | |||
} | } | |||
g_debug ("Running spawn command %s", arg_argv[0]); | g_info ("Running spawn command %s", arg_argv[0]); | |||
n_fds = 0; | n_fds = 0; | |||
if (fds != NULL) | if (fds != NULL) | |||
n_fds = g_variant_n_children (arg_fds); | n_fds = g_variant_n_children (arg_fds); | |||
fd_map = g_array_sized_new (FALSE, FALSE, sizeof (FdMapEntry), n_fds); | fd_map = g_array_sized_new (FALSE, FALSE, sizeof (FdMapEntry), n_fds); | |||
max_fd = -1; | max_fd = -1; | |||
for (i = 0; i < n_fds; i++) | for (i = 0; i < n_fds; i++) | |||
{ | { | |||
skipping to change at line 1258 | skipping to change at line 1258 | |||
g_ptr_array_add (flatpak_argv, | g_ptr_array_add (flatpak_argv, | |||
filesystem_sandbox_arg (instance_path, sandbox_expose[i ], FALSE)); | filesystem_sandbox_arg (instance_path, sandbox_expose[i ], FALSE)); | |||
for (i = 0; sandbox_expose_ro != NULL && sandbox_expose_ro[i] != NULL; i++ ) | for (i = 0; sandbox_expose_ro != NULL && sandbox_expose_ro[i] != NULL; i++ ) | |||
g_ptr_array_add (flatpak_argv, | g_ptr_array_add (flatpak_argv, | |||
filesystem_sandbox_arg (instance_path, sandbox_expose_r o[i], TRUE)); | filesystem_sandbox_arg (instance_path, sandbox_expose_r o[i], TRUE)); | |||
} | } | |||
for (i = 0; sandbox_expose_ro != NULL && sandbox_expose_ro[i] != NULL; i++) | for (i = 0; sandbox_expose_ro != NULL && sandbox_expose_ro[i] != NULL; i++) | |||
{ | { | |||
const char *expose = sandbox_expose_ro[i]; | const char *expose = sandbox_expose_ro[i]; | |||
g_debug ("exposing %s", expose); | g_info ("exposing %s", expose); | |||
} | } | |||
if (sandbox_expose_fd != NULL) | if (sandbox_expose_fd != NULL) | |||
{ | { | |||
gsize len = g_variant_n_children (sandbox_expose_fd); | gsize len = g_variant_n_children (sandbox_expose_fd); | |||
for (i = 0; i < len; i++) | for (i = 0; i < len; i++) | |||
{ | { | |||
gint32 handle; | gint32 handle; | |||
g_variant_get_child (sandbox_expose_fd, i, "h", &handle); | g_variant_get_child (sandbox_expose_fd, i, "h", &handle); | |||
if (handle >= 0 && handle < fds_len) | if (handle >= 0 && handle < fds_len) | |||
skipping to change at line 1282 | skipping to change at line 1282 | |||
gboolean writable = FALSE; | gboolean writable = FALSE; | |||
path = get_path_for_fd (handle_fd, &writable, &error); | path = get_path_for_fd (handle_fd, &writable, &error); | |||
if (path) | if (path) | |||
{ | { | |||
g_ptr_array_add (flatpak_argv, filesystem_arg (path, !writable )); | g_ptr_array_add (flatpak_argv, filesystem_arg (path, !writable )); | |||
} | } | |||
else | else | |||
{ | { | |||
g_debug ("unable to get path for sandbox-exposed fd %d, ignori | g_info ("unable to get path for sandbox-exposed fd %d, ignorin | |||
ng: %s", | g: %s", | |||
handle_fd, error->message); | handle_fd, error->message); | |||
g_clear_error (&error); | g_clear_error (&error); | |||
} | } | |||
} | } | |||
else | else | |||
{ | { | |||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, | g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, | |||
G_DBUS_ERROR_INVALID_ARGS, | G_DBUS_ERROR_INVALID_ARGS, | |||
"No file descriptor for han dle %d", | "No file descriptor for han dle %d", | |||
handle); | handle); | |||
return G_DBUS_METHOD_INVOCATION_HANDLED; | return G_DBUS_METHOD_INVOCATION_HANDLED; | |||
skipping to change at line 1319 | skipping to change at line 1319 | |||
gboolean writable = FALSE; | gboolean writable = FALSE; | |||
path = get_path_for_fd (handle_fd, &writable, &error); | path = get_path_for_fd (handle_fd, &writable, &error); | |||
if (path) | if (path) | |||
{ | { | |||
g_ptr_array_add (flatpak_argv, filesystem_arg (path, TRUE)); | g_ptr_array_add (flatpak_argv, filesystem_arg (path, TRUE)); | |||
} | } | |||
else | else | |||
{ | { | |||
g_debug ("unable to get path for sandbox-exposed fd %d, ignori | g_info ("unable to get path for sandbox-exposed fd %d, ignorin | |||
ng: %s", | g: %s", | |||
handle_fd, error->message); | handle_fd, error->message); | |||
g_clear_error (&error); | g_clear_error (&error); | |||
} | } | |||
} | } | |||
else | else | |||
{ | { | |||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, | g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, | |||
G_DBUS_ERROR_INVALID_ARGS, | G_DBUS_ERROR_INVALID_ARGS, | |||
"No file descriptor for han dle %d", | "No file descriptor for han dle %d", | |||
handle); | handle); | |||
return G_DBUS_METHOD_INVOCATION_HANDLED; | return G_DBUS_METHOD_INVOCATION_HANDLED; | |||
skipping to change at line 1370 | skipping to change at line 1370 | |||
path = get_path_for_fd (fds[handle], NULL, &error); | path = get_path_for_fd (fds[handle], NULL, &error); | |||
if (path == NULL) | if (path == NULL) | |||
{ | { | |||
g_prefix_error (&error, "Unable to convert /app fd %d into path: ", | g_prefix_error (&error, "Unable to convert /app fd %d into path: ", | |||
fds[handle]); | fds[handle]); | |||
g_dbus_method_invocation_return_gerror (invocation, error); | g_dbus_method_invocation_return_gerror (invocation, error); | |||
return G_DBUS_METHOD_INVOCATION_HANDLED; | return G_DBUS_METHOD_INVOCATION_HANDLED; | |||
} | } | |||
g_debug ("Using %s as /app instead of app", path); | g_info ("Using %s as /app instead of app", path); | |||
g_ptr_array_add (flatpak_argv, g_strdup_printf ("--app-path=%s", path)); | g_ptr_array_add (flatpak_argv, g_strdup_printf ("--app-path=%s", path)); | |||
} | } | |||
else if (empty_app) | else if (empty_app) | |||
{ | { | |||
g_ptr_array_add (flatpak_argv, g_strdup ("--app-path=")); | g_ptr_array_add (flatpak_argv, g_strdup ("--app-path=")); | |||
} | } | |||
if (usr_fd != NULL) | if (usr_fd != NULL) | |||
{ | { | |||
gint32 handle = g_variant_get_handle (usr_fd); | gint32 handle = g_variant_get_handle (usr_fd); | |||
skipping to change at line 1403 | skipping to change at line 1403 | |||
path = get_path_for_fd (fds[handle], NULL, &error); | path = get_path_for_fd (fds[handle], NULL, &error); | |||
if (path == NULL) | if (path == NULL) | |||
{ | { | |||
g_prefix_error (&error, "Unable to convert /usr fd %d into path: ", | g_prefix_error (&error, "Unable to convert /usr fd %d into path: ", | |||
fds[handle]); | fds[handle]); | |||
g_dbus_method_invocation_return_gerror (invocation, error); | g_dbus_method_invocation_return_gerror (invocation, error); | |||
return G_DBUS_METHOD_INVOCATION_HANDLED; | return G_DBUS_METHOD_INVOCATION_HANDLED; | |||
} | } | |||
g_debug ("Using %s as /usr instead of runtime", path); | g_info ("Using %s as /usr instead of runtime", path); | |||
g_ptr_array_add (flatpak_argv, g_strdup_printf ("--usr-path=%s", path)); | g_ptr_array_add (flatpak_argv, g_strdup_printf ("--usr-path=%s", path)); | |||
} | } | |||
g_ptr_array_add (flatpak_argv, g_strdup_printf ("--runtime=%s", runtime_parts[ 1])); | g_ptr_array_add (flatpak_argv, g_strdup_printf ("--runtime=%s", runtime_parts[ 1])); | |||
g_ptr_array_add (flatpak_argv, g_strdup_printf ("--runtime-version=%s", runtim e_parts[3])); | g_ptr_array_add (flatpak_argv, g_strdup_printf ("--runtime-version=%s", runtim e_parts[3])); | |||
if ((arg_flags & FLATPAK_SPAWN_FLAGS_LATEST_VERSION) == 0) | if ((arg_flags & FLATPAK_SPAWN_FLAGS_LATEST_VERSION) == 0) | |||
{ | { | |||
if (app_commit) | if (app_commit) | |||
g_ptr_array_add (flatpak_argv, g_strdup_printf ("--commit=%s", app_commi t)); | g_ptr_array_add (flatpak_argv, g_strdup_printf ("--commit=%s", app_commi t)); | |||
skipping to change at line 1440 | skipping to change at line 1440 | |||
{ | { | |||
g_autoptr(GString) cmd = g_string_new (""); | g_autoptr(GString) cmd = g_string_new (""); | |||
for (i = 0; flatpak_argv->pdata[i] != NULL; i++) | for (i = 0; flatpak_argv->pdata[i] != NULL; i++) | |||
{ | { | |||
if (i > 0) | if (i > 0) | |||
g_string_append (cmd, " "); | g_string_append (cmd, " "); | |||
g_string_append (cmd, flatpak_argv->pdata[i]); | g_string_append (cmd, flatpak_argv->pdata[i]); | |||
} | } | |||
g_debug ("Starting: %s\n", cmd->str); | g_info ("Starting: %s\n", cmd->str); | |||
} | } | |||
/* We make a second pass over the fds to find if any "to" fd index | /* We make a second pass over the fds to find if any "to" fd index | |||
overlaps an already in use fd (i.e. one in the "from" category | overlaps an already in use fd (i.e. one in the "from" category | |||
that are allocated randomly). If a fd overlaps "to" fd then its | that are allocated randomly). If a fd overlaps "to" fd then its | |||
a caller issue and not our fault, so we ignore that. */ | a caller issue and not our fault, so we ignore that. */ | |||
for (i = 0; i < fd_map->len; i++) | for (i = 0; i < fd_map->len; i++) | |||
{ | { | |||
int to_fd = g_array_index (fd_map, FdMapEntry, i).to; | int to_fd = g_array_index (fd_map, FdMapEntry, i).to; | |||
gboolean conflict = FALSE; | gboolean conflict = FALSE; | |||
skipping to change at line 1511 | skipping to change at line 1511 | |||
pid_data->pid = pid; | pid_data->pid = pid; | |||
pid_data->client = g_strdup (g_dbus_method_invocation_get_sender (invocation)) ; | pid_data->client = g_strdup (g_dbus_method_invocation_get_sender (invocation)) ; | |||
pid_data->watch_bus = (arg_flags & FLATPAK_SPAWN_FLAGS_WATCH_BUS) != 0; | pid_data->watch_bus = (arg_flags & FLATPAK_SPAWN_FLAGS_WATCH_BUS) != 0; | |||
pid_data->expose_or_share_pids = (expose_pids || share_pids); | pid_data->expose_or_share_pids = (expose_pids || share_pids); | |||
pid_data->child_watch = g_child_watch_add_full (G_PRIORITY_DEFAULT, | pid_data->child_watch = g_child_watch_add_full (G_PRIORITY_DEFAULT, | |||
pid, | pid, | |||
child_watch_died, | child_watch_died, | |||
pid_data, | pid_data, | |||
NULL); | NULL); | |||
g_debug ("Client Pid is %d", pid_data->pid); | g_info ("Client Pid is %d", pid_data->pid); | |||
g_hash_table_replace (client_pid_data_hash, GUINT_TO_POINTER (pid_data->pid), | g_hash_table_replace (client_pid_data_hash, GUINT_TO_POINTER (pid_data->pid), | |||
pid_data); | pid_data); | |||
portal_flatpak_complete_spawn (object, invocation, NULL, pid); | portal_flatpak_complete_spawn (object, invocation, NULL, pid); | |||
return G_DBUS_METHOD_INVOCATION_HANDLED; | return G_DBUS_METHOD_INVOCATION_HANDLED; | |||
} | } | |||
static gboolean | static gboolean | |||
handle_spawn_signal (PortalFlatpak *object, | handle_spawn_signal (PortalFlatpak *object, | |||
GDBusMethodInvocation *invocation, | GDBusMethodInvocation *invocation, | |||
guint arg_pid, | guint arg_pid, | |||
guint arg_signal, | guint arg_signal, | |||
gboolean arg_to_process_group) | gboolean arg_to_process_group) | |||
{ | { | |||
PidData *pid_data = NULL; | PidData *pid_data = NULL; | |||
g_debug ("spawn_signal(%d %d)", arg_pid, arg_signal); | g_info ("spawn_signal(%d %d)", arg_pid, arg_signal); | |||
pid_data = g_hash_table_lookup (client_pid_data_hash, GUINT_TO_POINTER (arg_pi d)); | pid_data = g_hash_table_lookup (client_pid_data_hash, GUINT_TO_POINTER (arg_pi d)); | |||
if (pid_data == NULL || | if (pid_data == NULL || | |||
strcmp (pid_data->client, g_dbus_method_invocation_get_sender (invocation) ) != 0) | strcmp (pid_data->client, g_dbus_method_invocation_get_sender (invocation) ) != 0) | |||
{ | { | |||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, | g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, | |||
G_DBUS_ERROR_UNIX_PROCESS_ID_UNKNOW N, | G_DBUS_ERROR_UNIX_PROCESS_ID_UNKNOW N, | |||
"No such pid"); | "No such pid"); | |||
return G_DBUS_METHOD_INVOCATION_HANDLED; | return G_DBUS_METHOD_INVOCATION_HANDLED; | |||
} | } | |||
g_debug ("Sending signal %d to client pid %d", arg_signal, arg_pid); | g_info ("Sending signal %d to client pid %d", arg_signal, arg_pid); | |||
if (arg_to_process_group) | if (arg_to_process_group) | |||
killpg (pid_data->pid, arg_signal); | killpg (pid_data->pid, arg_signal); | |||
else | else | |||
kill (pid_data->pid, arg_signal); | kill (pid_data->pid, arg_signal); | |||
portal_flatpak_complete_spawn_signal (portal, invocation); | portal_flatpak_complete_spawn_signal (portal, invocation); | |||
return G_DBUS_METHOD_INVOCATION_HANDLED; | return G_DBUS_METHOD_INVOCATION_HANDLED; | |||
} | } | |||
skipping to change at line 1740 | skipping to change at line 1740 | |||
"app-path", NULL); | "app-path", NULL); | |||
m->reported_local_commit = g_strdup (m->commit); | m->reported_local_commit = g_strdup (m->commit); | |||
m->reported_remote_commit = g_strdup (m->commit); | m->reported_remote_commit = g_strdup (m->commit); | |||
monitor = portal_flatpak_update_monitor_skeleton_new (); | monitor = portal_flatpak_update_monitor_skeleton_new (); | |||
g_object_set_data_full (G_OBJECT (monitor), "update-monitor-data", m, update_m onitor_data_free); | g_object_set_data_full (G_OBJECT (monitor), "update-monitor-data", m, update_m onitor_data_free); | |||
g_object_set_data_full (G_OBJECT (monitor), "required-sender", g_strdup (m->se nder), g_free); | g_object_set_data_full (G_OBJECT (monitor), "required-sender", g_strdup (m->se nder), g_free); | |||
g_debug ("created UpdateMonitor for %s/%s at %s", m->name, m->branch, obj_path ); | g_info ("created UpdateMonitor for %s/%s at %s", m->name, m->branch, obj_path) ; | |||
return monitor; | return monitor; | |||
} | } | |||
static void | static void | |||
update_monitor_do_close (PortalFlatpakUpdateMonitor *monitor) | update_monitor_do_close (PortalFlatpakUpdateMonitor *monitor) | |||
{ | { | |||
UpdateMonitorData *m = update_monitor_get_data (monitor); | UpdateMonitorData *m = update_monitor_get_data (monitor); | |||
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (monitor)); | g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (monitor)); | |||
skipping to change at line 1847 | skipping to change at line 1847 | |||
g_autoptr(FlatpakRemoteRef) remote_ref = NULL; | g_autoptr(FlatpakRemoteRef) remote_ref = NULL; | |||
const char *origin = NULL; | const char *origin = NULL; | |||
const char *local_commit = NULL; | const char *local_commit = NULL; | |||
const char *remote_commit; | const char *remote_commit; | |||
g_autoptr(GError) error = NULL; | g_autoptr(GError) error = NULL; | |||
g_autoptr(FlatpakDir) dir = NULL; | g_autoptr(FlatpakDir) dir = NULL; | |||
const char *ref; | const char *ref; | |||
installation_path = update_monitor_get_installation_path (monitor); | installation_path = update_monitor_get_installation_path (monitor); | |||
g_debug ("Checking for updates for %s/%s/%s in %s", m->name, m->arch, m->branc h, flatpak_file_get_path_cached (installation_path)); | g_info ("Checking for updates for %s/%s/%s in %s", m->name, m->arch, m->branch , flatpak_file_get_path_cached (installation_path)); | |||
installation = lookup_installation_for_path (installation_path, &error); | installation = lookup_installation_for_path (installation_path, &error); | |||
if (installation == NULL) | if (installation == NULL) | |||
{ | { | |||
g_debug ("Unable to find installation for path %s: %s", flatpak_file_get_p ath_cached (installation_path), error->message); | g_info ("Unable to find installation for path %s: %s", flatpak_file_get_pa th_cached (installation_path), error->message); | |||
return; | return; | |||
} | } | |||
installed_ref = flatpak_installation_get_installed_ref (installation, | installed_ref = flatpak_installation_get_installed_ref (installation, | |||
FLATPAK_REF_KIND_APP, | FLATPAK_REF_KIND_APP, | |||
m->name, m->arch, m->b ranch, | m->name, m->arch, m->b ranch, | |||
m->cancellable, &error ); | m->cancellable, &error ); | |||
if (installed_ref == NULL) | if (installed_ref == NULL) | |||
{ | { | |||
g_debug ("getting installed ref failed: %s", error->message); | g_info ("getting installed ref failed: %s", error->message); | |||
return; /* Never report updates for uninstalled refs */ | return; /* Never report updates for uninstalled refs */ | |||
} | } | |||
dir = flatpak_installation_get_dir (installation, NULL); | dir = flatpak_installation_get_dir (installation, NULL); | |||
if (dir == NULL) | if (dir == NULL) | |||
return; | return; | |||
ref = flatpak_ref_format_ref_cached (FLATPAK_REF (installed_ref)); | ref = flatpak_ref_format_ref_cached (FLATPAK_REF (installed_ref)); | |||
if (flatpak_dir_ref_is_masked (dir, ref)) | if (flatpak_dir_ref_is_masked (dir, ref)) | |||
return; /* Never report updates for masked refs */ | return; /* Never report updates for masked refs */ | |||
skipping to change at line 1887 | skipping to change at line 1887 | |||
remote_ref = flatpak_installation_fetch_remote_ref_sync (installation, origin, | remote_ref = flatpak_installation_fetch_remote_ref_sync (installation, origin, | |||
FLATPAK_REF_KIND_APP, | FLATPAK_REF_KIND_APP, | |||
m->name, m->arch, m-> branch, | m->name, m->arch, m-> branch, | |||
m->cancellable, &erro r); | m->cancellable, &erro r); | |||
if (remote_ref == NULL) | if (remote_ref == NULL) | |||
{ | { | |||
/* Probably some network issue. | /* Probably some network issue. | |||
* Fall back to the local_commit to at least be able to pick up already in stalled updates. | * Fall back to the local_commit to at least be able to pick up already in stalled updates. | |||
*/ | */ | |||
g_debug ("getting remote ref failed: %s", error->message); | g_info ("getting remote ref failed: %s", error->message); | |||
g_clear_error (&error); | g_clear_error (&error); | |||
remote_commit = local_commit; | remote_commit = local_commit; | |||
} | } | |||
else | else | |||
{ | { | |||
remote_commit = flatpak_ref_get_commit (FLATPAK_REF (remote_ref)); | remote_commit = flatpak_ref_get_commit (FLATPAK_REF (remote_ref)); | |||
if (remote_commit == NULL) | if (remote_commit == NULL) | |||
{ | { | |||
/* This can happen if we're offline and there is an update from an usb drive. | /* This can happen if we're offline and there is an update from an usb drive. | |||
* Not much we can do in terms of reporting it, but at least handle th e case | * Not much we can do in terms of reporting it, but at least handle th e case | |||
*/ | */ | |||
g_debug ("Unknown remote commit, setting to local_commit"); | g_info ("Unknown remote commit, setting to local_commit"); | |||
remote_commit = local_commit; | remote_commit = local_commit; | |||
} | } | |||
} | } | |||
if (g_strcmp0 (m->reported_local_commit, local_commit) != 0 || | if (g_strcmp0 (m->reported_local_commit, local_commit) != 0 || | |||
g_strcmp0 (m->reported_remote_commit, remote_commit) != 0) | g_strcmp0 (m->reported_remote_commit, remote_commit) != 0) | |||
{ | { | |||
GVariantBuilder builder; | GVariantBuilder builder; | |||
gboolean is_closed; | gboolean is_closed; | |||
g_free (m->reported_local_commit); | g_free (m->reported_local_commit); | |||
m->reported_local_commit = g_strdup (local_commit); | m->reported_local_commit = g_strdup (local_commit); | |||
g_free (m->reported_remote_commit); | g_free (m->reported_remote_commit); | |||
m->reported_remote_commit = g_strdup (remote_commit); | m->reported_remote_commit = g_strdup (remote_commit); | |||
g_debug ("Found update for %s/%s/%s, local: %s, remote: %s", m->name, m->a rch, m->branch, local_commit, remote_commit); | g_info ("Found update for %s/%s/%s, local: %s, remote: %s", m->name, m->ar ch, m->branch, local_commit, remote_commit); | |||
g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); | g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); | |||
g_variant_builder_add (&builder, "{sv}", "running-commit", g_variant_new_s tring (m->commit)); | g_variant_builder_add (&builder, "{sv}", "running-commit", g_variant_new_s tring (m->commit)); | |||
g_variant_builder_add (&builder, "{sv}", "local-commit", g_variant_new_str ing (local_commit)); | g_variant_builder_add (&builder, "{sv}", "local-commit", g_variant_new_str ing (local_commit)); | |||
g_variant_builder_add (&builder, "{sv}", "remote-commit", g_variant_new_st ring (remote_commit)); | g_variant_builder_add (&builder, "{sv}", "remote-commit", g_variant_new_st ring (remote_commit)); | |||
/* Maybe someone closed the monitor while we were checking for updates, th en drop the signal. | /* Maybe someone closed the monitor while we were checking for updates, th en drop the signal. | |||
* There is still a minimal race between this check and the emit where a c lient could call close() | * There is still a minimal race between this check and the emit where a c lient could call close() | |||
* and still see the signal though. */ | * and still see the signal though. */ | |||
g_mutex_lock (&m->lock); | g_mutex_lock (&m->lock); | |||
is_closed = m->closed; | is_closed = m->closed; | |||
skipping to change at line 2005 | skipping to change at line 2005 | |||
/* Runs on main thread */ | /* Runs on main thread */ | |||
static gboolean | static gboolean | |||
check_all_for_updates_cb (void *data) | check_all_for_updates_cb (void *data) | |||
{ | { | |||
g_autoptr(GTask) task = g_task_new (NULL, NULL, NULL, NULL); | g_autoptr(GTask) task = g_task_new (NULL, NULL, NULL, NULL); | |||
if (!opt_poll_when_metered && | if (!opt_poll_when_metered && | |||
g_network_monitor_get_network_metered (network_monitor)) | g_network_monitor_get_network_metered (network_monitor)) | |||
{ | { | |||
g_debug ("Skipping update check on metered network"); | g_info ("Skipping update check on metered network"); | |||
return G_SOURCE_CONTINUE; | return G_SOURCE_CONTINUE; | |||
} | } | |||
g_debug ("Checking all update monitors"); | g_info ("Checking all update monitors"); | |||
G_LOCK (update_monitors); | G_LOCK (update_monitors); | |||
update_monitors_timeout = 0; | update_monitors_timeout = 0; | |||
update_monitors_timeout_running_thread = TRUE; | update_monitors_timeout_running_thread = TRUE; | |||
G_UNLOCK (update_monitors); | G_UNLOCK (update_monitors); | |||
g_task_run_in_thread (task, check_all_for_updates_in_thread_func); | g_task_run_in_thread (task, check_all_for_updates_in_thread_func); | |||
return G_SOURCE_REMOVE; /* This will be re-added by the thread when done */ | return G_SOURCE_REMOVE; /* This will be re-added by the thread when done */ | |||
} | } | |||
skipping to change at line 2041 | skipping to change at line 2041 | |||
g_autofree char *sender_escaped = NULL; | g_autofree char *sender_escaped = NULL; | |||
g_autofree char *obj_path = NULL; | g_autofree char *obj_path = NULL; | |||
g_autofree char *token = NULL; | g_autofree char *token = NULL; | |||
g_autoptr(GError) error = NULL; | g_autoptr(GError) error = NULL; | |||
int i; | int i; | |||
if (!g_variant_lookup (options, "handle_token", "s", &token)) | if (!g_variant_lookup (options, "handle_token", "s", &token)) | |||
token = g_strdup_printf ("%d", g_random_int_range (0, 1000)); | token = g_strdup_printf ("%d", g_random_int_range (0, 1000)); | |||
sender = g_dbus_method_invocation_get_sender (invocation); | sender = g_dbus_method_invocation_get_sender (invocation); | |||
g_debug ("handle CreateUpdateMonitor from %s", sender); | g_info ("handle CreateUpdateMonitor from %s", sender); | |||
sender_escaped = g_strdup (sender + 1); | sender_escaped = g_strdup (sender + 1); | |||
for (i = 0; sender_escaped[i]; i++) | for (i = 0; sender_escaped[i]; i++) | |||
{ | { | |||
if (sender_escaped[i] == '.') | if (sender_escaped[i] == '.') | |||
sender_escaped[i] = '_'; | sender_escaped[i] = '_'; | |||
} | } | |||
obj_path = g_strdup_printf ("%s/update_monitor/%s/%s", | obj_path = g_strdup_printf ("%s/update_monitor/%s/%s", | |||
FLATPAK_PORTAL_PATH, | FLATPAK_PORTAL_PATH, | |||
skipping to change at line 2089 | skipping to change at line 2089 | |||
return G_DBUS_METHOD_INVOCATION_HANDLED; | return G_DBUS_METHOD_INVOCATION_HANDLED; | |||
} | } | |||
/* Runs in worker thread */ | /* Runs in worker thread */ | |||
static gboolean | static gboolean | |||
handle_close (PortalFlatpakUpdateMonitor *monitor, | handle_close (PortalFlatpakUpdateMonitor *monitor, | |||
GDBusMethodInvocation *invocation) | GDBusMethodInvocation *invocation) | |||
{ | { | |||
update_monitor_close (monitor); | update_monitor_close (monitor); | |||
g_debug ("handle UpdateMonitor.Close"); | g_info ("handle UpdateMonitor.Close"); | |||
portal_flatpak_update_monitor_complete_close (monitor, invocation); | portal_flatpak_update_monitor_complete_close (monitor, invocation); | |||
return G_DBUS_METHOD_INVOCATION_HANDLED; | return G_DBUS_METHOD_INVOCATION_HANDLED; | |||
} | } | |||
static void | static void | |||
deep_free_object_list (gpointer data) | deep_free_object_list (gpointer data) | |||
{ | { | |||
g_list_free_full ((GList *)data, g_object_unref); | g_list_free_full ((GList *)data, g_object_unref); | |||
skipping to change at line 2116 | skipping to change at line 2116 | |||
GCancellable *cancellable) | GCancellable *cancellable) | |||
{ | { | |||
GList *list = task_data; | GList *list = task_data; | |||
GList *l; | GList *l; | |||
for (l = list; l; l = l->next) | for (l = list; l; l = l->next) | |||
{ | { | |||
PortalFlatpakUpdateMonitor *monitor = l->data; | PortalFlatpakUpdateMonitor *monitor = l->data; | |||
UpdateMonitorData *m = update_monitor_get_data (monitor); | UpdateMonitorData *m = update_monitor_get_data (monitor); | |||
g_debug ("closing monitor %s", m->obj_path); | g_info ("closing monitor %s", m->obj_path); | |||
update_monitor_close (monitor); | update_monitor_close (monitor); | |||
} | } | |||
} | } | |||
static void | static void | |||
close_update_monitors_for_sender (const char *sender) | close_update_monitors_for_sender (const char *sender) | |||
{ | { | |||
GList *list = update_monitors_get_all (sender); | GList *list = update_monitors_get_all (sender); | |||
if (list) | if (list) | |||
{ | { | |||
g_autoptr(GTask) task = g_task_new (NULL, NULL, NULL, NULL); | g_autoptr(GTask) task = g_task_new (NULL, NULL, NULL, NULL); | |||
g_task_set_task_data (task, list, deep_free_object_list); | g_task_set_task_data (task, list, deep_free_object_list); | |||
g_debug ("%s dropped off the bus, closing monitors", sender); | g_info ("%s dropped off the bus, closing monitors", sender); | |||
g_task_run_in_thread (task, close_update_monitors_in_thread_func); | g_task_run_in_thread (task, close_update_monitors_in_thread_func); | |||
} | } | |||
} | } | |||
static guint32 | static guint32 | |||
get_update_permission (const char *app_id) | get_update_permission (const char *app_id) | |||
{ | { | |||
g_autoptr(GVariant) out_perms = NULL; | g_autoptr(GVariant) out_perms = NULL; | |||
g_autoptr(GVariant) out_data = NULL; | g_autoptr(GVariant) out_data = NULL; | |||
g_autoptr(GError) error = NULL; | g_autoptr(GError) error = NULL; | |||
guint32 ret = UNSET; | guint32 ret = UNSET; | |||
if (permission_store == NULL) | if (permission_store == NULL) | |||
{ | { | |||
g_debug ("No portals installed, assume no permissions"); | g_info ("No portals installed, assume no permissions"); | |||
return NO; | return NO; | |||
} | } | |||
if (!xdp_dbus_permission_store_call_lookup_sync (permission_store, | if (!xdp_dbus_permission_store_call_lookup_sync (permission_store, | |||
PERMISSION_TABLE, | PERMISSION_TABLE, | |||
PERMISSION_ID, | PERMISSION_ID, | |||
&out_perms, | &out_perms, | |||
&out_data, | &out_data, | |||
NULL, | NULL, | |||
&error)) | &error)) | |||
{ | { | |||
g_dbus_error_strip_remote_error (error); | g_dbus_error_strip_remote_error (error); | |||
g_debug ("No updates permissions found: %s", error->message); | g_info ("No updates permissions found: %s", error->message); | |||
g_clear_error (&error); | g_clear_error (&error); | |||
} | } | |||
if (out_perms != NULL) | if (out_perms != NULL) | |||
{ | { | |||
const char **perms; | const char **perms; | |||
if (g_variant_lookup (out_perms, app_id, "^a&s", &perms)) | if (g_variant_lookup (out_perms, app_id, "^a&s", &perms)) | |||
{ | { | |||
if (strcmp (perms[0], "ask") == 0) | if (strcmp (perms[0], "ask") == 0) | |||
ret = ASK; | ret = ASK; | |||
else if (strcmp (perms[0], "yes") == 0) | else if (strcmp (perms[0], "yes") == 0) | |||
ret = YES; | ret = YES; | |||
else | else | |||
ret = NO; | ret = NO; | |||
} | } | |||
} | } | |||
g_debug ("Updates permissions for %s: %d", app_id, ret); | g_info ("Updates permissions for %s: %d", app_id, ret); | |||
return ret; | return ret; | |||
} | } | |||
static void | static void | |||
set_update_permission (const char *app_id, | set_update_permission (const char *app_id, | |||
Permission permission) | Permission permission) | |||
{ | { | |||
g_autoptr(GError) error = NULL; | g_autoptr(GError) error = NULL; | |||
const char *permissions[2]; | const char *permissions[2]; | |||
skipping to change at line 2330 | skipping to change at line 2330 | |||
int progress, | int progress, | |||
int status, | int status, | |||
const char *error_name, | const char *error_name, | |||
const char *error_message) | const char *error_message) | |||
{ | { | |||
UpdateMonitorData *m = update_monitor_get_data (monitor); | UpdateMonitorData *m = update_monitor_get_data (monitor); | |||
GDBusConnection *connection; | GDBusConnection *connection; | |||
GVariantBuilder builder; | GVariantBuilder builder; | |||
g_autoptr(GError) error = NULL; | g_autoptr(GError) error = NULL; | |||
g_debug ("%d/%d ops, progress %d, status: %d", op, n_ops, progress, status); | g_info ("%d/%d ops, progress %d, status: %d", op, n_ops, progress, status); | |||
g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); | g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); | |||
if (n_ops > 0) | if (n_ops > 0) | |||
{ | { | |||
g_variant_builder_add (&builder, "{sv}", "op", g_variant_new_uint32 (op)); | g_variant_builder_add (&builder, "{sv}", "op", g_variant_new_uint32 (op)); | |||
g_variant_builder_add (&builder, "{sv}", "n_ops", g_variant_new_uint32 (n_ ops)); | g_variant_builder_add (&builder, "{sv}", "n_ops", g_variant_new_uint32 (n_ ops)); | |||
g_variant_builder_add (&builder, "{sv}", "progress", g_variant_new_uint32 (progress)); | g_variant_builder_add (&builder, "{sv}", "progress", g_variant_new_uint32 (progress)); | |||
} | } | |||
g_variant_builder_add (&builder, "{sv}", "status", g_variant_new_uint32 (statu s)); | g_variant_builder_add (&builder, "{sv}", "status", g_variant_new_uint32 (statu s)); | |||
skipping to change at line 2695 | skipping to change at line 2695 | |||
g_autoptr(GVariant) v = NULL; | g_autoptr(GVariant) v = NULL; | |||
guint32 op; | guint32 op; | |||
guint32 n_ops; | guint32 n_ops; | |||
guint32 progress; | guint32 progress; | |||
const char *error_name; | const char *error_name; | |||
const char *error_message; | const char *error_message; | |||
v = read_variant (in, m->cancellable, error); | v = read_variant (in, m->cancellable, error); | |||
if (v == NULL) | if (v == NULL) | |||
{ | { | |||
g_debug ("Reading message from child update process failed %s", (*erro r)->message); | g_info ("Reading message from child update process failed %s", (*error )->message); | |||
return FALSE; | return FALSE; | |||
} | } | |||
g_variant_get (v, "(uuuu&s&s)", | g_variant_get (v, "(uuuu&s&s)", | |||
&op, &n_ops, &progress, &status, &error_name, &error_messag e); | &op, &n_ops, &progress, &status, &error_name, &error_messag e); | |||
emit_progress (monitor, op, n_ops, progress, status, | emit_progress (monitor, op, n_ops, progress, status, | |||
*error_name != 0 ? error_name : NULL, | *error_name != 0 ? error_name : NULL, | |||
*error_message != 0 ? error_message : NULL); | *error_message != 0 ? error_message : NULL); | |||
} | } | |||
skipping to change at line 2777 | skipping to change at line 2777 | |||
static gboolean | static gboolean | |||
handle_update (PortalFlatpakUpdateMonitor *monitor, | handle_update (PortalFlatpakUpdateMonitor *monitor, | |||
GDBusMethodInvocation *invocation, | GDBusMethodInvocation *invocation, | |||
const char *arg_window, | const char *arg_window, | |||
GVariant *arg_options) | GVariant *arg_options) | |||
{ | { | |||
UpdateMonitorData *m = update_monitor_get_data (monitor); | UpdateMonitorData *m = update_monitor_get_data (monitor); | |||
g_autoptr(GTask) task = NULL; | g_autoptr(GTask) task = NULL; | |||
gboolean already_installing = FALSE; | gboolean already_installing = FALSE; | |||
g_debug ("handle UpdateMonitor.Update"); | g_info ("handle UpdateMonitor.Update"); | |||
g_mutex_lock (&m->lock); | g_mutex_lock (&m->lock); | |||
if (m->installing) | if (m->installing) | |||
already_installing = TRUE; | already_installing = TRUE; | |||
else | else | |||
m->installing = TRUE; | m->installing = TRUE; | |||
g_mutex_unlock (&m->lock); | g_mutex_unlock (&m->lock); | |||
if (already_installing) | if (already_installing) | |||
{ | { | |||
skipping to change at line 2838 | skipping to change at line 2838 | |||
{ | { | |||
pid_data = value; | pid_data = value; | |||
if (pid_data->watch_bus && g_str_equal (pid_data->client, name)) | if (pid_data->watch_bus && g_str_equal (pid_data->client, name)) | |||
list = g_list_prepend (list, pid_data); | list = g_list_prepend (list, pid_data); | |||
} | } | |||
for (l = list; l; l = l->next) | for (l = list; l; l = l->next) | |||
{ | { | |||
pid_data = l->data; | pid_data = l->data; | |||
g_debug ("%s dropped off the bus, killing %d", pid_data->client, pid_d ata->pid); | g_info ("%s dropped off the bus, killing %d", pid_data->client, pid_da ta->pid); | |||
killpg (pid_data->pid, SIGINT); | killpg (pid_data->pid, SIGINT); | |||
} | } | |||
g_list_free (list); | g_list_free (list); | |||
close_update_monitors_for_sender (name); | close_update_monitors_for_sender (name); | |||
} | } | |||
} | } | |||
#define DBUS_NAME_DBUS "org.freedesktop.DBus" | #define DBUS_NAME_DBUS "org.freedesktop.DBus" | |||
#define DBUS_INTERFACE_DBUS DBUS_NAME_DBUS | #define DBUS_INTERFACE_DBUS DBUS_NAME_DBUS | |||
#define DBUS_PATH_DBUS "/org/freedesktop/DBus" | #define DBUS_PATH_DBUS "/org/freedesktop/DBus" | |||
static gboolean | ||||
supports_expose_pids (void) | ||||
{ | ||||
const char *path = g_find_program_in_path (flatpak_get_bwrap ()); | ||||
struct stat st; | ||||
/* This is supported only if bwrap exists and is not setuid */ | ||||
return | ||||
path != NULL && | ||||
stat (path, &st) == 0 && | ||||
(st.st_mode & S_ISUID) == 0; | ||||
} | ||||
static void | static void | |||
on_bus_acquired (GDBusConnection *connection, | on_bus_acquired (GDBusConnection *connection, | |||
const gchar *name, | const gchar *name, | |||
gpointer user_data) | gpointer user_data) | |||
{ | { | |||
GError *error = NULL; | GError *error = NULL; | |||
g_debug ("Bus acquired, creating skeleton"); | g_info ("Bus acquired, creating skeleton"); | |||
g_dbus_connection_set_exit_on_close (connection, FALSE); | g_dbus_connection_set_exit_on_close (connection, FALSE); | |||
update_monitors = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_ob ject_unref); | update_monitors = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_ob ject_unref); | |||
permission_store = xdp_dbus_permission_store_proxy_new_sync (connection, | permission_store = xdp_dbus_permission_store_proxy_new_sync (connection, | |||
G_DBUS_PROXY_FLAG S_NONE, | G_DBUS_PROXY_FLAG S_NONE, | |||
"org.freedesktop. impl.portal.PermissionStore", | "org.freedesktop. impl.portal.PermissionStore", | |||
"/org/freedesktop /impl/portal/PermissionStore", | "/org/freedesktop /impl/portal/PermissionStore", | |||
NULL, NULL); | NULL, NULL); | |||
skipping to change at line 2925 | skipping to change at line 2912 | |||
g_warning ("error: %s", error->message); | g_warning ("error: %s", error->message); | |||
g_error_free (error); | g_error_free (error); | |||
} | } | |||
} | } | |||
static void | static void | |||
on_name_acquired (GDBusConnection *connection, | on_name_acquired (GDBusConnection *connection, | |||
const gchar *name, | const gchar *name, | |||
gpointer user_data) | gpointer user_data) | |||
{ | { | |||
g_debug ("Name acquired"); | g_info ("Name acquired"); | |||
} | } | |||
static void | static void | |||
on_name_lost (GDBusConnection *connection, | on_name_lost (GDBusConnection *connection, | |||
const gchar *name, | const gchar *name, | |||
gpointer user_data) | gpointer user_data) | |||
{ | { | |||
g_debug ("Name lost"); | g_info ("Name lost"); | |||
unref_skeleton_in_timeout (); | unref_skeleton_in_timeout (); | |||
} | } | |||
static void | static void | |||
binary_file_changed_cb (GFileMonitor *file_monitor, | binary_file_changed_cb (GFileMonitor *file_monitor, | |||
GFile *file, | GFile *file, | |||
GFile *other_file, | GFile *other_file, | |||
GFileMonitorEvent event_type, | GFileMonitorEvent event_type, | |||
gpointer data) | gpointer data) | |||
{ | { | |||
static gboolean got_it = FALSE; | static gboolean got_it = FALSE; | |||
if (!got_it) | if (!got_it) | |||
{ | { | |||
g_debug ("binary file changed"); | g_info ("binary file changed"); | |||
unref_skeleton_in_timeout (); | unref_skeleton_in_timeout (); | |||
} | } | |||
got_it = TRUE; | got_it = TRUE; | |||
} | } | |||
static void | static void | |||
message_handler (const gchar *log_domain, | message_handler (const gchar *log_domain, | |||
GLogLevelFlags log_level, | GLogLevelFlags log_level, | |||
const gchar *message, | const gchar *message, | |||
gpointer user_data) | gpointer user_data) | |||
{ | { | |||
/* Make this look like normal console output */ | /* Make this look like normal console output */ | |||
if (log_level & G_LOG_LEVEL_DEBUG) | if (log_level & (G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_INFO)) | |||
g_printerr ("F: %s\n", message); | g_printerr ("F: %s\n", message); | |||
else | else | |||
g_printerr ("%s: %s\n", g_get_prgname (), message); | g_printerr ("%s: %s\n", g_get_prgname (), message); | |||
} | } | |||
int | int | |||
main (int argc, | main (int argc, | |||
char **argv) | char **argv) | |||
{ | { | |||
gchar exe_path[PATH_MAX + 1]; | gchar exe_path[PATH_MAX + 1]; | |||
skipping to change at line 3032 | skipping to change at line 3019 | |||
if (opt_poll_timeout == 0) | if (opt_poll_timeout == 0) | |||
opt_poll_timeout = DEFAULT_UPDATE_POLL_TIMEOUT_SEC; | opt_poll_timeout = DEFAULT_UPDATE_POLL_TIMEOUT_SEC; | |||
if (show_version) | if (show_version) | |||
{ | { | |||
g_print (PACKAGE_STRING "\n"); | g_print (PACKAGE_STRING "\n"); | |||
return 0; | return 0; | |||
} | } | |||
if (opt_verbose) | if (opt_verbose) | |||
g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, message_handler, NULL); | g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, message_handler, NULL); | |||
client_pid_data_hash = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotif y) pid_data_free); | client_pid_data_hash = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotif y) pid_data_free); | |||
session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); | session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); | |||
if (session_bus == NULL) | if (session_bus == NULL) | |||
{ | { | |||
g_printerr ("Can't find bus: %s\n", error->message); | g_printerr ("Can't find bus: %s\n", error->message); | |||
return 1; | return 1; | |||
} | } | |||
skipping to change at line 3065 | skipping to change at line 3052 | |||
&local_error); | &local_error); | |||
if (monitor == NULL) | if (monitor == NULL) | |||
g_warning ("Failed to set watch on %s: %s", exe_path, error->message); | g_warning ("Failed to set watch on %s: %s", exe_path, error->message); | |||
else | else | |||
g_signal_connect (monitor, "changed", | g_signal_connect (monitor, "changed", | |||
G_CALLBACK (binary_file_changed_cb), NULL); | G_CALLBACK (binary_file_changed_cb), NULL); | |||
} | } | |||
flatpak_connection_track_name_owners (session_bus); | flatpak_connection_track_name_owners (session_bus); | |||
if (supports_expose_pids ()) | if (flatpak_bwrap_is_unprivileged ()) | |||
supports |= FLATPAK_SPAWN_SUPPORT_FLAGS_EXPOSE_PIDS; | supports |= FLATPAK_SPAWN_SUPPORT_FLAGS_EXPOSE_PIDS; | |||
flags = G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT; | flags = G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT; | |||
if (replace) | if (replace) | |||
flags |= G_BUS_NAME_OWNER_FLAGS_REPLACE; | flags |= G_BUS_NAME_OWNER_FLAGS_REPLACE; | |||
name_owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, | name_owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, | |||
FLATPAK_PORTAL_BUS_NAME, | FLATPAK_PORTAL_BUS_NAME, | |||
flags, | flags, | |||
on_bus_acquired, | on_bus_acquired, | |||
End of changes. 49 change blocks. | ||||
66 lines changed or deleted | 53 lines changed or added |