cross-build: Add secure_getenv() for MacOS cross builds
Reviewed by: arichardson
Fixes: 68ca8363c7
("libc: Use secure_getenv(3) where appropriate")
Differential Revision: https://reviews.freebsd.org/D39295
This commit is contained in:
parent
fe5e6e2cc5
commit
0ec03c0b10
@ -204,7 +204,13 @@ CFLAGS.closefrom.c+= -DSTDC_HEADERS -DHAVE_SYS_DIR_H -DHAVE_DIRENT_H \
|
||||
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 @@ subr_capability.c: ${SRCTOP}/sys/kern/subr_capability.c
|
||||
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
|
||||
|
@ -42,6 +42,7 @@ __BEGIN_DECLS
|
||||
|
||||
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);
|
||||
|
||||
|
16
tools/build/cross-build/secure_getenv.c
Normal file
16
tools/build/cross-build/secure_getenv.c
Normal file
@ -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));
|
||||
}
|
Loading…
Reference in New Issue
Block a user