diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..931c618 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +SOURCES/spice-vdagent-0.20.0.tar.bz2 +SOURCES/victortoso-E37A484F.keyring diff --git a/.spice-vdagent.metadata b/.spice-vdagent.metadata new file mode 100644 index 0000000..50c755b --- /dev/null +++ b/.spice-vdagent.metadata @@ -0,0 +1,2 @@ +93f67af0586f22af31074b47521e9a1953a5ce58 SOURCES/spice-vdagent-0.20.0.tar.bz2 +da7a529db1ea28a1540c5892ea9836abeb378c3e SOURCES/victortoso-E37A484F.keyring diff --git a/SOURCES/0001-vdagentd-work-around-GLib-s-fork-issues.patch b/SOURCES/0001-vdagentd-work-around-GLib-s-fork-issues.patch new file mode 100644 index 0000000..3e66ee3 --- /dev/null +++ b/SOURCES/0001-vdagentd-work-around-GLib-s-fork-issues.patch @@ -0,0 +1,104 @@ +From 51489290e7fbd771907751990eda719199ff491e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jakub=20Jank=C5=AF?= +Date: Fri, 20 Mar 2020 10:36:03 +0100 +Subject: [PATCH 1/4] vdagentd: work around GLib's fork issues +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Creating threads is not compatible with forking as only the thread +that calls fork() is inherited. + +Handlers registered with g_unix_signal_add() create a thread so +move these calls after fork. + +Also call g_socket_service_start() after fork to avoid creation of +new threads before it is necessary. + +Fixes: https://gitlab.freedesktop.org/spice/linux/vd_agent/issues/18 + +Also see: https://gitlab.gnome.org/GNOME/glib/issues/2073 + +Signed-off-by: Jakub Janků +Acked-by: Frediano Ziglio +(cherry picked from commit 9b8c0ebb9fb573e6ce3c5416371509f416503d0c) +--- + src/udscs.c | 6 ++++++ + src/udscs.h | 2 ++ + src/vdagentd/vdagentd.c | 9 +++++---- + 3 files changed, 13 insertions(+), 4 deletions(-) + +diff --git a/src/udscs.c b/src/udscs.c +index 4de75f8..7c99eed 100644 +--- a/src/udscs.c ++++ b/src/udscs.c +@@ -186,6 +186,7 @@ struct udscs_server *udscs_server_new( + server->read_callback = read_callback; + server->error_cb = error_cb; + server->service = g_socket_service_new(); ++ g_socket_service_stop(server->service); + + g_signal_connect(server->service, "incoming", + G_CALLBACK(udscs_server_accept_cb), server); +@@ -223,6 +224,11 @@ void udscs_server_listen_to_address(struct udscs_server *server, + g_object_unref(sock_addr); + } + ++void udscs_server_start(struct udscs_server *server) ++{ ++ g_socket_service_start(server->service); ++} ++ + void udscs_server_destroy_connection(struct udscs_server *server, + UdscsConnection *conn) + { +diff --git a/src/udscs.h b/src/udscs.h +index 45ebd3f..4f7ea36 100644 +--- a/src/udscs.h ++++ b/src/udscs.h +@@ -98,6 +98,8 @@ void udscs_server_listen_to_address(struct udscs_server *server, + const gchar *addr, + GError **err); + ++void udscs_server_start(struct udscs_server *server); ++ + void udscs_server_destroy_connection(struct udscs_server *server, + UdscsConnection *conn); + +diff --git a/src/vdagentd/vdagentd.c b/src/vdagentd/vdagentd.c +index cfd0a51..1b63ec8 100644 +--- a/src/vdagentd/vdagentd.c ++++ b/src/vdagentd/vdagentd.c +@@ -1184,10 +1184,6 @@ int main(int argc, char *argv[]) + uinput_device = g_strdup(DEFAULT_UINPUT_DEVICE); + } + +- g_unix_signal_add(SIGINT, signal_handler, NULL); +- g_unix_signal_add(SIGHUP, signal_handler, NULL); +- g_unix_signal_add(SIGTERM, signal_handler, NULL); +- + openlog("spice-vdagentd", do_daemonize ? 0 : LOG_PERROR, LOG_USER); + + /* Setup communication with vdagent process(es) */ +@@ -1240,6 +1236,10 @@ int main(int argc, char *argv[]) + } + #endif + ++ g_unix_signal_add(SIGINT, signal_handler, NULL); ++ g_unix_signal_add(SIGHUP, signal_handler, NULL); ++ g_unix_signal_add(SIGTERM, signal_handler, NULL); ++ + if (want_session_info) + session_info = session_info_create(debug); + if (session_info) { +@@ -1252,6 +1252,7 @@ int main(int argc, char *argv[]) + + active_xfers = g_hash_table_new(g_direct_hash, g_direct_equal); + ++ udscs_server_start(server); + loop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(loop); + +-- +2.26.1 + diff --git a/SOURCES/0002-vdagentd-init-static-uinput-before-fork.patch b/SOURCES/0002-vdagentd-init-static-uinput-before-fork.patch new file mode 100644 index 0000000..298cee3 --- /dev/null +++ b/SOURCES/0002-vdagentd-init-static-uinput-before-fork.patch @@ -0,0 +1,45 @@ +From 3bcba789b9c5f776aa5f43b5783ef41befee62a6 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jakub=20Jank=C5=AF?= +Date: Fri, 20 Mar 2020 17:18:32 +0100 +Subject: [PATCH 2/4] vdagentd: init static uinput before fork +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Otherwise the caller doesn't know that the init failed +because we're returning 0 in the parent and 1 in child. + +Signed-off-by: Jakub Janků +Acked-by: Frediano Ziglio +(cherry picked from commit 7b0435ef66af088c1a1be20b6bc6b0fcb76e4e1a) +--- + src/vdagentd/vdagentd.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/vdagentd/vdagentd.c b/src/vdagentd/vdagentd.c +index 1b63ec8..753c9bf 100644 +--- a/src/vdagentd/vdagentd.c ++++ b/src/vdagentd/vdagentd.c +@@ -1224,9 +1224,6 @@ int main(int argc, char *argv[]) + } + } + +- if (do_daemonize) +- daemonize(); +- + #ifdef WITH_STATIC_UINPUT + uinput = vdagentd_uinput_create(uinput_device, 1024, 768, NULL, 0, + debug > 1, uinput_fake); +@@ -1236,6 +1233,9 @@ int main(int argc, char *argv[]) + } + #endif + ++ if (do_daemonize) ++ daemonize(); ++ + g_unix_signal_add(SIGINT, signal_handler, NULL); + g_unix_signal_add(SIGHUP, signal_handler, NULL); + g_unix_signal_add(SIGTERM, signal_handler, NULL); +-- +2.26.1 + diff --git a/SOURCES/0003-systemd-login-Avoid-a-crash-on-container.patch b/SOURCES/0003-systemd-login-Avoid-a-crash-on-container.patch new file mode 100644 index 0000000..ccbd2f6 --- /dev/null +++ b/SOURCES/0003-systemd-login-Avoid-a-crash-on-container.patch @@ -0,0 +1,35 @@ +From 823d743394f5696887ed1622623f45f7190d59bf Mon Sep 17 00:00:00 2001 +From: Frediano Ziglio +Date: Thu, 26 Mar 2020 11:31:50 +0000 +Subject: [PATCH 3/4] systemd-login: Avoid a crash on container + +On containers dbus could be not running. +In this case dbus.system_connection is NULL and calling +dbus_connection_close on it will cause a crash. +This happens also under Gitlab CI. + +Signed-off-by: Frediano Ziglio +Acked-by: Victor Toso +(cherry picked from commit 5654f4d2f90f95efd1f0ca70b438a3ab81022d15) +--- + src/vdagentd/systemd-login.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/vdagentd/systemd-login.c b/src/vdagentd/systemd-login.c +index 0b8f3c1..2d2311c 100644 +--- a/src/vdagentd/systemd-login.c ++++ b/src/vdagentd/systemd-login.c +@@ -250,7 +250,9 @@ void session_info_destroy(struct session_info *si) + return; + + si_dbus_match_remove(si); +- dbus_connection_close(si->dbus.system_connection); ++ if (si->dbus.system_connection) { ++ dbus_connection_close(si->dbus.system_connection); ++ } + sd_login_monitor_unref(si->mon); + g_free(si->session); + g_free(si); +-- +2.26.1 + diff --git a/SOURCES/0004-Fix-possible-compile-error-using-former-GLib2-versio.patch b/SOURCES/0004-Fix-possible-compile-error-using-former-GLib2-versio.patch new file mode 100644 index 0000000..f03083f --- /dev/null +++ b/SOURCES/0004-Fix-possible-compile-error-using-former-GLib2-versio.patch @@ -0,0 +1,31 @@ +From 7a9ae6219c5a114edcfd1ccb5db04568e47c94aa Mon Sep 17 00:00:00 2001 +From: Frediano Ziglio +Date: Mon, 11 May 2020 10:47:49 +0100 +Subject: [PATCH 4/4] Fix possible compile error using former GLib2 version + +We require GLib 2.50 but G_SOURCE_FUNC was introduced in version +2.58. Do the conversion instead of using G_SOURCE_FUNC macro. + +Signed-off-by: Frediano Ziglio +Acked-by: Victor Toso +(cherry picked from commit d0b5f80adaef757ebfa81d1ab1c6561697243dc9) +--- + src/vdagent-connection.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/vdagent-connection.c b/src/vdagent-connection.c +index 8c023e2..c085d81 100644 +--- a/src/vdagent-connection.c ++++ b/src/vdagent-connection.c +@@ -231,7 +231,7 @@ void vdagent_connection_write(VDAgentConnection *self, + out = G_POLLABLE_OUTPUT_STREAM(g_io_stream_get_output_stream(priv->io_stream)); + + source = g_pollable_output_stream_create_source(out, priv->cancellable); +- g_source_set_callback(source, G_SOURCE_FUNC(out_stream_ready_cb), ++ g_source_set_callback(source, (GSourceFunc) out_stream_ready_cb, + g_object_ref(self), NULL); + g_source_attach(source, NULL); + g_source_unref(source); +-- +2.26.1 + diff --git a/SOURCES/spice-vdagent-0.20.0.tar.bz2.sig b/SOURCES/spice-vdagent-0.20.0.tar.bz2.sig new file mode 100644 index 0000000..fcea9b5 Binary files /dev/null and b/SOURCES/spice-vdagent-0.20.0.tar.bz2.sig differ diff --git a/SPECS/spice-vdagent.spec b/SPECS/spice-vdagent.spec new file mode 100644 index 0000000..3149b1a --- /dev/null +++ b/SPECS/spice-vdagent.spec @@ -0,0 +1,229 @@ +Name: spice-vdagent +Version: 0.20.0 +Release: 1%{?dist} +Summary: Agent for Spice guests +Group: Applications/System +License: GPLv3+ +URL: https://spice-space.org/ +Source0: https://spice-space.org/download/releases/%{name}-%{version}.tar.bz2 +Source1: https://spice-space.org/download/releases/%{name}-%{version}.tar.bz2.sig +Source2: victortoso-E37A484F.keyring +Patch0001: 0001-vdagentd-work-around-GLib-s-fork-issues.patch +Patch0002: 0002-vdagentd-init-static-uinput-before-fork.patch +Patch0003: 0003-systemd-login-Avoid-a-crash-on-container.patch +Patch0004: 0004-Fix-possible-compile-error-using-former-GLib2-versio.patch + +BuildRequires: git-core gnupg2 +BuildRequires: systemd-devel +BuildRequires: glib2-devel >= 2.50 +BuildRequires: spice-protocol >= 0.14.1 +BuildRequires: libpciaccess-devel libXrandr-devel libXinerama-devel +BuildRequires: libXfixes-devel systemd desktop-file-utils libtool +BuildRequires: alsa-lib-devel dbus-devel libdrm-devel +%{?systemd_requires} + +%description +Spice agent for Linux guests offering the following features: + +Features: +* Client mouse mode (no need to grab mouse by client, no mouse lag) + this is handled by the daemon by feeding mouse events into the kernel + via uinput. This will only work if the active X-session is running a + spice-vdagent process so that its resolution can be determined. +* Automatic adjustment of the X-session resolution to the client resolution +* Support of copy and paste (text and images) between the active X-session + and the client + + +%prep +gpgv2 --quiet --keyring %{SOURCE2} %{SOURCE1} %{SOURCE0} +%autosetup -S git_am +#autoreconf -fi + + +%build +%configure --with-session-info=systemd --with-init-script=systemd +make %{?_smp_mflags} V=2 + + +%install +make install DESTDIR=$RPM_BUILD_ROOT V=2 + + +%post +%systemd_post spice-vdagentd.service spice-vdagentd.socket + +%preun +%systemd_preun spice-vdagentd.service spice-vdagentd.socket + +%postun +%systemd_postun_with_restart spice-vdagentd.service spice-vdagentd.socket + + +%files +%doc COPYING CHANGELOG.md README.md +/usr/lib/udev/rules.d/70-spice-vdagentd.rules +%{_unitdir}/spice-vdagentd.service +%{_unitdir}/spice-vdagentd.socket +%{_prefix}/lib/tmpfiles.d/spice-vdagentd.conf +%{_bindir}/spice-vdagent +%{_sbindir}/spice-vdagentd +%{_var}/run/spice-vdagentd +%{_sysconfdir}/xdg/autostart/spice-vdagent.desktop +# For /usr/share/gdm/autostart/LoginWindow/spice-vdagent.desktop +# We own the dir too, otherwise we must Require gdm +%{_datadir}/gdm +%{_mandir}/man1/%{name}*.1* + + +%changelog +* Mon May 15 2020 Victor Toso 0.20.0-1 +- Update to 0.20.0 +- Backport fixes post-release + Resolves: rhbz#1817476 + +* Tue Aug 27 2019 Victor Toso 0.19.0-3 +- Fix two new covscan warnings + Resolves: rhbz#1660566 + +* Mon Aug 19 2019 Victor Toso 0.19.0-2 +- Fix some covscan warnings from latest build + Resolves: rhbz#1660566 + +* Mon May 20 2019 Victor Toso 0.19.0-1 +- Update to 0.19.0 + Resolves: rhbz#1711975 +- Validate tarball with gpg + +* Tue Dec 18 2018 Victor Toso 0.18.0-3 +- Fix leak of unix sockets. + Resolves: rhbz#1660108 + +* Thu Nov 15 2018 Victor Toso 0.18.0-2 +- Fix unusable mouse on xorg resolution event in wayland + Resolves: rhbz#1641723 + +* Tue Jun 12 2018 Victor Toso 0.18.0-1 +- Update to spice-vdagent 0.18.0 + +* Fri Feb 09 2018 Fedora Release Engineering - 0.17.0-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Thu Jan 25 2018 Igor Gnatenko - 0.17.0-5 +- Fix systemd executions/requirements + +* Thu Aug 03 2017 Fedora Release Engineering - 0.17.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Thu Jul 27 2017 Fedora Release Engineering - 0.17.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Sat Feb 11 2017 Fedora Release Engineering - 0.17.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Tue Nov 22 2016 Christophe Fergeau 0.17.0-1 +- Update to spice-vdagent 0.17.0 + +* Fri Feb 05 2016 Fedora Release Engineering - 0.16.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Mon Oct 05 2015 Christophe Fergeau 0.16.0-2 +- Add upstream patch fixing a memory corruption bug (double free) + Resolves: rhbz#1268666 + Exit with a non-0 exit code when the virtio device cannot be opened by the + agent + +* Tue Jun 30 2015 Christophe Fergeau 0.16.0-1 +- Update to 0.16.0 release + +* Fri Jun 19 2015 Fedora Release Engineering - 0.15.0-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Sat Feb 21 2015 Till Maas - 0.15.0-4 +- Rebuilt for Fedora 23 Change + https://fedoraproject.org/wiki/Changes/Harden_all_packages_with_position-independent_code + +* Mon Aug 18 2014 Fedora Release Engineering - 0.15.0-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Sun Jun 08 2014 Fedora Release Engineering - 0.15.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Mon Oct 14 2013 Alon Levy - 0.15.0-1 +- New upstream release 0.15.0 + +* Tue Sep 10 2013 Hans de Goede - 0.14.0-5 +- Silence session agent error logging when not running in a vm (rhbz#999804) +- Release guest clipboard ownership on client disconnect (rhbz#1003977) + +* Sun Aug 04 2013 Fedora Release Engineering - 0.14.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Wed Jul 3 2013 Hans de Goede - 0.14.0-3 +- Advertise clipboard line-endings for copy and paste line-ending conversion +- Build spice-vdagentd as pie + relro + +* Mon May 20 2013 Hans de Goede - 0.14.0-2 +- Drop the no longer needed /etc/modules-load.d/spice-vdagentd.conf (#963201) + +* Fri Apr 12 2013 Hans de Goede - 0.14.0-1 +- New upstream release 0.14.0 +- Adds support for file transfers from client to guest +- Adds manpages for spice-vdagent and spice-vdagentd + +* Fri Feb 15 2013 Fedora Release Engineering - 0.12.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Tue Jan 8 2013 Hans de Goede - 0.12.1-1 +- New upstream release 0.12.1 +- Fixes various issues with dynamic monitor / resolution support + +* Mon Nov 12 2012 Hans de Goede - 0.12.0-2 +- Fix setting of mode on non arbitrary resolution capable X driver +- Fix wrong mouse coordinates on vms with multiple qxl devices + +* Sat Sep 1 2012 Hans de Goede - 0.12.0-1 +- New upstream release 0.12.0 +- This moves the tmpfiles.d to /usr/lib/tmpfiles.d (rhbz#840194) +- This adds a systemd .service file (rhbz#848102) + +* Sat Jul 21 2012 Fedora Release Engineering - 0.10.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Tue Mar 27 2012 Hans de Goede - 0.10.1-1 +- New upstream release 0.10.1 + +* Thu Mar 22 2012 Hans de Goede - 0.10.0-1 +- New upstream release 0.10.0 +- This supports using systemd-logind instead of console-kit (rhbz#756398) + +* Sat Jan 14 2012 Fedora Release Engineering - 0.8.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Mon Jul 18 2011 Hans de Goede 0.8.1-1 +- New upstream release 0.8.1 + +* Fri Jul 15 2011 Hans de Goede 0.8.0-2 +- Make the per session agent process automatically reconnect to the system + spice-vdagentd when the system daemon gets restarted + +* Tue Apr 19 2011 Hans de Goede 0.8.0-1 +- New upstream release 0.8.0 + +* Mon Mar 07 2011 Hans de Goede 0.6.3-6 +- Fix setting of the guest resolution from a multi monitor client + +* Wed Feb 09 2011 Fedora Release Engineering - 0.6.3-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Mon Jan 10 2011 Hans de Goede 0.6.3-4 +- Make sysvinit script exit cleanly when not running on a spice enabled vm + +* Fri Nov 19 2010 Hans de Goede 0.6.3-3 +- Put the pid and log files into their own subdir (#648553) + +* Mon Nov 8 2010 Hans de Goede 0.6.3-2 +- Fix broken multiline description in initscript lsb header (#648549) + +* Sat Oct 30 2010 Hans de Goede 0.6.3-1 +- Initial Fedora package