From 1932be8fffa9c6a1e3b6df17f51f3e29746cb7f4 Mon Sep 17 00:00:00 2001 From: venaas Date: Tue, 19 Feb 2008 14:12:26 +0000 Subject: [PATCH] Solaris9 fixes git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@214 e88ac4ed-0b26-0410-9574-a7f39faa03bf --- Makefile.am | 4 ++-- configure.ac | 13 +++++++++++++ debug.c | 2 ++ debug.h | 2 ++ radsecproxy.c | 20 ++++++++++++++++++++ util.c | 2 +- 6 files changed, 40 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index acf4223..eb4b1d2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,8 +11,8 @@ radsecproxy_SOURCES = radsecproxy.c \ util.h \ list.h -radsecproxy_CFLAGS = -g -Wall -pedantic -pthread @SSL_CFLAGS@ -radsecproxy_LDFLAGS = @SSL_LDFLAGS@ +radsecproxy_CFLAGS = -g -Wall -pedantic -pthread @SSL_CFLAGS@ @TARGET_CFLAGS@ +radsecproxy_LDFLAGS = @SSL_LDFLAGS@ @TARGET_LDFLAGS@ radsecproxy_LDADD = @SSL_LIBS@ dist_sysconf_DATA = $(srcdir)/radsecproxy.conf-example diff --git a/configure.ac b/configure.ac index 410df27..444ee64 100644 --- a/configure.ac +++ b/configure.ac @@ -2,5 +2,18 @@ AC_INIT(radsecproxy, 1.2-devel, venaas@uninett.no) AM_INIT_AUTOMAKE AC_PROG_CC AM_PROG_CC_C_O +dnl Check if we're on Solaris and set CFLAGS accordingly +AC_CANONICAL_SYSTEM +case "${target_os}" in + solaris*) + TARGET_CFLAGS="-DSYS_SOLARIS9 -D_POSIX_PTHREAD_SEMANTICS" + TARGET_LDFLAGS="-lsocket" + ;; + *) + TARGET_CFLAGS="" + TARGET_LDFLAGS="" + esac +AC_SUBST(TARGET_CFLAGS) +AC_SUBST(TARGET_LDFLAGS) AX_CHECK_SSL AC_OUTPUT(Makefile) diff --git a/debug.c b/debug.c index 384c141..9d0312e 100644 --- a/debug.c +++ b/debug.c @@ -6,7 +6,9 @@ * copyright notice and this permission notice appear in all copies. */ +#ifndef SYS_SOLARIS9 #include +#endif #include #include #include diff --git a/debug.h b/debug.h index 79a275e..b4b8787 100644 --- a/debug.h +++ b/debug.h @@ -6,7 +6,9 @@ * copyright notice and this permission notice appear in all copies. */ +#ifndef SYS_SOLARIS9 #include +#endif #define DBG_DBG 8 #define DBG_INFO 16 diff --git a/radsecproxy.c b/radsecproxy.c index 2f3c99b..f6cbaa1 100644 --- a/radsecproxy.c +++ b/radsecproxy.c @@ -34,6 +34,9 @@ #include #include #include +#ifdef SYS_SOLARIS9 +#include +#endif #include #include #include @@ -2768,6 +2771,23 @@ void getargs(int argc, char **argv, uint8_t *foreground, uint8_t *pretend, uint8 exit(1); } +#ifdef SYS_SOLARIS9 +int daemon(int a, int b) { + int i; + + if (fork()) + exit(0); + + setsid(); + + for (i = 0; i < 3; i++) { + close(i); + open("/dev/null", O_RDWR); + } + return 1; +} +#endif + int main(int argc, char **argv) { pthread_t udpserverth, udpaccserverth, udpclient4rdth, udpclient6rdth; struct list_node *entry; diff --git a/util.c b/util.c index c74b824..ee7d4d5 100644 --- a/util.c +++ b/util.c @@ -91,7 +91,7 @@ char *addr2string(struct sockaddr *addr, socklen_t len) { if (getnameinfo(addr, len, addr_buf[i], sizeof(addr_buf[i]), NULL, 0, NI_NUMERICHOST)) { debug(DBG_WARN, "getnameinfo failed"); - return NULL; + return return "getnameinfo_failed"; } return addr_buf[i]; } -- 2.1.4