_XOPEN_SOURCE redefined - include order
Enables PAM modules to be written in Python
Brought to you by:
rstuart
During make lib
compilation I get the following error:
[ 62s] gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -Wall -Wextra -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wsign-compare -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Werror -I/usr/local/lib/ -fPIC -DLIBPYTHON_SO="libpython2.6.so.1.0" -I/usr/include/python2.6 -c pam_python.c -o build/temp.linux-x86_64-2.6/pam_python.o [ 62s] In file included from /usr/include/python2.6/pyconfig.h:6, [ 62s] from /usr/include/python2.6/Python.h:8, [ 62s] from pam_python.c:43: [ 62s] /usr/include/python2.6/pyconfig-64.h:1043:1: error: "_XOPEN_SOURCE" redefined [ 62s] In file included from /usr/include/stdlib.h:25, [ 62s] from /usr/include/security/_pam_macros.h:12, [ 62s] from pam_python.c:33: [ 62s] /usr/include/features.h:164:1: error: this is the location of the previous definition [ 63s] error: command 'gcc' failed with exit status 1 [ 63s] make[1]: *** [pam_python.so] Error 1
In order to fix this I moved the python header include to the beginning (see attached patch file).
I can reproduce this on CentOS 6 and 7. With the attached patch file the module works on both platforms.
I too encountered this issue while attempting to build the module on RHEL 7. Moving the Python.h up as described addressed the issue.
version: 1.0.6
Last edit: Danny 2019-06-13