OpenSCAP / openscap

NIST Certified SCAP 1.2 toolkit
https://www.open-scap.org/tools/openscap-base
GNU Lesser General Public License v2.1
1.38k stars 380 forks source link

OpenSCAP 1.2.8 fails to compile on Solaris 10/SPARC #390

Closed skrueger8 closed 9 months ago

skrueger8 commented 8 years ago

Hi,

OpenSCAP doesn't compile on Solaris 10/SPARC.

Step to reproduce:

PATH=$PATH:/usr/lib/gnome-private/bin \
PKG_CONFIG_PATH=/usr/lib/pkgconfig:/opt/sfw/lib/pkgconfig  \
./configure MAKE=gmake \
CC=gcc CFLAGS='-g -std=c99 -DNDEBUG -DOSCAP_THREAD_SAFE' \
CPPFLAGS='-I/usr/include/openldap -I/usr/include/pcre -I/opt/sfw/include' \
LDFLAGS='-R/opt/sfw/lib -L/opt/sfw/lib' \
LIBS="-lnsl -lsocket -lscf -lsec -lzonecfg" \
--enable-debug=no --enable-sce=yes --enable-perl=no --enable-python=no \
--prefix=/opt/openscap --with-crypto=nss3

Here are the issues I've faced so far:

  1. program_invocation_short_name and pthread_getname_np
debug.c: In function `debug_message_start':
debug.c:166: error: `program_invocation_short_name' undeclared (first use in this function)
debug.c: In function `debug_message_devel_metadata':
debug.c:175: warning: implicit declaration of function `pthread_getname_np'
debug.c:178: error: `program_invocation_short_name' undeclared (first use in this function)

program_invocation_short_name seems to be only available on Linux, and pthread_{set,get}name_np() are only available in Solaris 11.3 or higher.

pthread_setname_np is also used in

debug.c:98: warning: implicit declaration of function `open'
debug.c:98: error: `O_APPEND' undeclared (first use in this function)
debug.c:98: error: (Each undeclared identifier is reported only once
debug.c:98: error: for each function it appears in.)
debug.c:98: error: `O_WRONLY' undeclared (first use in this function)
debug.c:109: error: `O_CREAT' undeclared (first use in this function)
debug.c:109: error: `O_TRUNC' undeclared (first use in this function)
debug.c:110: error: `S_IRUSR' undeclared (first use in this function)
debug.c:110: error: `S_IWUSR' undeclared (first use in this function)
debug.c:110: error: `S_IRGRP' undeclared (first use in this function)
debug.c:110: error: `S_IWGRP' undeclared (first use in this function)
debug.c:110: error: `S_IROTH' undeclared (first use in this function)
debug.c:110: error: `S_IWOTH' undeclared (first use in this function)

Fixed by adding #include <fcntl.h>

  1. PATH_MAX in src/OVAL/oval_session.c
oval_session.c: In function `oval_session_export':
oval_session.c:422: error: `PATH_MAX' undeclared (first use in this function)

Fixed by adding #include <limits.h>

  1. MNTTYPE_SMBFS undefined in src/OVAL/probes/oval_fts.c
probes/oval_fts.c: In function `valid_remote_fs':
probes/oval_fts.c:151: error: `MNTTYPE_SMBFS' undeclared (first use in this function)
probes/oval_fts.c:151: error: (Each undeclared identifier is reported only once

Sadly MNTTYPE_SMBFS is not defined in Solaris 10's /usr/include/sys/mntent.h, I had to comment it out.

  1. Missing header in src/OVAL/probes/independent/system_info.c
independent/system_info.c:123:21: ifaddrs.h: No such file or directory
independent/system_info.c:135: warning: "struct ifaddrs" declared inside parameter list
independent/system_info.c:135: warning: its scope is only this definition or declaration, which is probably not what you want
independent/system_info.c: In function `get_mac':
independent/system_info.c:148: error: dereferencing pointer to incomplete type
independent/system_info.c:151: error: `IFF_IPMP' undeclared (first use in this function)
independent/system_info.c:151: error: (Each undeclared identifier is reported only once
independent/system_info.c:151: error: for each function it appears in.)
independent/system_info.c:164: error: `DLPI_INFO_VERSION' undeclared (first use in this function)

Sadly this header is only available on Solaris 11 as well. I had to #if 0 get_mac() and get_ifs().

  1. Missing functions stpcpy() and strndup()

Used in

You can get them from:

http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libc/port/gen/stpcpy.c and http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libc/port/gen/strndup.c

  1. Final linking errors are missing xsltInit() + xmlDOMWrapCloneNode()
nm /usr/lib/libxslt.so | grep -w xsltInit
[254]   |     43748|        12|FUNC |LOCL |0    |10     |xsltInit

xsltInit() seems to be there but it's not exposed as a function you can call. I had to comment it out in src/common/oscapxml.c

The real show stopper is xmlDOMWrapCloneNode(), seems like Solaris 10's libxml2 is way too old for this:

$ nm /usr/lib/libxml2.so | grep xmlDOMWrapCloneNode
nada
mpreisler commented 8 years ago

Hi, could you please provide a pull request for the fixes you suggested?

mpreisler commented 7 years ago

Original author didn't provide a pull request but the changes in this are valuable. If somebody could turn this or at least parts of it into a pull request that'd be great.

akcrisp commented 6 years ago

Hi, I know this ticket is couple years old. Just wondering if any progress was actually made in getting this to work on solaris 10 sparc ? Or ideally if anyone has a working package.

Michael-Angel-Sec commented 2 years ago

@jan-cerny @akcrisp @skrueger8 Thanks for this great work. I understand this is several years old. Solaris 11 has OpenSCAP included in vendor repos [1]. Any luck on getting openscap working on Solaris 10 SPARC?

[1] https://blogs.oracle.com/solaris/post/compliance-reporting-with-scap