Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F164582117
D39295.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D39295.diff
View Options
diff --git a/tools/build/Makefile b/tools/build/Makefile
--- a/tools/build/Makefile
+++ b/tools/build/Makefile
@@ -204,7 +204,13 @@
SRCS+= progname.c
# Stub implementations of fflagstostr/strtofflags
SRCS+= fflags.c
-.endif
+.endif # ${MAKE.OS} == "Linux"
+
+.if ${.MAKE.OS} == "Darwin"
+# Standalone implementation of secure_getenv(), not available on MacOS.
+SRCS+= secure_getenv.c
+.endif # ${MAKE.OS} == "Darwin"
+
# Provide the same arc4random implementation on Linux/macOS
CFLAGS.arc4random.c+= -I${SRCTOP}/sys/crypto/chacha20 -D__isthreaded=1
SRCS+= arc4random.c arc4random_uniform.c
@@ -227,7 +233,7 @@
cp ${.ALLSRC} ${.TARGET}
SRCS+= subr_capability.c
CLEANFILES+= subr_capability.c
-.endif
+.endif # ${MAKE.OS} != "FreeBSD"
CASPERINC+= ${SRCTOP}/lib/libcasper/services/cap_fileargs/cap_fileargs.h
CASPERINC+= ${SRCTOP}/lib/libcasper/services/cap_net/cap_net.h
diff --git a/tools/build/cross-build/include/mac/stdlib.h b/tools/build/cross-build/include/mac/stdlib.h
--- a/tools/build/cross-build/include/mac/stdlib.h
+++ b/tools/build/cross-build/include/mac/stdlib.h
@@ -42,6 +42,7 @@
int rpmatch(const char *response);
+char *secure_getenv(const char *name);
long long strtonum(const char *numstr, long long minval, long long maxval,
const char **errstrp);
diff --git a/tools/build/cross-build/secure_getenv.c b/tools/build/cross-build/secure_getenv.c
new file mode 100644
--- /dev/null
+++ b/tools/build/cross-build/secure_getenv.c
@@ -0,0 +1,16 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2023 Mark Johnston <markj@FreeBSD.org>
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+
+char *
+secure_getenv(const char *name)
+{
+ if (issetugid() != 0)
+ return (NULL);
+ return (getenv(name));
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Aug 3, 5:02 AM (8 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35895932
Default Alt Text
D39295.diff (1 KB)
Attached To
Mode
D39295: cross-build: Add secure_getenv() for MacOS cross builds
Attached
Detach File
Event Timeline
Log In to Comment