Skip to content

Commit

Permalink
Merge pull request #53 from jrossi/travis-ci-build-windows
Browse files Browse the repository at this point in the history
Travis ci build windows and fix for setenv not being avaiable on win32
  • Loading branch information
ddpbsd committed Feb 18, 2014
2 parents 5c22490 + 624261c commit 5e85f85
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 14 deletions.
40 changes: 39 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
language: c

script: ( cd src && make all )
env:
#- DB=mysql OSSEC_TYPE=all GEOIP=yes
- DB=mysql OSSEC_TYPE=all GEOIP=no
#- DB=none OSSEC_TYPE=all GEOIP=yes
- DB=none OSSEC_TYPE=all GEOIP=no
- DB=none OSSEC_TYPE=agent GEOIP=no
- DB=none OSSEC_TYPE=windows_agent GEOIP=no



compiler:
- gcc



before_script:
- if [[ "$DB" == "mysql" ]]; then ( cd src && make setdb ); fi
- if [[ "$GEOIP" == "yes" ]]; then ( sudo apt-get install geoip-bin geoip-database libgeoip-dev libgeoip1 ); fi
- if [[ "$GEOIP" == "yes" ]]; then ( cd src && make setgeoip ); fi
- if [[ "$OSSEC_TYPE" == "windows_agent" ]]; then ( sudo apt-get install mingw32 mingw32-binutils mingw32-runtime nsis ); fi



script:
- ( cd src && sudo make $OSSEC_TYPE )

before_deploy:
- mkdir travis-builds
- if [[ "$OSSEC_TYPE" == "windows_agent" ]]; then ( cp src/win-pkg/ossec-win32-agent.exe travis-builds/ossec-win32-agent-bid:$TRAVIS_JOB_NUMBER-br:$TRAVIS_BRANCH.exe ); fi


deploy:
provider: s3
access_key_id: AKIAIJNKNIB2ARNBYMOA
secret_access_key:
secure: QXvGH4lhTWEiPuTjpC+bN5Uo25O3U09w75iIXXPx0xYtQcLC4zni884Z7LI5tJy8mZwHvg5ywzJWMWjeudvXS5p1I6Ixl/elk6gglkdUBeKgLQqGEmlk+7N4WM89mpvXGsp+Oa/bMaBCuae+lawat3uuBQvj51dmSHHHXaE8UJM=
bucket: ossec-travis-ci
upload-dir: ossec-hids
local-dir: travis-builds
12 changes: 12 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ clean:
@/bin/sh ./Makeall clean
rm -f ../bin/ossec*
rm -f ../bin/manage_agents
rm -rf win-pkg/
rm Config.OS
rm win32/LICENSE.txt
rm win32/help_win.txt
rm win32/internal_options-win.conf
rm win32/ossec-win.conf
rm win32/restart-ossec.cmd
rm win32/route-null.cmd

all:
@/bin/sh ./Makeall all
Expand All @@ -43,6 +51,10 @@ local:
agent:
@/bin/sh ./InstallAgent.sh

windows_agent:
( cd win32 && /bin/sh ./gen_win.sh )
( cd win-pkg && /bin/sh ./make.sh )

setagent:
@echo "CEXTRA=-DCLIENT" >> ./Config.OS

Expand Down
10 changes: 10 additions & 0 deletions src/addagent/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@
#include "manage_agents.h"
#include <stdlib.h>

#if defined(__MINGW32__)
static int setenv(const char * name, const char * val, int overwrite) {
int len = strlen(name) + strlen(val) + 2;
char * str = (char *)malloc(len);
snprintf(str, len, "%s=%s", name, val);
putenv(str);
return 0;
}
#endif

