diff options
-rw-r--r-- | gnu/local.mk | 2 | ||||
-rw-r--r-- | gnu/packages/chez.scm | 1 | ||||
-rw-r--r-- | gnu/packages/patches/chez-scheme-bin-sh.patch | 76 | ||||
-rw-r--r-- | gnu/packages/patches/racket-chez-scheme-bin-sh.patch | 76 | ||||
-rw-r--r-- | gnu/packages/racket.scm | 3 |
5 files changed, 157 insertions, 1 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index 8197f2bc83..a8357338ef 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -939,6 +939,7 @@ dist_patch_DATA = \ %D%/packages/patches/calibre-remove-test-sqlite.patch \ %D%/packages/patches/calibre-remove-test-unrar.patch \ %D%/packages/patches/catdoc-CVE-2017-11110.patch \ + %D%/packages/patches/chez-scheme-bin-sh.patch \ %D%/packages/patches/circos-remove-findbin.patch \ %D%/packages/patches/cdparanoia-fpic.patch \ %D%/packages/patches/cdrkit-libre-cross-compile.patch \ @@ -1774,6 +1775,7 @@ dist_patch_DATA = \ %D%/packages/patches/ripperx-missing-file.patch \ %D%/packages/patches/rpcbind-CVE-2017-8779.patch \ %D%/packages/patches/rtags-separate-rct.patch \ + %D%/packages/patches/racket-chez-scheme-bin-sh.patch \ %D%/packages/patches/racket-rktio-bin-sh.patch \ %D%/packages/patches/remake-impure-dirs.patch \ %D%/packages/patches/restic-0.9.6-fix-tests-for-go1.15.patch \ diff --git a/gnu/packages/chez.scm b/gnu/packages/chez.scm index 812d41fc5b..c627c4d842 100644 --- a/gnu/packages/chez.scm +++ b/gnu/packages/chez.scm @@ -269,6 +269,7 @@ Otherwise, SYSTEM can use only the ``portable bytecode'' backends." (base32 "0xchqq8cm0ka5wgpn18sjs0hh15rc3nb7xrjqbbc9al3asq0d7gc")) (file-name (git-file-name name version)) + (patches (search-patches "chez-scheme-bin-sh.patch")) (snippet #~(begin (use-modules (guix build utils)) ;; TODO: consider putting this in a (guix ...) or diff --git a/gnu/packages/patches/chez-scheme-bin-sh.patch b/gnu/packages/patches/chez-scheme-bin-sh.patch new file mode 100644 index 0000000000..7650914f01 --- /dev/null +++ b/gnu/packages/patches/chez-scheme-bin-sh.patch @@ -0,0 +1,76 @@ +From 3c838e6a0c3214d95bf02048cddccfd1b69a679f Mon Sep 17 00:00:00 2001 +From: Philip McGrath <philip@philipmcgrath.com> +Date: Thu, 19 May 2022 13:41:56 -0400 +Subject: [PATCH] patch s_process for "/bin/sh" on Guix + +If: + + 1. The nonstandard but ubiquitous macro `_PATH_BSHELL` from + <paths.h> is defined; and + + 2. The path specified by `_PATH_BSHELL` exists; + +then `s_process` will call `execl` with the file specified by +`_PATH_BSHELL` instead of "/bin/sh". + +Checking that the path specified by `_PATH_BSHELL` exists safeguards +against obscure errors if attempting to use stand-alone executables +built by the patched Racket in non-Guix envoronments. + +This patch does not change the behavior of `s_system`, which relies +on `system` from the C library. +--- + c/prim5.c | 21 ++++++++++++++++++++- + 1 file changed, 20 insertions(+), 1 deletion(-) + +diff --git a/c/prim5.c b/c/prim5.c +index 5a07893..bc2736c 100644 +--- a/c/prim5.c ++++ b/c/prim5.c +@@ -23,6 +23,12 @@ + #include <ctype.h> + #include <math.h> + ++/* BEGIN PATCH for Guix */ ++#ifndef WIN32 ++# include <paths.h> ++#endif ++/* END PATCH for Guix */ ++ + /* locally defined functions */ + static INT s_errno(void); + static iptr s_addr_in_heap(uptr x); +@@ -746,6 +752,17 @@ static ptr s_process(char *s, IBOOL stderrp) { + + INT tofds[2], fromfds[2], errfds[2]; + struct sigaction act, oint_act; ++ /* BEGIN PATCH for Guix */ ++#if defined(_PATH_BSHELL) ++ struct stat guix_stat_buf; ++ char *guix_sh = ++ (0 == stat(_PATH_BSHELL, &guix_stat_buf)) ++ ? _PATH_BSHELL ++ : "/bin/sh"; ++#else /* _PATH_BSHELL */ ++ char *guix_sh = "/bin/sh"; ++#endif ++ /* END PATCH for Guix */ + + if (pipe(tofds)) S_error("process","cannot open pipes"); + if (pipe(fromfds)) { +@@ -771,7 +788,9 @@ static ptr s_process(char *s, IBOOL stderrp) { + CLOSE(1); if (dup(fromfds[1]) != 1) _exit(1); + CLOSE(2); if (dup(stderrp ? errfds[1] : 1) != 2) _exit(1); + {INT i; for (i = 3; i < NOFILE; i++) (void)CLOSE(i);} +- execl("/bin/sh", "/bin/sh", "-c", s, NULL); ++ /* BEGIN PATCH for Guix */ ++ execl(guix_sh, guix_sh, "-c", s, NULL); ++ /* END PATCH for Guix */ + _exit(1) /* only if execl fails */; + /*NOTREACHED*/ + } else { + +base-commit: 9df56e7b25bc523663eac3da24be33afc5f76c84 +-- +2.32.0 + diff --git a/gnu/packages/patches/racket-chez-scheme-bin-sh.patch b/gnu/packages/patches/racket-chez-scheme-bin-sh.patch new file mode 100644 index 0000000000..65cf2f99f3 --- /dev/null +++ b/gnu/packages/patches/racket-chez-scheme-bin-sh.patch @@ -0,0 +1,76 @@ +From e982b6687494bf071386c67be74e57a29cf4ce00 Mon Sep 17 00:00:00 2001 +From: Philip McGrath <philip@philipmcgrath.com> +Date: Wed, 24 Aug 2022 19:55:14 -0400 +Subject: [PATCH] Chez Scheme: patch s_process for "/bin/sh" on Guix + +If: + + 1. The nonstandard but ubiquitous macro `_PATH_BSHELL` from + <paths.h> is defined; and + + 2. The path specified by `_PATH_BSHELL` exists; + +then `s_process` will call `execl` with the file specified by +`_PATH_BSHELL` instead of "/bin/sh". + +Checking that the path specified by `_PATH_BSHELL` exists safeguards +against obscure errors if attempting to use stand-alone executables +built by the patched Racket in non-Guix envoronments. + +This patch does not change the behavior of `s_system`, which relies +on `system` from the C library. +--- + racket/src/ChezScheme/c/prim5.c | 21 ++++++++++++++++++++- + 1 file changed, 20 insertions(+), 1 deletion(-) + +diff --git a/racket/src/ChezScheme/c/prim5.c b/racket/src/ChezScheme/c/prim5.c +index f5e3e345be..922421ca75 100644 +--- a/racket/src/ChezScheme/c/prim5.c ++++ b/racket/src/ChezScheme/c/prim5.c +@@ -22,6 +22,12 @@ + #include <limits.h> + #include <ctype.h> + ++/* BEGIN PATCH for Guix */ ++#ifndef WIN32 ++# include <paths.h> ++#endif ++/* END PATCH for Guix */ ++ + /* locally defined functions */ + static INT s_errno PROTO((void)); + static IBOOL s_addr_in_heap PROTO((uptr x)); +@@ -856,6 +862,17 @@ static ptr s_process(s, stderrp) char *s; IBOOL stderrp; { + + INT tofds[2], fromfds[2], errfds[2]; + struct sigaction act, oint_act; ++ /* BEGIN PATCH for Guix */ ++#if defined(_PATH_BSHELL) ++ struct stat guix_stat_buf; ++ char *guix_sh = ++ (0 == stat(_PATH_BSHELL, &guix_stat_buf)) ++ ? _PATH_BSHELL ++ : "/bin/sh"; ++#else /* _PATH_BSHELL */ ++ char *guix_sh = "/bin/sh"; ++#endif ++ /* END PATCH for Guix */ + + if (pipe(tofds)) S_error("process","cannot open pipes"); + if (pipe(fromfds)) { +@@ -881,7 +898,9 @@ static ptr s_process(s, stderrp) char *s; IBOOL stderrp; { + CLOSE(1); if (dup(fromfds[1]) != 1) _exit(1); + CLOSE(2); if (dup(stderrp ? errfds[1] : 1) != 2) _exit(1); + {INT i; for (i = 3; i < NOFILE; i++) (void)CLOSE(i);} +- execl("/bin/sh", "/bin/sh", "-c", s, NULL); ++ /* BEGIN PATCH for Guix */ ++ execl(guix_sh, guix_sh, "-c", s, NULL); ++ /* END PATCH for Guix */ + _exit(1) /* only if execl fails */; + /*NOTREACHED*/ + } else { + +base-commit: 9d228d16fb99c274c964e5bef93e97333888769f +-- +2.32.0 + diff --git a/gnu/packages/racket.scm b/gnu/packages/racket.scm index 319f63f9d2..0f766e7850 100644 --- a/gnu/packages/racket.scm +++ b/gnu/packages/racket.scm @@ -211,7 +211,8 @@ otherwise." (sha256 (base32 "0f9zyhdvbh4xsndrqjzl85j5ziz0rmqi676g9s1lw3h3skq2636h")) (file-name (git-file-name "racket" %racket-version)) - (patches (search-patches "racket-rktio-bin-sh.patch")) + (patches (search-patches "racket-chez-scheme-bin-sh.patch" + "racket-rktio-bin-sh.patch")) (modules '((guix build utils))) (snippet #~(begin |