Module: check_mk
Branch: master
Commit: 0d0c71a51896912095dd69ccb77ad26709700e02
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0d0c71a5189691…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Fri Sep 29 12:57:28 2017 +0200
Prevent Windows agent make outside chroot jail
Force to use make-agent script instead.
Change-Id: Ib59a77e47c7cc67d4eac748acd49527db61ab2b8
---
agents/windows/Makefile | 10 ++++++++++
agents/windows/do-chroot | 5 +++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/agents/windows/Makefile b/agents/windows/Makefile
index 1b0afb6..8f7aa27 100644
--- a/agents/windows/Makefile
+++ b/agents/windows/Makefile
@@ -40,6 +40,16 @@ MKDIR = mkdir -p
POSTCOMPILE = mv -f -u $(DEPDIR)/$*.Td $(DEPDIR)/$*.d
+EMPTY :=
+ifneq (,$(MAKECMDGOALS))
+ SEPARATOR := $(EMPTY) $(EMPTY)
+endif
+
+# Check if called inside chroot jail.
+ifneq (WinAgent,$(CHROOTNAME))
+ $(error "Not allowed outside chroot. Please call
'./make-agent$(SEPARATOR)$(MAKECMDGOALS)' instead")
+endif
+
ifeq ($(shell uname),Linux)
CXX = i686-w64-mingw32-g++-posix
CXX_64 = x86_64-w64-mingw32-g++-posix
diff --git a/agents/windows/do-chroot b/agents/windows/do-chroot
index f1db6ec..be4ccd8 100755
--- a/agents/windows/do-chroot
+++ b/agents/windows/do-chroot
@@ -6,6 +6,7 @@ CMD="$1"
export HOSTNAME=cmk-windows-agent-chroot
unset LANG
+CHROOTNAME=WinAgent
BASE="$(dirname "$(dirname "$(cd "$(dirname
"${BASH_SOURCE[0]}")" && pwd)")")"
MNT=$BASE/agents/windows/chroot
@@ -27,9 +28,9 @@ if [ ! -e $MNT/build/Makefile ] ; then
fi
if [ -n "$CMD" ] ; then
- chroot chroot bash -c "$CMD"
+ chroot chroot /usr/bin/env CHROOTNAME=$CHROOTNAME bash -c "$CMD"
else
- chroot chroot bash -l
+ chroot chroot /usr/bin/env CHROOTNAME=$CHROOTNAME bash -l
fi
umount $MNT/build