projects/guix·blob python-team · refs

79 lines · 2.4 KiB

1From cd6bed5d22ea9cb7bae2be134d5d04433fc8e313 Mon Sep 17 00:00:00 2001
2From: Philip McGrath <[email protected]>
3Date: Mon, 11 Apr 2022 20:43:18 -0400
4Subject: [PATCH] patch zuo_process for "/bin/sh" on Guix
5
6If:
7
8 1. The nonstandard but ubiquitous macro `_PATH_BSHELL` from
9 <paths.h> is defined; and
10
11 2. `zuo_process` is called with the exact path "/bin/sh"; and
12
13 3. The path specified by `_PATH_BSHELL` exists;
14
15then `zuo_process` will execute the file specified by `_PATH_BSHELL`
16instead of "/bin/sh".
17
18Checking that the path specified by `_PATH_BSHELL` exists safeguards
19against obscure errors if attempting to use the patched Zuo
20or derived executables in non-Guix envoronments.
21---
22
23Notes:
24 See also chez-scheme-bin-sh.patch, racket-chez-scheme-bin-sh.patch,
25 racket-rktio-bin-sh.patch.
26
27 zuo.c | 20 ++++++++++++++++++--
28 1 file changed, 18 insertions(+), 2 deletions(-)
29
30diff --git a/zuo.c b/zuo.c
31index d4163eb..bfc5484 100644
32--- a/zuo.c
33+++ b/zuo.c
34@@ -16,6 +16,7 @@
35 #include <string.h>
36 #include <ctype.h>
37 #ifdef ZUO_UNIX
38+# include <paths.h> /* PATCHED for Guix */
39 # include <fcntl.h>
40 # include <unistd.h>
41 # include <errno.h>
42@@ -5949,7 +5950,10 @@ static void zuo_pipe(zuo_raw_handle_t *_r, zuo_raw_handle_t *_w)
43 zuo_t *zuo_process(zuo_t *command_and_args)
44 {
45 const char *who = "process";
46- zuo_t *command = _zuo_car(command_and_args);
47+ /* BEGIN PATCH for Guix */
48+ zuo_t *_guix_orig_command = _zuo_car(command_and_args);
49+ zuo_t *command;
50+ /* END PATCH for Guix */
51 zuo_t *args = _zuo_cdr(command_and_args), *rev_args = z.o_null;
52 zuo_t *options = z.o_empty_hash, *opt;
53 zuo_t *dir, *l, *p_handle, *result;
54@@ -5960,7 +5964,19 @@ zuo_t *zuo_process(zuo_t *command_and_args)
55 void *env;
56 int as_child, exact_cmdline;
57
58- check_path_string(who, command);
59+ /* BEGIN PATCH for Guix */
60+ check_path_string(who, _guix_orig_command);
61+#if defined(_PATH_BSHELL)
62+ command =
63+ ((z.o_false == zuo_string_eql(_guix_orig_command, zuo_string("/bin/sh")))
64+ || (z.o_false == zuo_stat(zuo_string(_PATH_BSHELL), z.o_false, z.o_true)))
65+ ? _guix_orig_command
66+ : zuo_string(_PATH_BSHELL);
67+#else
68+ command = _guix_orig_command;
69+#endif
70+ /* END PATCH for Guix */
71+
72 for (l = args; l->tag == zuo_pair_tag; l = _zuo_cdr(l)) {
73 zuo_t *a = _zuo_car(l);
74 if (a == z.o_null) {
75
76base-commit: a0faa82c8383d206aa38d21462ca4ae699851a0b
77--
782.41.0
79