Closed vitorhmcorreia closed 6 years ago
What version of gcc and binutils are you using?
gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)
From APT: Package: binutils Version: 2.30-20ubuntu2~18.04
Help, anyone?
Try to recompile with -fPIC
?
Please, how can I go about doing that? I am using the install.sh script, should I change something there?
Thank you.
I haven't really tried it, but:
env CFLAGS="-fPIC" ./install.sh
No luck...
I just ran env CFLAGS="-fPIC" make TARGET=server V=1
to test, and here's the output:
cc -fPIC -O2 -DMAX_AGENTS=2048 -DOSSECHIDS -DDEFAULTDIR=\"/var/ossec\" -DUSER=\"ossec\" -DREMUSER=\"ossecr\" -DGROUPGLOBAL=\"ossec\" -DMAILUSER=\"ossecm\" -DLinux -DINOTIFY_ENABLED -DLIBOPENSSL_ENABLED -Wall -Wextra -I./ -I./headers/ -DARGV0=\"ossec-maild\" -c os_maild/maild.c -o os_maild/maild.o
cc -fPIC -O2 -DMAX_AGENTS=2048 -DOSSECHIDS -DDEFAULTDIR=\"/var/ossec\" -DUSER=\"ossec\" -DREMUSER=\"ossecr\" -DGROUPGLOBAL=\"ossec\" -DMAILUSER=\"ossecm\" -DLinux -DINOTIFY_ENABLED -DLIBOPENSSL_ENABLED -Wall -Wextra -I./ -I./headers/ -DARGV0=\"ossec-maild\" -c os_maild/sendmail.c -o os_maild/sendmail.o
cc -fPIC -O2 -DMAX_AGENTS=2048 -DOSSECHIDS -DDEFAULTDIR=\"/var/ossec\" -DUSER=\"ossec\" -DREMUSER=\"ossecr\" -DGROUPGLOBAL=\"ossec\" -DMAILUSER=\"ossecm\" -DLinux -DINOTIFY_ENABLED -DLIBOPENSSL_ENABLED -Wall -Wextra -I./ -I./headers/ -DARGV0=\"ossec-maild\" -c os_maild/sendcustomemail.c -o os_maild/sendcustomemail.o
cc -fPIC -O2 -DMAX_AGENTS=2048 -DOSSECHIDS -DDEFAULTDIR=\"/var/ossec\" -DUSER=\"ossec\" -DREMUSER=\"ossecr\" -DGROUPGLOBAL=\"ossec\" -DMAILUSER=\"ossecm\" -DLinux -DINOTIFY_ENABLED -DLIBOPENSSL_ENABLED -Wall -Wextra -I./ -I./headers/ -DARGV0=\"ossec-maild\" -c os_maild/config.c -o os_maild/config.o
cc -fPIC -O2 -DMAX_AGENTS=2048 -DOSSECHIDS -DDEFAULTDIR=\"/var/ossec\" -DUSER=\"ossec\" -DREMUSER=\"ossecr\" -DGROUPGLOBAL=\"ossec\" -DMAILUSER=\"ossecm\" -DLinux -DINOTIFY_ENABLED -DLIBOPENSSL_ENABLED -Wall -Wextra -I./ -I./headers/ -DARGV0=\"ossec-maild\" -c os_maild/os_maild_client.c -o os_maild/os_maild_client.o
cc -fPIC -O2 -DMAX_AGENTS=2048 -DOSSECHIDS -DDEFAULTDIR=\"/var/ossec\" -DUSER=\"ossec\" -DREMUSER=\"ossecr\" -DGROUPGLOBAL=\"ossec\" -DMAILUSER=\"ossecm\" -DLinux -DINOTIFY_ENABLED -DLIBOPENSSL_ENABLED -Wall -Wextra -I./ -I./headers/ -DARGV0=\"ossec-maild\" -c os_maild/mail_list.c -o os_maild/mail_list.o
...
cc -fPIC -O2 -DMAX_AGENTS=2048 -DOSSECHIDS -DDEFAULTDIR=\"/var/ossec\" -DUSER=\"ossec\" -DREMUSER=\"ossecr\" -DGROUPGLOBAL=\"ossec\" -DMAILUSER=\"ossecm\" -DLinux -DINOTIFY_ENABLED -DLIBOPENSSL_ENABLED -Wall -Wextra -I./ -I./headers/ os_maild/maild.o os_maild/sendmail.o os_maild/sendcustomemail.o os_maild/config.o os_maild/os_maild_client.o os_maild/mail_list.o os_crypto.a config.a shared.a os_net.a os_regex.a os_xml.a -lm -lpthread -lssl -lcrypto -o ossec-maild
(I removed some unrelated warnings) So it should be working. I get similar results for:
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28)
gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0
I also see -fPIC
being used when I run: env CFLAGS=-fPIC V=1 ./install.sh
Compiler:
CFLAGS -fPIC -O2 -DMAX_AGENTS=2048 -DOSSECHIDS -DDEFAULTDIR="/var/ossec" -DUSER="ossec" -DREMUSER="ossecr" -DGROUPGLOBAL="ossec" -DMAILUSER="ossecm" -DLinux -DINOTIFY_ENABLED -DLIBOPENSSL_ENABLED -Wall -Wextra -I./ -I./headers/
No luck, unfortunately :|
That doesn't give me a lot to go on.
Sorry Dan,
I was in a hurry, but still wanted to give you some feedback.
Here are the errors:
root@server:~/ossec/ossec-hids# env CFLAGS=-fPIC V=1 ./install.sh
Para instalação em português, escolha [br]. 要使用中文进行安装, 请选择 [cn]. Fur eine deutsche Installation wohlen Sie [de]. Για εγκατάσταση στα Ελληνικά, επιλέξτε [el]. For installation in English, choose [en]. Para instalar en Español , eliga [es]. Pour une installation en français, choisissez [fr] A Magyar nyelvű telepítéshez válassza [hu]. Per l'installazione in Italiano, scegli [it]. 日本語でインストールします.選択して下さい.[jp]. Voor installatie in het Nederlands, kies [nl]. Aby instalować w języku Polskim, wybierz [pl]. Для инструкций по установке на русском ,введите [ru]. Za instalaciju na srpskom, izaberi [sr]. ** Türkçe kurulum için seçin [tr]. (en/br/cn/de/el/es/fr/hu/it/jp/nl/pl/ru/sr/tr) [en]: OSSEC HIDS v3.0.0 Installation Script - http://www.ossec.net
You are about to start the installation process of the OSSEC HIDS. You must have a C compiler pre-installed in your system.
Host: server
-- Press ENTER to continue or Ctrl-C to abort. --
2- Setting up the installation environment.
- Installation will be made at /var/ossec .
5- Installing the system
Running the Makefile
cd external/lua-5.2.3/ && make posix
make[1]: Entering directory '/ossec/ossec-hids/src/external/lua-5.2.3'
cd src && make posix
make[2]: Entering directory '/ossec/ossec-hids/src/external/lua-5.2.3/src'
make all SYSCFLAGS="-DLUA_USE_POSIX"
make[3]: Entering directory '/ossec/ossec-hids/src/external/lua-5.2.3/src'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/ossec/ossec-hids/src/external/lua-5.2.3/src'
make[2]: Leaving directory '/ossec/ossec-hids/src/external/lua-5.2.3/src'
make[1]: Leaving directory '/ossec/ossec-hids/src/external/lua-5.2.3'
cc -fPIC -O2 -DMAX_AGENTS=2048 -DOSSECHIDS -DDEFAULTDIR=\"/var/ossec\" -DUSER=\"ossec\" -DREMUSER=\"ossecr\" -DGROUPGLOBAL=\"ossec\" -DMAILUSER=\"ossecm\" -DLinux -DINOTIFY_ENABLED -DLIBOPENSSL_ENABLED -DLOCAL -Wall -Wextra -I./ -I./headers/ os_maild/sendmail.o os_maild/sendcustomemail.o os_maild/config.o os_maild/os_maild_client.o os_maild/maild.o os_maild/mail_list.o os_crypto.a config.a shared.a os_net.a os_regex.a os_xml.a -lm -lpthread -lssl -lcrypto -o ossec-maild
/usr/bin/x86_64-linux-gnu-ld: os_maild/sendmail.o: relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC /usr/bin/x86_64-linux-gnu-ld: os_maild/config.o: relocation R_X86_64_32 against
.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: config.a(syscheck-config.o): relocation R_X86_64_32 against .rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC /usr/bin/x86_64-linux-gnu-ld: config.a(client-config.o): relocation R_X86_64_32 against
.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: config.a(email-alerts-config.o): relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC /usr/bin/x86_64-linux-gnu-ld: config.a(rules-config.o): relocation R_X86_64_32 against
.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: config.a(agentlessd-config.o): relocation R_X86_64_32S against .rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC /usr/bin/x86_64-linux-gnu-ld: config.a(alerts-config.o): relocation R_X86_64_32 against
.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: config.a(csyslogd-config.o): relocation R_X86_64_32S against .rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC /usr/bin/x86_64-linux-gnu-ld: config.a(localfile-config.o): relocation R_X86_64_32 against
.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: config.a(rootcheck-config.o): relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC /usr/bin/x86_64-linux-gnu-ld: config.a(remote-config.o): relocation R_X86_64_32 against
.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: config.a(reports-config.o): relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC /usr/bin/x86_64-linux-gnu-ld: config.a(dbd-config.o): relocation R_X86_64_32 against
.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: shared.a(mem_op.o): relocation R_X86_64_32 against .rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC /usr/bin/x86_64-linux-gnu-ld: shared.a(regex_op.o): relocation R_X86_64_32 against
.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: shared.a(help.o): relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC /usr/bin/x86_64-linux-gnu-ld: shared.a(privsep_op.o): relocation R_X86_64_32 against
.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: shared.a(debug_op.o): relocation R_X86_64_32S against .rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC /usr/bin/x86_64-linux-gnu-ld: shared.a(sig_op.o): relocation R_X86_64_32 against
.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: shared.a(store_op.o): relocation R_X86_64_32 against .rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC /usr/bin/x86_64-linux-gnu-ld: os_regex.a(os_regex_compile.o): relocation R_X86_64_32S against symbol
charmap' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: os_regex.a(os_match_compile.o): relocation R_X86_64_32S against symbol charmap' can not be used when making a PIE object; recompile with -fPIC /usr/bin/x86_64-linux-gnu-ld: os_regex.a(os_regex_execute.o): relocation R_X86_64_32S against symbol
regexmap' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: os_regex.a(os_match_execute.o): relocation R_X86_64_32S against symbol `charmap' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
Makefile:848: recipe for target 'ossec-maild' failed
make: *** [ossec-maild] Error 1
Error 0x5. Building error. Unable to finish the installation.
Did you make clean
in the src dir before trying to compile? You could also try adding -no-pie
to the CFLAGS.
env CFLAGS="-fPIC -nopie" V=1 ./install.sh
Bingo!
Ran 'make clean' in src dir. and then 'env CFLAGS="-fPIC -no-pie" V=1 ./install.sh' worked perfectly.
Thank you so much for your help and time.
I want to understand the problem, can you please explain your train of thought?
I can, but not well! The error complains about -fPIE
, and tells us to use -fPIC
. That didn't work, so there must be some default adding in the -fPIE
in there silently. I kind of remembered an option to disable PIE, so I googled it.
As for the make clean
, the output you provided looked too short, so something was being cached. I just wanted to make sure that wasn't affecting anything.
Brilliant stuff, Dan!
Again, I really appreciate your time and effort :)
Hey i have tried the above but still i am getting the below error could you please help me on it
5- Installing the system
Error 0x5. Building error. Unable to finish the installation.
@sachin078 What cc and version of that cc are you using? You should be using llvm/clang or gnu gcc
[root]# cc --version cc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44) Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[root]# [root]# cc -Q -v Using built-in specs. COLLECT_GCC=cc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux Thread model: posix gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
I am actually facing this issue while installing the OSSEC agent.
Wow, ok that's pretty old. I guess remove the -no-pie
stuff or install a reasonable compiler.
which compiler would you recommend to install.
Do you want me to upgrade and test it?
I am getting the below error while installing it without -no-pie
.o os_maild/maild.o os_maild/mail_list.o os_crypto.a config.a shared.a os_net.a os_regex.a os_xml.a -lm -lpthread -lsystemd -lpcre2-8 -lssl -lcrypto -lz ./external/compat/imsg.c ./external/compat/imsg-buffer.c -o ossec-maild /usr/bin/ld: cannot find -lsystemd collect2: error: ld returned 1 exit status make: *** [ossec-maild] Error 1
Error 0x5. Building error. Unable to finish the installation.
I don't know if a system that old has the systemd libs, but if it does you need to install them. Not sure how to handle legacy systems beyond that though. Maybe build with USE_SYSTEMD=no
?
should i upgrade my cc
I don't know enough about your system to make that kind of decision.
@ddpbsd Please let me know what information is required. I am not able to resolve this error from past 3 days it would be great if you could help me.
@sachin078 Which error? You solved the -no-pie
one by removing that flag from the build, and the lack of the systemd libs can be solved by either installing the systemd libs or building without the systemd stuff.
I installed systemd libs but now i am getting the below error.
l/compat/imsg-buffer.c -o ossec-maild /usr/bin/ld: cannot find -lsystemd collect2: error: ld returned 1 exit status make: *** [ossec-maild] Error 1
Error 0x5. Building error. Unable to finish the installation.
I'm not sure, you'll have to do some troubleshooting.
Is there some reason youre using 3.0.0? Have you tried the 3.8.0 version?
@mikegotroot99 They're not using 3.0.0, they're using 3.6.0 (the latest version I'm aware of). I don't think the systemd stuff was added until 3.6. They just lazily re-used a slightly similar issue instead of creating a new one.
Based on the age of their gcc, I'm guessing @sachin078 is using an old distribution (I don't think it's specified in the thread anywhere), so disabling systemd with env USE_SYSTEMD=no ./install.sh
is probably the best option. It's only for reading journald binary logs which distributions from that long ago didn't use (to the best of my knowledge).
Compilation / installation fails on Ubuntu Linux 4.15.13 64 bits
Relevant logs:
(...) /usr/bin/x86_64-linux-gnu-ld: shared.a(store_op.o): relocation R_X86_64_32 against
.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC /usr/bin/x86_64-linux-gnu-ld: os_regex.a(os_regex_compile.o): relocation R_X86_64_32S against symbol
charmap' can not be used when making a PIE object; recompile with -fPIC /usr/bin/x86_64-linux-gnu-ld: os_regex.a(os_match_compile.o): relocation R_X86_64_32S against symbolcharmap' can not be used when making a PIE object; recompile with -fPIC /usr/bin/x86_64-linux-gnu-ld: os_regex.a(os_regex_execute.o): relocation R_X86_64_32S against symbol
regexmap' can not be used when making a PIE object; recompile with -fPIC /usr/bin/x86_64-linux-gnu-ld: os_regex.a(os_match_execute.o): relocation R_X86_64_32S against symbol `charmap' can not be used when making a PIE object; recompile with -fPIC /usr/bin/x86_64-linux-gnu-ld: final link failed: Nonrepresentable section on output collect2: error: ld returned 1 exit status Makefile:839: recipe for target 'ossec-maild' failed make: *** [ossec-maild] Error 1Error 0x5. Building error. Unable to finish the installation.
(..)
Previous version: 2.9.3, working fine. No major changes to the server have been made lately. Full install log in attach.
Any ideias?
Best regards, Vitor Correia
ossec_install_log.log