Skip to content

Commit 50e4961

Browse files
author
Felipe Zimmerle
committed
Uses autotools to idenfiy if sys/utsname.h is present
Fix build problem on the msc_status_engine, reported by: Walter Hop and Derek Werthmuller.
1 parent 3323137 commit 50e4961

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

apache2/msc_status_engine.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "msc_status_engine.h"
1616
#include "apr_sha1.h"
17+
#include "modsecurity_config.h"
1718

1819
#ifdef WIN32
1920
#include <winsock2.h>
@@ -26,20 +27,20 @@
2627
#include <net/if.h>
2728
#include <net/if_dl.h>
2829
#include <netinet/in.h>
29-
#include <sys/utsname.h>
3030
#include <sys/types.h>
3131
#include <sys/socket.h>
3232
#ifndef IFT_ETHER
3333
#define IFT_ETHER 0x6 /* Ethernet CSMACD */
3434
#endif
3535
#endif
3636

37-
#ifdef __gnu_linux__
38-
#include <sys/utsname.h>
37+
#if (defined(__linux__) || defined(__gnu_linux__))
3938
#include <linux/if.h>
4039
#include <linux/sockios.h>
4140
#endif
42-
41+
#ifdef HAVE_SYS_UTSNAME_H
42+
#include <sys/utsname.h>
43+
#endif
4344

4445
// Bese32 encode, based on:
4546
// https://code.google.com/p/google-authenticator/source/browse/libpam/base32.c
@@ -133,7 +134,9 @@ int DSOLOCAL msc_status_engine_machine_name(char *machine_name, size_t len) {
133134
if (GetComputerName(machine_name, &lenComputerName) == 0) {
134135
goto failed;
135136
}
136-
#else
137+
#endif
138+
139+
#ifdef HAVE_SYS_UTSNAME_H
137140
static struct utsname u;
138141

139142
if ( uname( &u ) < 0 ) {
@@ -180,7 +183,7 @@ int DSOLOCAL msc_status_engine_mac_address (unsigned char *mac)
180183
freeifaddrs( ifaphead );
181184
#endif
182185

183-
#if __gnu_linux__
186+
#if (defined(__linux__) || defined(__gnu_linux__))
184187
struct ifconf conf;
185188
int sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP );
186189
struct ifreq* ifr;

configure.ac

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ AC_PATH_PROGS(ENV_CMD, [env printenv], )
3333

3434
# Checks for header files.
3535
AC_HEADER_STDC
36-
AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h unistd.h sys/types.h sys/stat.h])
36+
AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h unistd.h sys/types.h sys/stat.h sys/utsname.h])
3737

3838
# Checks for typedefs, structures, and compiler characteristics.
3939
AC_C_CONST

0 commit comments

Comments
 (0)