"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "session-helper/flatpak-session-helper.c" between
flatpak-1.15.1.tar.xz and flatpak-1.15.2.tar.xz

About: Flatpak is a Linux application sandboxing and distribution framework. Pre-release.

flatpak-session-helper.c  (flatpak-1.15.1.tar.xz):flatpak-session-helper.c  (flatpak-1.15.2.tar.xz)
skipping to change at line 103 skipping to change at line 103
} }
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_SESSION_HELPER_PATH_DEVELOPMENT, FLATPAK_SESSION_HELPER_PATH_DEVELOPMENT,
FLATPAK_SESSION_HELPER_INTERFACE_DEVELOPMENT, FLATPAK_SESSION_HELPER_INTERFACE_DEVELOPMENT,
"HostCommandExited", "HostCommandExited",
signal_variant, signal_variant,
NULL); NULL);
skipping to change at line 190 skipping to change at line 190
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
handle_host_command (FlatpakDevelopment *object, handle_host_command (FlatpakDevelopment *object,
GDBusMethodInvocation *invocation, GDBusMethodInvocation *invocation,
GUnixFDList *fd_list, GUnixFDList *fd_list,
skipping to change at line 240 skipping to change at line 240
!g_variant_is_of_type (arg_envs, G_VARIANT_TYPE ("a{ss}")) || !g_variant_is_of_type (arg_envs, G_VARIANT_TYPE ("a{ss}")) ||
(flags & ~(FLATPAK_HOST_COMMAND_FLAGS_CLEAR_ENV | (flags & ~(FLATPAK_HOST_COMMAND_FLAGS_CLEAR_ENV |
FLATPAK_HOST_COMMAND_FLAGS_WATCH_BUS)) != 0) FLATPAK_HOST_COMMAND_FLAGS_WATCH_BUS)) != 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,
"Unexpected argument"); "Unexpected argument");
return G_DBUS_METHOD_INVOCATION_HANDLED; return G_DBUS_METHOD_INVOCATION_HANDLED;
} }
g_debug ("Running host command %s", arg_argv[0]); g_info ("Running host command %s", arg_argv[0]);
n_fds = 0; n_fds = 0;
fds = NULL; fds = NULL;
if (fd_list != NULL) if (fd_list != NULL)
{ {
n_fds = g_variant_n_children (arg_fds); n_fds = g_variant_n_children (arg_fds);
fds = g_unix_fd_list_peek_fds (fd_list, NULL); fds = g_unix_fd_list_peek_fds (fd_list, NULL);
} }
fd_map = g_new0 (FdMapEntry, n_fds); fd_map = g_new0 (FdMapEntry, n_fds);
skipping to change at line 355 skipping to change at line 355
pid_data = g_new0 (PidData, 1); pid_data = g_new0 (PidData, 1);
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 = (flags & FLATPAK_HOST_COMMAND_FLAGS_WATCH_BUS) != 0; pid_data->watch_bus = (flags & FLATPAK_HOST_COMMAND_FLAGS_WATCH_BUS) != 0;
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);
flatpak_development_complete_host_command (object, invocation, NULL, flatpak_development_complete_host_command (object, invocation, NULL,
pid_data->pid); pid_data->pid);
return G_DBUS_METHOD_INVOCATION_HANDLED; return G_DBUS_METHOD_INVOCATION_HANDLED;
} }
static gboolean static gboolean
skipping to change at line 384 skipping to change at line 384
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 (to_process_group) if (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);
flatpak_development_complete_host_command_signal (object, invocation); flatpak_development_complete_host_command_signal (object, invocation);
return G_DBUS_METHOD_INVOCATION_HANDLED; return G_DBUS_METHOD_INVOCATION_HANDLED;
} }
skipping to change at line 566 skipping to change at line 566
GFileMonitorEvent event_type, GFileMonitorEvent event_type,
MonitorData *data); MonitorData *data);
static void static void
update_real_monitor (MonitorData *data) update_real_monitor (MonitorData *data)
{ {
char *real = realpath (data->source, NULL); char *real = realpath (data->source, NULL);
if (real == NULL) if (real == NULL)
{ {
g_debug ("unable to get real path to monitor host file %s: %s", data->sour g_info ("unable to get real path to monitor host file %s: %s", data->sourc
ce, e,
g_strerror (errno)); g_strerror (errno));
return; return;
} }
/* source path matches real path, second monitor is not required, but an old /* source path matches real path, second monitor is not required, but an old
* one may still exist. set to NULL and compare to what we have. */ * one may still exist. set to NULL and compare to what we have. */
if (!g_strcmp0 (data->source, real)) if (!g_strcmp0 (data->source, real))
{ {
free (real); free (real);
real = NULL; real = NULL;
} }
skipping to change at line 606 skipping to change at line 606
} }
if (!real) if (!real)
return; return;
g_autoptr(GFile) r = g_file_new_for_path (real); g_autoptr(GFile) r = g_file_new_for_path (real);
g_autoptr(GError) err = NULL; g_autoptr(GError) err = NULL;
data->monitor_real = g_file_monitor_file (r, G_FILE_MONITOR_NONE, NULL, &err); data->monitor_real = g_file_monitor_file (r, G_FILE_MONITOR_NONE, NULL, &err);
if (!data->monitor_real) if (!data->monitor_real)
{ {
g_debug ("failed to monitor host file %s (real path of %s): %s", g_info ("failed to monitor host file %s (real path of %s): %s",
real, data->source, err->message); real, data->source, err->message);
return; return;
} }
g_signal_connect (data->monitor_real, "changed", G_CALLBACK (file_changed), da ta); g_signal_connect (data->monitor_real, "changed", G_CALLBACK (file_changed), da ta);
} }
static void static void
file_monitor_do (MonitorData *data) file_monitor_do (MonitorData *data)
{ {
skipping to change at line 665 skipping to change at line 665
data->source = source; data->source = source;
monitor = g_file_monitor_file (s, G_FILE_MONITOR_NONE, NULL, &err); monitor = g_file_monitor_file (s, G_FILE_MONITOR_NONE, NULL, &err);
if (monitor) if (monitor)
{ {
data->monitor_source = monitor; data->monitor_source = monitor;
g_signal_connect (monitor, "changed", G_CALLBACK (file_changed), data); g_signal_connect (monitor, "changed", G_CALLBACK (file_changed), data);
} }
else else
{ {
g_debug ("failed to monitor host file %s: %s", source, err->message); g_info ("failed to monitor host file %s: %s", source, err->message);
} }
file_monitor_do (data); file_monitor_do (data);
return data; return data;
} }
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);
} }
static void static void
start_p11_kit_server (const char *flatpak_dir) start_p11_kit_server (const char *flatpak_dir)
{ {
g_autofree char *socket_basename = g_strdup_printf ("pkcs11-flatpak-%d", getpi d ()); g_autofree char *socket_basename = g_strdup_printf ("pkcs11-flatpak-%d", getpi d ());
g_autofree char *socket_path = g_build_filename (flatpak_dir, socket_basename, NULL); g_autofree char *socket_path = g_build_filename (flatpak_dir, socket_basename, NULL);
skipping to change at line 709 skipping to change at line 709
* this flag. This is good, because those earlier versions did not properly daemonize and caused * this flag. This is good, because those earlier versions did not properly daemonize and caused
* the spawn_sync to hang forever, waiting for the pipe to close. * the spawn_sync to hang forever, waiting for the pipe to close.
*/ */
"--sh", "--sh",
"-n", socket_path, "-n", socket_path,
"--provider", "p11-kit-trust.so", "--provider", "p11-kit-trust.so",
"pkcs11:model=p11-kit-trust?write-protected=yes", "pkcs11:model=p11-kit-trust?write-protected=yes",
NULL NULL
}; };
g_debug ("starting p11-kit server"); g_info ("starting p11-kit server");
if (!g_spawn_sync (NULL, if (!g_spawn_sync (NULL,
p11_argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV _NULL, p11_argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV _NULL,
NULL, NULL, NULL, NULL,
&p11_kit_stdout, NULL, &p11_kit_stdout, NULL,
&exit_status, &local_error)) &exit_status, &local_error))
{ {
g_warning ("Unable to start p11-kit server: %s", local_error->message); g_warning ("Unable to start p11-kit server: %s", local_error->message);
return; return;
} }
skipping to change at line 750 skipping to change at line 750
while (g_ascii_isdigit (*p)) while (g_ascii_isdigit (*p))
p++; p++;
*p = 0; *p = 0;
p11_kit_server_pid = atol (pid); p11_kit_server_pid = atol (pid);
} }
} }
if (p11_kit_server_pid != 0) if (p11_kit_server_pid != 0)
{ {
g_debug ("Using p11-kit socket path %s, pid %d", socket_path, p11_kit_serv er_pid); g_info ("Using p11-kit socket path %s, pid %d", socket_path, p11_kit_serve r_pid);
p11_kit_server_socket_path = g_steal_pointer (&socket_path); p11_kit_server_socket_path = g_steal_pointer (&socket_path);
} }
else else
g_debug ("Not using p11-kit due to older version"); g_info ("Not using p11-kit due to older version");
} }
int int
main (int argc, main (int argc,
char **argv) char **argv)
{ {
guint owner_id; guint owner_id;
GMainLoop *loop; GMainLoop *loop;
gboolean replace; gboolean replace;
gboolean verbose; gboolean verbose;
skipping to change at line 826 skipping to change at line 826
return 1; return 1;
} }
if (show_version) if (show_version)
{ {
g_print (PACKAGE_STRING "\n"); g_print (PACKAGE_STRING "\n");
return 0; return 0;
} }
if (verbose) if (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;
} }
flatpak_dir = g_build_filename (g_get_user_runtime_dir (), ".flatpak-helper", NULL); flatpak_dir = g_build_filename (g_get_user_runtime_dir (), ".flatpak-helper", NULL);
if (g_mkdir_with_parents (flatpak_dir, 0700) != 0) if (g_mkdir_with_parents (flatpak_dir, 0700) != 0)
{ {
g_print ("Can't create %s\n", monitor_dir); g_print ("Can't create %s\n", monitor_dir);
exit (1); exit (1);
} }
if (g_find_program_in_path ("p11-kit")) if (g_find_program_in_path ("p11-kit"))
start_p11_kit_server (flatpak_dir); start_p11_kit_server (flatpak_dir);
else else
g_debug ("p11-kit not found"); g_info ("p11-kit not found");
monitor_dir = g_build_filename (flatpak_dir, "monitor", NULL); monitor_dir = g_build_filename (flatpak_dir, "monitor", NULL);
if (g_mkdir_with_parents (monitor_dir, 0755) != 0) if (g_mkdir_with_parents (monitor_dir, 0755) != 0)
{ {
g_print ("Can't create %s\n", monitor_dir); g_print ("Can't create %s\n", monitor_dir);
exit (1); exit (1);
} }
m_resolv_conf = setup_file_monitor ("/etc/resolv.conf"); m_resolv_conf = setup_file_monitor ("/etc/resolv.conf");
m_host_conf = setup_file_monitor ("/etc/host.conf"); m_host_conf = setup_file_monitor ("/etc/host.conf");
 End of changes. 14 change blocks. 
17 lines changed or deleted 17 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)