mirror of
https://github.com/flatpak/flatpak.git
synced 2026-05-03 13:36:02 -04:00
system-helper: Centralize pid-setting
There was a bunch of handle methods which forgot to do this manually, so call the flatpak_dir_set_source_pid() method right when we create the FlatpakDir object. Closes: #2384 Approved by: alexlarsson
This commit is contained in:
committed by
Atomic Bot
parent
c685f05f8a
commit
e14af35207
@@ -119,7 +119,9 @@ schedule_idle_callback (void)
|
||||
}
|
||||
|
||||
static FlatpakDir *
|
||||
dir_get_system (const char *installation, GError **error)
|
||||
dir_get_system (const char *installation,
|
||||
pid_t source_pid,
|
||||
GError **error)
|
||||
{
|
||||
FlatpakDir *system = NULL;
|
||||
|
||||
@@ -132,7 +134,9 @@ dir_get_system (const char *installation, GError **error)
|
||||
if (system == NULL)
|
||||
return NULL;
|
||||
|
||||
flatpak_dir_set_source_pid (system, source_pid);
|
||||
flatpak_dir_set_no_system_helper (system, TRUE);
|
||||
|
||||
return system;
|
||||
}
|
||||
|
||||
@@ -213,15 +217,13 @@ handle_deploy (FlatpakSystemHelper *object,
|
||||
|
||||
g_debug ("Deploy %s %u %s %s %s", arg_repo_path, arg_flags, arg_ref, arg_origin, arg_installation);
|
||||
|
||||
system = dir_get_system (arg_installation, &error);
|
||||
system = dir_get_system (arg_installation, get_sender_pid (invocation), &error);
|
||||
if (system == NULL)
|
||||
{
|
||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
flatpak_dir_set_source_pid (system, get_sender_pid (invocation));
|
||||
|
||||
if ((arg_flags & ~FLATPAK_HELPER_DEPLOY_FLAGS_ALL) != 0)
|
||||
{
|
||||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
|
||||
@@ -500,7 +502,7 @@ handle_deploy_appstream (FlatpakSystemHelper *object,
|
||||
|
||||
g_debug ("DeployAppstream %s %u %s %s %s", arg_repo_path, arg_flags, arg_origin, arg_arch, arg_installation);
|
||||
|
||||
system = dir_get_system (arg_installation, &error);
|
||||
system = dir_get_system (arg_installation, get_sender_pid (invocation), &error);
|
||||
if (system == NULL)
|
||||
{
|
||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||
@@ -674,15 +676,13 @@ handle_uninstall (FlatpakSystemHelper *object,
|
||||
|
||||
g_debug ("Uninstall %u %s %s", arg_flags, arg_ref, arg_installation);
|
||||
|
||||
system = dir_get_system (arg_installation, &error);
|
||||
system = dir_get_system (arg_installation, get_sender_pid (invocation), &error);
|
||||
if (system == NULL)
|
||||
{
|
||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
flatpak_dir_set_source_pid (system, get_sender_pid (invocation));
|
||||
|
||||
if ((arg_flags & ~FLATPAK_HELPER_UNINSTALL_FLAGS_ALL) != 0)
|
||||
{
|
||||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
|
||||
@@ -696,8 +696,6 @@ handle_uninstall (FlatpakSystemHelper *object,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
flatpak_dir_set_source_pid (system, get_sender_pid (invocation));
|
||||
|
||||
if (!flatpak_dir_uninstall (system, arg_ref, arg_flags, NULL, &error))
|
||||
{
|
||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||
@@ -724,15 +722,13 @@ handle_install_bundle (FlatpakSystemHelper *object,
|
||||
|
||||
g_debug ("InstallBundle %s %u %s %s", arg_bundle_path, arg_flags, arg_remote, arg_installation);
|
||||
|
||||
system = dir_get_system (arg_installation, &error);
|
||||
system = dir_get_system (arg_installation, get_sender_pid (invocation), &error);
|
||||
if (system == NULL)
|
||||
{
|
||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
flatpak_dir_set_source_pid (system, get_sender_pid (invocation));
|
||||
|
||||
if ((arg_flags & ~FLATPAK_HELPER_INSTALL_BUNDLE_FLAGS_ALL) != 0)
|
||||
{
|
||||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
|
||||
@@ -777,15 +773,13 @@ handle_configure_remote (FlatpakSystemHelper *object,
|
||||
|
||||
g_debug ("ConfigureRemote %u %s %s", arg_flags, arg_remote, arg_installation);
|
||||
|
||||
system = dir_get_system (arg_installation, &error);
|
||||
system = dir_get_system (arg_installation, get_sender_pid (invocation), &error);
|
||||
if (system == NULL)
|
||||
{
|
||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
flatpak_dir_set_source_pid (system, get_sender_pid (invocation));
|
||||
|
||||
if (*arg_remote == 0 || strchr (arg_remote, '/') != NULL)
|
||||
{
|
||||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
|
||||
@@ -860,15 +854,13 @@ handle_configure (FlatpakSystemHelper *object,
|
||||
|
||||
g_debug ("Configure %u %s=%s %s", arg_flags, arg_key, arg_value, arg_installation);
|
||||
|
||||
system = dir_get_system (arg_installation, &error);
|
||||
system = dir_get_system (arg_installation, get_sender_pid (invocation), &error);
|
||||
if (system == NULL)
|
||||
{
|
||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
flatpak_dir_set_source_pid (system, get_sender_pid (invocation));
|
||||
|
||||
if ((arg_flags & ~FLATPAK_HELPER_CONFIGURE_FLAGS_ALL) != 0)
|
||||
{
|
||||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
|
||||
@@ -925,15 +917,13 @@ handle_update_remote (FlatpakSystemHelper *object,
|
||||
|
||||
g_debug ("UpdateRemote %u %s %s %s %s", arg_flags, arg_remote, arg_installation, arg_summary_path, arg_summary_sig_path);
|
||||
|
||||
system = dir_get_system (arg_installation, &error);
|
||||
system = dir_get_system (arg_installation, get_sender_pid (invocation), &error);
|
||||
if (system == NULL)
|
||||
{
|
||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
flatpak_dir_set_source_pid (system, get_sender_pid (invocation));
|
||||
|
||||
if (*arg_remote == 0 || strchr (arg_remote, '/') != NULL)
|
||||
{
|
||||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
|
||||
@@ -1003,15 +993,13 @@ handle_remove_local_ref (FlatpakSystemHelper *object,
|
||||
|
||||
g_debug ("RemoveLocalRef %u %s %s %s", arg_flags, arg_remote, arg_ref, arg_installation);
|
||||
|
||||
system = dir_get_system (arg_installation, &error);
|
||||
system = dir_get_system (arg_installation, get_sender_pid (invocation), &error);
|
||||
if (system == NULL)
|
||||
{
|
||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
flatpak_dir_set_source_pid (system, get_sender_pid (invocation));
|
||||
|
||||
if ((arg_flags & ~FLATPAK_HELPER_REMOVE_LOCAL_REF_FLAGS_ALL) != 0)
|
||||
{
|
||||
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
|
||||
@@ -1054,7 +1042,7 @@ handle_prune_local_repo (FlatpakSystemHelper *object,
|
||||
|
||||
g_debug ("PruneLocalRepo %u %s", arg_flags, arg_installation);
|
||||
|
||||
system = dir_get_system (arg_installation, &error);
|
||||
system = dir_get_system (arg_installation, get_sender_pid (invocation), &error);
|
||||
if (system == NULL)
|
||||
{
|
||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||
@@ -1097,7 +1085,7 @@ handle_ensure_repo (FlatpakSystemHelper *object,
|
||||
|
||||
g_debug ("EnsureRepo %u %s", arg_flags, arg_installation);
|
||||
|
||||
system = dir_get_system (arg_installation, &error);
|
||||
system = dir_get_system (arg_installation, get_sender_pid (invocation), &error);
|
||||
if (system == NULL)
|
||||
{
|
||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||
@@ -1133,7 +1121,7 @@ handle_run_triggers (FlatpakSystemHelper *object,
|
||||
|
||||
g_debug ("RunTriggers %u %s", arg_flags, arg_installation);
|
||||
|
||||
system = dir_get_system (arg_installation, &error);
|
||||
system = dir_get_system (arg_installation, get_sender_pid (invocation), &error);
|
||||
if (system == NULL)
|
||||
{
|
||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||
@@ -1175,7 +1163,7 @@ handle_update_summary (FlatpakSystemHelper *object,
|
||||
|
||||
g_debug ("UpdateSummary %u %s", arg_flags, arg_installation);
|
||||
|
||||
system = dir_get_system (arg_installation, &error);
|
||||
system = dir_get_system (arg_installation, get_sender_pid (invocation), &error);
|
||||
if (system == NULL)
|
||||
{
|
||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||
@@ -1219,7 +1207,7 @@ handle_generate_oci_summary (FlatpakSystemHelper *object,
|
||||
|
||||
g_debug ("GenerateOciSummary %u %s %s", arg_flags, arg_origin, arg_installation);
|
||||
|
||||
system = dir_get_system (arg_installation, &error);
|
||||
system = dir_get_system (arg_installation, get_sender_pid (invocation), &error);
|
||||
if (system == NULL)
|
||||
{
|
||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
||||
@@ -1340,7 +1328,7 @@ flatpak_authorize_method_handler (GDBusInterfaceSkeleton *interface,
|
||||
is_install = TRUE;
|
||||
else
|
||||
{
|
||||
g_autoptr(FlatpakDir) system = dir_get_system (installation, NULL);
|
||||
g_autoptr(FlatpakDir) system = dir_get_system (installation, 0, NULL);
|
||||
|
||||
is_install = !dir_ref_is_installed (system, ref);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user