1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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
|