From 360c10ba7e43f31bee2150ee5f93ba4c65108645 Mon Sep 17 00:00:00 2001 From: Josselin Poiret Date: Tue, 14 Dec 2021 22:47:51 +0100 Subject: [PATCH] gnu: xdg-desktop-portal-wlr: Add binary dependencies. * gnu/packages/patches/xdg-desktop-portal-wlr-harcoded-length.patch: Add it. * gnu/local.mk (dist_patch_DATA): Register it. * gnu/packages/freedesktop.scm (xdg-desktop-portal-wlr): Add dependencies on bash-minimal, grim and slurp, and hardcode the paths in source. Signed-off-by: Mathieu Othacehe --- gnu/local.mk | 1 + gnu/packages/freedesktop.scm | 23 +++++++++++++-- ...g-desktop-portal-wlr-harcoded-length.patch | 28 +++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 gnu/packages/patches/xdg-desktop-portal-wlr-harcoded-length.patch diff --git a/gnu/local.mk b/gnu/local.mk index 0bae6ffa63..d20a51070b 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1932,6 +1932,7 @@ dist_patch_DATA = \ %D%/packages/patches/wpa-supplicant-CVE-2021-27803.patch \ %D%/packages/patches/wpa-supplicant-CVE-2021-30004.patch \ %D%/packages/patches/x265-arm-flags.patch \ + %D%/packages/patches/xdg-desktop-portal-wlr-harcoded-length.patch\ %D%/packages/patches/xf86-video-ark-remove-mibstore.patch \ %D%/packages/patches/xf86-video-mach64-bool-to-boolean.patch \ %D%/packages/patches/xf86-video-mach64-glibc-2.20.patch \ diff --git a/gnu/packages/freedesktop.scm b/gnu/packages/freedesktop.scm index 215e9727e2..dcd1870e41 100644 --- a/gnu/packages/freedesktop.scm +++ b/gnu/packages/freedesktop.scm @@ -2387,18 +2387,37 @@ interfaces.") (file-name (git-file-name name version)) (sha256 (base32 - "1ipg35gv8ja39ijwbyi96qlyq2y1fjdggl40s38rv68bsya8zry1")))) + "1ipg35gv8ja39ijwbyi96qlyq2y1fjdggl40s38rv68bsya8zry1")) + (patches (search-patches "xdg-desktop-portal-wlr-harcoded-length.patch")))) (build-system meson-build-system) (arguments `(#:configure-flags '("-Dsystemd=disabled" - "-Dsd-bus-provider=libelogind"))) + "-Dsd-bus-provider=libelogind") + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'hardcode-binaries + (lambda* (#:key inputs #:allow-other-keys) + (let ((sh (search-input-file inputs "/bin/sh")) + (grim (search-input-file inputs "/bin/grim")) + (slurp (search-input-file inputs "/bin/slurp"))) + (substitute* "src/screenshot/screenshot.c" + (("grim") grim) + (("slurp") slurp) + (("execl\\(\"/bin/sh\", \"/bin/sh\"") + (string-append "execl(\"" sh "\", \"" sh "\""))) + (substitute* "src/screencast/screencast.c" + (("execvp\\(\"sh") + (string-append "execvp(\"" sh))))))))) (native-inputs (list cmake pkg-config)) (inputs (list elogind + bash-minimal + grim iniparser libinih pipewire-0.3 + slurp wayland wayland-protocols)) (home-page "https://github.com/emersion/xdg-desktop-portal-wlr") diff --git a/gnu/packages/patches/xdg-desktop-portal-wlr-harcoded-length.patch b/gnu/packages/patches/xdg-desktop-portal-wlr-harcoded-length.patch new file mode 100644 index 0000000000..b499a039e8 --- /dev/null +++ b/gnu/packages/patches/xdg-desktop-portal-wlr-harcoded-length.patch @@ -0,0 +1,28 @@ +From 3121eeb5e68bedd6e2398f35b9bd60b69709a47e Mon Sep 17 00:00:00 2001 +From: Josselin Poiret +Date: Tue, 14 Dec 2021 18:49:54 +0100 +Subject: [PATCH] Replace hardcoded command length + +--- + src/screenshot/screenshot.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/screenshot/screenshot.c b/src/screenshot/screenshot.c +index 9df0ea7..5f27681 100644 +--- a/src/screenshot/screenshot.c ++++ b/src/screenshot/screenshot.c +@@ -42,8 +42,9 @@ static bool exec_screenshooter_interactive(const char *path) { + perror("fork"); + return false; + } else if (pid == 0) { +- char cmd[strlen(path) + 25]; +- snprintf(cmd, sizeof(cmd), "grim -g \"$(slurp)\" -- %s", path); ++ const char cmd_fmt[] = "grim -g \"$(slurp)\" -- %s"; ++ char cmd[strlen(path) + sizeof(cmd_fmt)]; ++ snprintf(cmd, sizeof(cmd), cmd_fmt, path); + execl("/bin/sh", "/bin/sh", "-c", cmd, NULL); + perror("execl"); + exit(127); +-- +2.34.0 +