/** help **/
void helpmsg()
{
Expand Down
39 changes: 28 additions & 11 deletions src/win32/make.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@
echo Making windows agent
BASES="${MING_BASE} amd64-mingw32msvc i586-mingw32msvc i686-pc-mingw32 i686-w64-mingw32"

i686-w64-mingw32-windres -i icofile.rc -o icon.o
i686-w64-mingw32-gcc -o ossec-agent.exe -Wall -DARGV0=\"ossec-agent\" -DCLIENT -DWIN32 -DOSSECHIDS icon.o os_regex/*.c os_net/*.c os_xml/*.c zlib-1.2.3/*.c config/*.c shared/*.c os_execd/*.c os_crypto/blowfish/*.c os_crypto/md5/*.c os_crypto/sha1/*.c os_crypto/md5_sha1/*.c os_crypto/shared/*.c rootcheck/*.c *.c -Iheaders/ -I./ -lwsock32
#i686-w64-mingw32-gcc -o ossec-agent-eventchannel.exe -Wall -DARGV0=\"ossec-agent\" -DCLIENT -DWIN32 -DOSSECHIDS -DEVENTCHANNEL_SUPPORT icon.o os_regex/*.c os_net/*.c os_xml/*.c zlib-1.2.3/*.c config/*.c shared/*.c os_execd/*.c os_crypto/blowfish/*.c os_crypto/md5/*.c os_crypto/sha1/*.c os_crypto/md5_sha1/*.c os_crypto/shared/*.c rootcheck/*.c *.c -Iheaders/ -I./ -lwsock32 -lwevtapi
i686-w64-mingw32-gcc -o ossec-rootcheck.exe -Wall -DARGV0=\"ossec-rootcheck\" -DCLIENT -DWIN32 icon.o os_regex/*.c os_net/*.c os_xml/*.c config/*.c shared/*.c win_service.c rootcheck/*.c -Iheaders/ -I./ -lwsock32
i686-w64-mingw32-gcc -o manage_agents.exe -Wall -DARGV0=\"ossec-agent\" -DCLIENT -DWIN32 -DMA os_regex/*.c zlib-1.2.3/*.c os_zlib.c shared/*.c os_crypto/blowfish/*.c os_crypto/md5/*.c os_crypto/shared/*.c addagent/*.c -Iheaders/ -I./ -lwsock32
i686-w64-mingw32-gcc -o setup-windows.exe -Wall os_regex/*.c -DARGV0=\"setup-windows\" -DCLIENT -DWIN32 win_service.c shared/file_op.c shared/debug_op.c setup/setup-win.c setup/setup-shared.c -Iheaders/ -I./ -lwsock32
i686-w64-mingw32-gcc -o setup-syscheck.exe -Wall os_regex/*.c os_xml/*.c setup/setup-syscheck.c setup/setup-shared.c -I./ -Iheaders/
i686-w64-mingw32-gcc -o service-start.exe -Wall icon.o os_regex/*.c setup/service-start.c -I./
i686-w64-mingw32-gcc -o service-stop.exe -Wall os_regex/*.c setup/service-stop.c -I./
i686-w64-mingw32-gcc -o setup-iis.exe -Wall os_regex/*.c setup/setup-iis.c -I./
i686-w64-mingw32-gcc -o add-localfile.exe -Wall os_regex/*.c setup/add-localfile.c -I./
for i in ${BASES}; do
which ${i}-gcc
if [ "$?" = "0" ]; then
export MING_BASE=${i}
fi
done

#echo ${MING_BASE}


${MING_BASE}-windres -i icofile.rc -o icon.o
${MING_BASE}-gcc -o ossec-agent.exe -Wall -DARGV0=\"ossec-agent\" -DCLIENT -DWIN32 -DOSSECHIDS icon.o os_regex/*.c os_net/*.c os_xml/*.c zlib-1.2.3/*.c config/*.c shared/*.c os_execd/*.c os_crypto/blowfish/*.c os_crypto/md5/*.c os_crypto/sha1/*.c os_crypto/md5_sha1/*.c os_crypto/shared/*.c rootcheck/*.c *.c -Iheaders/ -I./ -lwsock32
#${MING_BASE}-gcc -o ossec-agent-eventchannel.exe -Wall -DARGV0=\"ossec-agent\" -DCLIENT -DWIN32 -DOSSECHIDS -DEVENTCHANNEL_SUPPORT icon.o os_regex/*.c os_net/*.c os_xml/*.c zlib-1.2.3/*.c config/*.c shared/*.c os_execd/*.c os_crypto/blowfish/*.c os_crypto/md5/*.c os_crypto/sha1/*.c os_crypto/md5_sha1/*.c os_crypto/shared/*.c rootcheck/*.c *.c -Iheaders/ -I./ -lwsock32 -lwevtapi
${MING_BASE}-gcc -o ossec-rootcheck.exe -Wall -DARGV0=\"ossec-rootcheck\" -DCLIENT -DWIN32 icon.o os_regex/*.c os_net/*.c os_xml/*.c config/*.c shared/*.c win_service.c rootcheck/*.c -Iheaders/ -I./ -lwsock32
${MING_BASE}-gcc -o manage_agents.exe -Wall -DARGV0=\"ossec-agent\" -DCLIENT -DWIN32 -DMA os_regex/*.c zlib-1.2.3/*.c os_zlib.c shared/*.c os_crypto/blowfish/*.c os_crypto/md5/*.c os_crypto/shared/*.c addagent/*.c -Iheaders/ -I./ -lwsock32
${MING_BASE}-gcc -o setup-windows.exe -Wall os_regex/*.c -DARGV0=\"setup-windows\" -DCLIENT -DWIN32 win_service.c shared/file_op.c shared/debug_op.c setup/setup-win.c setup/setup-shared.c -Iheaders/ -I./ -lwsock32
${MING_BASE}-gcc -o setup-syscheck.exe -Wall os_regex/*.c os_xml/*.c setup/setup-syscheck.c setup/setup-shared.c -I./ -Iheaders/
${MING_BASE}-gcc -o service-start.exe -Wall icon.o os_regex/*.c setup/service-start.c -I./
${MING_BASE}-gcc -o service-stop.exe -Wall os_regex/*.c setup/service-stop.c -I./
${MING_BASE}-gcc -o setup-iis.exe -Wall os_regex/*.c setup/setup-iis.c -I./
${MING_BASE}-gcc -o add-localfile.exe -Wall os_regex/*.c setup/add-localfile.c -I./

cd ui
sh ./make.sh
cd ../

makensis ui.nsi
makensis ossec-installer.nsi

echo Making windows agent with eventchannel support

${MING_BASE}-gcc -o ossec-agent.exe -Wall -DARGV0=\"ossec-agent\" -DCLIENT -DWIN32 -DOSSECHIDS -DEVENTCHANNEL_SUPPORT icon.o os_regex/*.c os_net/*.c os_xml/*.c zlib-1.2.3/*.c config/*.c shared/*.c os_execd/*.c os_crypto/blowfish/*.c os_crypto/md5/*.c os_crypto/sha1/*.c os_crypto/md5_sha1/*.c os_crypto/shared/*.c rootcheck/*.c *.c -Iheaders/ -I./ -lwsock32 -lwevtapi

makensis -DOutFile=ossec-win32-agent-with-eventchannel.exe ossec-installer.nsi
4 changes: 2 additions & 2 deletions src/win32/ui/make.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
echo Making windows agent UI

i686-w64-mingw32-windres -o resource.o win32ui.rc
i686-w64-mingw32-gcc -o os_win32ui.exe -Wall -DARGV0=\"ossec-agent\" -DCLIENT -DWIN32 resource.o ../os_net/*.c ../os_xml/*.c ../addagent/b64.c ../shared/validate_op.c ../shared/debug_op.c ../win_service.c *.c -I../headers/ -I../ -lcomctl32 -mwindows -lwsock32
${MING_BASE}-windres -o resource.o win32ui.rc
${MING_BASE}-gcc -o os_win32ui.exe -Wall -DARGV0=\"ossec-agent\" -DCLIENT -DWIN32 resource.o ../os_net/*.c ../os_xml/*.c ../addagent/b64.c ../shared/validate_op.c ../shared/debug_op.c ../win_service.c *.c -I../headers/ -I../ -lcomctl32 -mwindows -lwsock32
cp -pr os_win32ui.exe ../
cd ../

0 comments on commit 5e85f85

Please sign in to comment.