From 563670ff4bb6c50a91aa31427078515a85a92ce3 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 14 Dec 2020 13:30:20 +0000 Subject: Add chroot sysdep, fix endianness sysdep string in .h --- configure | 1 + src/sysdeps/trychroot.c | 20 ++++++++++++++++++++ tools/gen-sysdepsh.sh | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/sysdeps/trychroot.c diff --git a/configure b/configure index dec5e15..0376555 100755 --- a/configure +++ b/configure @@ -636,6 +636,7 @@ choose cl namespaces 'namespaces' choose cl nsgetparent 'NS_GET_PARENT' choose cl explicit_bzero 'explicit_bzero()' choose cl getrandom 'getrandom()' +choose cl chroot 'chroot()' # Here are the evil irreducible run-time sysdeps. choose clr devurandom '/dev/urandom' diff --git a/src/sysdeps/trychroot.c b/src/sysdeps/trychroot.c new file mode 100644 index 0000000..42d8872 --- /dev/null +++ b/src/sysdeps/trychroot.c @@ -0,0 +1,20 @@ +/* ISC license. */ + +#undef _POSIX_C_SOURCE +#undef _XOPEN_SOURCE + +#ifndef _BSD_SOURCE +#define _BSD_SOURCE +#endif + +#ifndef _DEFAULT_SOURCE +#define _DEFAULT_SOURCE +#endif + +#include + +int main (void) +{ + if (chroot("/") < 0) return 1 ; + return 0 ; +} diff --git a/tools/gen-sysdepsh.sh b/tools/gen-sysdepsh.sh index fc9ccbd..8373f8f 100755 --- a/tools/gen-sysdepsh.sh +++ b/tools/gen-sysdepsh.sh @@ -26,7 +26,7 @@ while read k v ; do echo "#define SKALIBS_$k $v" elif test ${k} = ENDIANNESS ; then echo '#undef SKALIBS_ENDIANNESS' - echo "#define SKALIBS_ENDIANNESS $v" + echo "#define SKALIBS_ENDIANNESS \"$v\"" else echo "#undef SKALIBS_HAS$k" if test $v = yes ; then -- cgit v1.2.3