<pre style='margin:0'>
Clemens Lang (neverpanic) pushed a commit to branch master
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/5fc98b8874676bc97829f4643f4f635426c953b7">https://github.com/macports/macports-base/commit/5fc98b8874676bc97829f4643f4f635426c953b7</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 5fc98b8874676bc97829f4643f4f635426c953b7
</span>Author: Clemens Lang <cal@macports.org>
AuthorDate: Thu Sep 28 02:33:06 2023 +0200
<span style='display:block; white-space:pre;color:#404040;'> darwintrace: Use env.c from FreeBSD
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Since it becomes increasingly harder and harder to get an unsigned env
</span><span style='display:block; white-space:pre;color:#404040;'> binary that works as expected, include a stripped-down version of the
</span><span style='display:block; white-space:pre;color:#404040;'> FreeBSD env.c implementation for testing.
</span>---
src/darwintracelib1.0/tests/Makefile.in | 12 ++--
src/darwintracelib1.0/tests/env.c | 107 ++++++++++++++++++++++++++++++++
2 files changed, 112 insertions(+), 7 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/darwintracelib1.0/tests/Makefile.in b/src/darwintracelib1.0/tests/Makefile.in
</span><span style='display:block; white-space:pre;color:#808080;'>index 47df74db0..ed5b94c39 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/darwintracelib1.0/tests/Makefile.in
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/darwintracelib1.0/tests/Makefile.in
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -7,6 +7,7 @@ SRCS = \
</span> access.c \
close.c \
dup2.c \
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ env.c \
</span> execve.c \
fork.c \
lstat.c \
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -25,14 +26,11 @@ OBJS = $(SRCS:%.c=%.o)
</span> BINS = $(SRCS:%.c=%)
TESTS = $(sort $(wildcard *.test))
<span style='display:block; white-space:pre;background:#ffe0e0;'>-# Create a copy of env that doesn't have Apple's restricted bits set in order
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-# to preserve DYLD* variables.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-env:
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- dd if=/usr/bin/env of=env
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- chmod +x env
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+env: env.o
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $(CC) $(LDFLAGS) -o $@ $^
</span>
%: %.o ../darwintrace.dylib
<span style='display:block; white-space:pre;background:#ffe0e0;'>- $(CC) -o $@ $^
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $(CC) $(LDFLAGS) -o $@ $^
</span>
# Generate dependency information
%.d : %.c
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -47,7 +45,7 @@ clean::
</span> distclean:: clean
rm -f Makefile
<span style='display:block; white-space:pre;background:#ffe0e0;'>-test:: env $(BINS)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+test:: $(BINS)
</span> $(foreach test,$(TESTS),DARWINTRACE_SIP_WORKAROUND_PATH=@DARWINTRACE_SIP_WORKAROUND_PATH@ LC_ALL=C $(TCLSH) "$(srcdir)/$(test)";)
ifeq (,$(findstring clean,$(MAKECMDGOALS)))
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/darwintracelib1.0/tests/env.c b/src/darwintracelib1.0/tests/env.c
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 000000000..fbd563eed
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/darwintracelib1.0/tests/env.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,107 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * SPDX-License-Identifier: BSD-3-Clause
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Copyright (c) 1988, 1993, 1994
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * The Regents of the University of California. All rights reserved.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Redistribution and use in source and binary forms, with or without
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * modification, are permitted provided that the following conditions
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * are met:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * 1. Redistributions of source code must retain the above copyright
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * notice, this list of conditions and the following disclaimer.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * 2. Redistributions in binary form must reproduce the above copyright
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * notice, this list of conditions and the following disclaimer in the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * documentation and/or other materials provided with the distribution.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * 3. Neither the name of the University nor the names of its contributors
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * may be used to endorse or promote products derived from this software
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * without specific prior written permission.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * SUCH DAMAGE.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifndef lint
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+static const char copyright[] =
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+"@(#) Copyright (c) 1988, 1993, 1994\n\
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ The Regents of the University of California. All rights reserved.\n";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* not lint */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#if 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifndef lint
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+static char sccsid[] = "@(#)env.c 8.3 (Berkeley) 4/2/94";
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* not lint */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <sys/cdefs.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <sys/types.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <err.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <errno.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <stdio.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <stdlib.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <string.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <unistd.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+extern char **environ;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+static void usage(void);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Exit codes.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define EXIT_CANCELED 125 /* Internal error prior to exec attempt. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define EXIT_CANNOT_INVOKE 126 /* Program located, but not usable. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define EXIT_ENOENT 127 /* Could not find program to exec. */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+main(int argc, char **argv)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ char **ep, *p;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int ch;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int rtrn;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ while ((ch = getopt(argc, argv, "u:")) != -1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ switch(ch) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ case 'u':
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ rtrn = unsetenv(optarg);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (rtrn == -1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ err(EXIT_FAILURE, "unsetenv %s", optarg);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ break;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ case '?':
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ default:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ usage();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ for (argv += optind; *argv && (p = strchr(*argv, '=')); ++argv) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *p = '\0';
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ rtrn = setenv(*argv, p + 1, 1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *p = '=';
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (rtrn == -1)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ err(EXIT_FAILURE, "setenv %s", *argv);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (*argv) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ execvp(*argv, argv);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ err(errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "%s", *argv);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ for (ep = environ; *ep; ep++)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ (void)printf("%s%c", *ep, '\n');
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ exit(0);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+static void
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+usage(void)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ (void)fprintf(stderr,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "usage: env [-u name] [name=value ...] [utility [argument ...]]\n");
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ (void)fprintf(stderr, "%s\n", copyright);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ exit(1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span></pre><pre style='margin:0'>
</pre>