From 61143a99a5fa961abee51e2cb87633c1868a54c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 20 Apr 2020 03:45:37 +0200 Subject: [PATCH] Remove qubesd-query-fast Since qubesd is connected directly as a socket-based qrexec service, the qubesd-query-fast tool isn't needed anymore. --- Makefile | 2 - qubes-rpc/.gitignore | 1 - qubes-rpc/Makefile | 8 --- qubes-rpc/qubesd-query-fast.c | 112 ---------------------------------- rpm_spec/core-dom0.spec.in | 5 +- 5 files changed, 1 insertion(+), 127 deletions(-) delete mode 100644 qubes-rpc/Makefile delete mode 100644 qubes-rpc/qubesd-query-fast.c diff --git a/Makefile b/Makefile index 406c20f4..1504df21 100644 --- a/Makefile +++ b/Makefile @@ -147,7 +147,6 @@ rpms-dom0: all: $(PYTHON) setup.py build - $(MAKE) -C qubes-rpc all # Currently supported only on xen install: @@ -201,7 +200,6 @@ endif cp qubes-rpc/qubes.NotifyTools $(DESTDIR)/etc/qubes-rpc/ cp qubes-rpc/qubes.NotifyUpdates $(DESTDIR)/etc/qubes-rpc/ cp qubes-rpc/qubes.ConnectTCP $(DESTDIR)/etc/qubes-rpc/ - install qubes-rpc/qubesd-query-fast $(DESTDIR)/usr/libexec/qubes/ install -m 0755 qvm-tools/qubes-bug-report $(DESTDIR)/usr/bin/qubes-bug-report install -m 0755 qvm-tools/qubes-hcl-report $(DESTDIR)/usr/bin/qubes-hcl-report install -m 0755 qvm-tools/qvm-sync-clock $(DESTDIR)/usr/bin/qvm-sync-clock diff --git a/qubes-rpc/.gitignore b/qubes-rpc/.gitignore index 732db7f6..bc50fb19 100644 --- a/qubes-rpc/.gitignore +++ b/qubes-rpc/.gitignore @@ -1,2 +1 @@ qfile-dom0-unpacker -qubesd-query-fast diff --git a/qubes-rpc/Makefile b/qubes-rpc/Makefile deleted file mode 100644 index 07c1364a..00000000 --- a/qubes-rpc/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -CFLAGS=-O2 -g -Wall -Werror -Wextra - -all: qubesd-query-fast - -qubesd-query-fast: qubesd-query-fast.c - -clean: - rm -f qubesd-query-fast diff --git a/qubes-rpc/qubesd-query-fast.c b/qubes-rpc/qubesd-query-fast.c deleted file mode 100644 index eeb02cf0..00000000 --- a/qubes-rpc/qubesd-query-fast.c +++ /dev/null @@ -1,112 +0,0 @@ -#include -#include -#include -#include -#include -#include - - -#define QUBESD_SOCKET "/var/run/qubesd.sock" - -void write_wrapper(int fd, char *data, size_t len) { - size_t written = 0; - int ret; - while (written < len) { - ret = write(fd, data+written, len-written); - if (ret == -1) { - perror("write"); - exit(1); - } - written += ret; - } -} - -int main(int argc, char **argv) { - char *source_domain = getenv("QREXEC_REMOTE_DOMAIN"); - char *target_domain = NULL; - char *target_domain_type = getenv("QREXEC_REQUESTED_TARGET_TYPE"); - char *target_domain_name = getenv("QREXEC_REQUESTED_TARGET"); - char *target_domain_keyword = getenv("QREXEC_REQUESTED_TARGET_KEYWORD"); - char *service_name = strrchr(argv[0], '/'); - int fd; - char buf[4096]; - int read_ret; - struct sockaddr_un qubesd_addr = { - .sun_family = AF_UNIX, - .sun_path = QUBESD_SOCKET, - }; - - if (service_name) - service_name++; - - if (!source_domain || !target_domain_type || !service_name || argc > 2) { - fprintf(stderr, "Usage: %s [service-argument]\n", argv[0]); - fprintf(stderr, "\n"); - fprintf(stderr, "Expected environment variables:\n"); - fprintf(stderr, " - QREXEC_REMOTE_DOMAIN - source domain for the call\n"); - fprintf(stderr, " - QREXEC_REQUESTED_TARGET_TYPE - target domain for the call\n"); - fprintf(stderr, "\n"); - fprintf(stderr, "Additionally, this program assumes being called with desired service name as argv[0] (use symlink)\n"); - return 1; - } - - fd = socket(AF_UNIX, SOCK_STREAM, 0); - if (fd == -1) { - perror("socket"); - return 1; - } - - if (connect(fd, (struct sockaddr *)&qubesd_addr, sizeof(qubesd_addr)) == -1) { - perror("connect to qubesd"); - return 1; - } - - if (strcmp(target_domain_type, "keyword") == 0) { - // translate @adminvm back to dom0 - if (strcmp(target_domain_keyword, "adminvm") == 0) - target_domain = "dom0"; - else if (strcmp(target_domain_keyword, "default") == 0) - target_domain = ""; - else { - fprintf(stderr, "Unsupported keyword: %s", target_domain_keyword); - return 1; - } - } else - target_domain = target_domain_name; - - assert(target_domain); - - // write parameters, including trailing zero as separator - write_wrapper(fd, source_domain, strlen(source_domain) + 1); - write_wrapper(fd, service_name, strlen(service_name) + 1); - write_wrapper(fd, target_domain, strlen(target_domain) + 1); - if (argc == 2) - write_wrapper(fd, argv[1], strlen(argv[1]) + 1); - else - // empty argument - write_wrapper(fd, "\0", 1); - - // now, read from stdin and write it to qubesd - while ((read_ret = read(0, buf, sizeof(buf))) > 0) - write_wrapper(fd, buf, read_ret); - - if (read_ret == -1) { - perror("read from stdin"); - return 1; - } - - // end of request, now let qubesd execute the action and return response - shutdown(fd, SHUT_WR); - - // then, retrieve the response from qubesd and send it to stdout - while ((read_ret = read(fd, buf, sizeof(buf))) > 0) - write_wrapper(1, buf, read_ret); - - if (read_ret == -1) { - perror("read from qubesd"); - return 1; - } - - return 0; -} - diff --git a/rpm_spec/core-dom0.spec.in b/rpm_spec/core-dom0.spec.in index 5b962337..99a2228a 100644 --- a/rpm_spec/core-dom0.spec.in +++ b/rpm_spec/core-dom0.spec.in @@ -41,13 +41,11 @@ URL: http://www.qubes-os.org # /bin -> usr/bin symlink). python*.rpm provides only /usr/bin/python. AutoReq: no -# FIXME: Enable this and disable debug_package -#BuildArch: noarch +BuildArch: noarch BuildRequires: ImageMagick BuildRequires: systemd-units BuildRequires: systemd -BuildRequires: gcc BuildRequires: python3-devel @@ -364,7 +362,6 @@ fi /usr/lib/qubes/cleanup-dispvms /usr/lib/qubes/fix-dir-perms.sh /usr/lib/qubes/startup-misc.sh -/usr/libexec/qubes/qubesd-query-fast %{_unitdir}/lvm2-pvscan@.service.d/30_qubes.conf %{_unitdir}/qubes-core.service %{_unitdir}/qubes-qmemman.service