[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/06: gnu: openssh: Trust Guix store directory
From: |
guix-commits |
Subject: |
05/06: gnu: openssh: Trust Guix store directory |
Date: |
Thu, 28 Apr 2022 18:43:31 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 4d3c142e0b9ccbe80c4a45f966bb378d055f420e
Author: Alexey Abramov <levenson@mmer.org>
AuthorDate: Tue Apr 26 09:25:50 2022 +0200
gnu: openssh: Trust Guix store directory
* gnu/local.mk (dist_patch_DATA): Add the patch
* gnu/packages/patches/openssh-trust-guix-store-directory.patch: Patch it
* gnu/packages/ssh.scm (openssh[source]): Use it.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
---
gnu/local.mk | 1 +
.../openssh-trust-guix-store-directory.patch | 40 ++++++++++++++++++++++
gnu/packages/ssh.scm | 8 ++++-
3 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/gnu/local.mk b/gnu/local.mk
index ce25b0f21e..ad7b0a1480 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1568,6 +1568,7 @@ dist_patch_DATA =
\
%D%/packages/patches/openjdk-15-xcursor-no-dynamic.patch \
%D%/packages/patches/openmpi-mtl-priorities.patch \
%D%/packages/patches/openssh-hurd.patch \
+ %D%/packages/patches/openssh-trust-guix-store-directory.patch \
%D%/packages/patches/openresolv-restartcmd-guix.patch \
%D%/packages/patches/openrgb-unbundle-hueplusplus.patch \
%D%/packages/patches/opensles-add-license-file.patch \
diff --git a/gnu/packages/patches/openssh-trust-guix-store-directory.patch
b/gnu/packages/patches/openssh-trust-guix-store-directory.patch
new file mode 100644
index 0000000000..b3a9c1bdfc
--- /dev/null
+++ b/gnu/packages/patches/openssh-trust-guix-store-directory.patch
@@ -0,0 +1,40 @@
+From 0d85bbd42ddcd442864a9ba4719aca8b70d68048 Mon Sep 17 00:00:00 2001
+From: Alexey Abramov <levenson@mmer.org>
+Date: Fri, 22 Apr 2022 11:32:15 +0200
+Subject: [PATCH] Trust guix store directory
+
+To be able to execute binaries defined in OpenSSH configuration, we
+need to tell OpenSSH that we can trust Guix store objects. safe_path
+procedure takes a canonical path and for each component, walking
+upwards, checks ownership and permissions constrains which are: must
+be owned by root, not writable by group or others.
+---
+ misc.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/misc.c b/misc.c
+index 0134d69..7131d5e 100644
+--- a/misc.c
++++ b/misc.c
+@@ -2146,6 +2146,7 @@ int
+ safe_path(const char *name, struct stat *stp, const char *pw_dir,
+ uid_t uid, char *err, size_t errlen)
+ {
++ static const char guix_store[] = @STORE_DIRECTORY@;
+ char buf[PATH_MAX], homedir[PATH_MAX];
+ char *cp;
+ int comparehome = 0;
+@@ -2178,6 +2179,10 @@ safe_path(const char *name, struct stat *stp, const
char *pw_dir,
+ }
+ strlcpy(buf, cp, sizeof(buf));
+
++ /* If we are past the Guix store then we can stop */
++ if (strcmp(guix_store, buf) == 0)
++ break;
++
+ if (stat(buf, &st) == -1 ||
+ (!platform_sys_dir_uid(st.st_uid) && st.st_uid != uid) ||
+ (st.st_mode & 022) != 0) {
+--
+2.34.0
+
diff --git a/gnu/packages/ssh.scm b/gnu/packages/ssh.scm
index 8a61b6e97a..7f3b02013e 100644
--- a/gnu/packages/ssh.scm
+++ b/gnu/packages/ssh.scm
@@ -189,7 +189,8 @@ a server that supports the SSH-2 protocol.")
(method url-fetch)
(uri (string-append "mirror://openbsd/OpenSSH/portable/"
"openssh-" version ".tar.gz"))
- (patches (search-patches "openssh-hurd.patch"))
+ (patches (search-patches "openssh-hurd.patch"
+
"openssh-trust-guix-store-directory.patch"))
(sha256
(base32
"1ry5prcax0134v6srkgznpl9ch5snkgq7yvjqvd8c5mbnxa7cjgx"))))
@@ -249,6 +250,11 @@ a server that supports the SSH-2 protocol.")
(substitute* "Makefile"
(("PRIVSEP_PATH=/var/empty")
(string-append "PRIVSEP_PATH=" out "/var/empty"))))))
+ (add-after 'configure 'set-store-location
+ (lambda* _
+ (substitute* "misc.c"
+ (("@STORE_DIRECTORY@")
+ (string-append "\"" (%store-directory) "\"")))))
(add-before 'check 'patch-tests
(lambda _
(substitute* "regress/test-exec.sh"
- branch master updated (882cacc1bb -> 313ae43f51), guix-commits, 2022/04/28
- 02/06: gnu: flatpak: Do not leak GDK_PIXBUF_MODULE_FILE into the sandbox., guix-commits, 2022/04/28
- 04/06: home: services: fish: Fix incorrect ".config" file name., guix-commits, 2022/04/28
- 06/06: gnu: Add Avizo., guix-commits, 2022/04/28
- 01/06: gnu: flatpak: Use G-expressions., guix-commits, 2022/04/28
- 03/06: gnu: rust-pyo3: Allow compilation with Criterion 0.3.5., guix-commits, 2022/04/28
- 05/06: gnu: openssh: Trust Guix store directory,
guix-commits <=