HP-UX

From rsyslog wiki

Jump to: navigation, search

This page lists efforts required to get Rsyslog compiled and running on HP-UX.

Specific software versions used

Rsyslog 3.20.2

HP-UX 11.31 ia64

Prerequisites

Maybe unnecessary, but I downloaded gcc 4.3.1 .depot files from HP and installed them as root using swinstall -s. This should install gcc and g++ into /opt/hp-gcc.

Compiling Rsyslog on HP-UX

The Rsyslog sources need some patchwork to make them compile. To summarize: some constants must be defined, either by including the correct header file or by redefining non-existing (on HP-UX) constants to a suitable equivalent. In addition, some socket code needs some fcntl() magic to mimic behaviour defined on Linux using flags that are not implemented on HP-UX.

As I am a complete newbie on HP-UX, I have copied the patched source tree to my Linux machine and have run a "diff -Nuar" there to produce the following patch (should apply cleanly in the rsyslog-3.20.2 source tree using "patch -p1 < patchfile"):

diff -Nuar rsyslog-3.20.2/runtime/conf.c rsyslog-3.20.2-patched-and-configured/runtime/conf.c
--- rsyslog-3.20.2/runtime/conf.c	2008-12-04 13:02:55.000000000 +0100
+++ rsyslog-3.20.2-patched-and-configured/runtime/conf.c	2009-03-03 15:44:52.000000000 +0100
@@ -67,7 +67,8 @@
 #include "expr.h"
 #include "ctok.h"
 #include "ctok_token.h"
-
+ 
+#define NAME_MAX MAXNAMLEN
 
 /* forward definitions */
 static rsRetVal cfline(uchar *line, selector_t **pfCurr);
diff -Nuar rsyslog-3.20.2/runtime/modules.c rsyslog-3.20.2-patched-and-configured/runtime/modules.c
--- rsyslog-3.20.2/runtime/modules.c	2008-12-04 13:02:55.000000000 +0100
+++ rsyslog-3.20.2-patched-and-configured/runtime/modules.c	2009-03-03 16:03:28.000000000 +0100
@@ -53,6 +53,8 @@
 #include "modules.h"
 #include "errmsg.h"
 
+#include <limits.h>
+
 /* static data */
 DEFobjStaticHelpers
 DEFobjCurrIf(errmsg)
diff -Nuar rsyslog-3.20.2/runtime/nsd_ptcp.c rsyslog-3.20.2-patched-and-configured/runtime/nsd_ptcp.c
--- rsyslog-3.20.2/runtime/nsd_ptcp.c	2008-12-04 12:33:00.000000000 +0100
+++ rsyslog-3.20.2-patched-and-configured/runtime/nsd_ptcp.c	2009-03-03 16:26:59.000000000 +0100
@@ -565,8 +565,18 @@
 	DEFiRet;
 	nsd_ptcp_t *pThis = (nsd_ptcp_t*) pNsd;
 	ISOBJ_TYPE_assert(pThis, nsd_ptcp);
+      
+        /* new call by thysebaertp */	
+	int old_flags;
+	old_flags = fcntl(pThis->sock, F_GETFL);
+	fcntl(pThis->sock, F_SETFL, old_flags | O_NONBLOCK);
+        *pLenBuf = recv(pThis->sock, pRcvBuf, *pLenBuf, 0);
+	fcntl(pThis->sock, F_SETFL, old_flags);
+	/* End of new call */
 
+	/* old call	
 	*pLenBuf = recv(pThis->sock, pRcvBuf, *pLenBuf, MSG_DONTWAIT);
+        */
 
 	if(*pLenBuf == 0) {
 		ABORT_FINALIZE(RS_RET_CLOSED);
@@ -695,7 +705,19 @@
  	nsd_ptcp_t *pThis = (nsd_ptcp_t*) pNsd;
 	ISOBJ_TYPE_assert(pThis, nsd_ptcp);
 
-	rc = recv(pThis->sock, msgbuf, 1, MSG_DONTWAIT | MSG_PEEK);
+        /* New call by thysebaertp */
+        int oldflags;
+
+	oldflags = fcntl(pThis->sock, F_GETFL);
+        fcntl(pThis->sock, F_SETFL, oldflags | O_NONBLOCK);
+	rc = recv(pThis->sock, msgbuf, 1, MSG_PEEK);
+        fcntl(pThis->sock, F_SETFL, oldflags);	
+	/* End of new call */	
+
+	/* Old call  
+	 rc = recv(pThis->sock, msgbuf, 1, MSG_DONTWAIT | MSG_PEEK);
+        */
+
 	if(rc == 0) {
 		dbgprintf("CheckConnection detected broken connection - closing it\n");
 		/* in this case, the remote peer had shut down the connection and we
diff -Nuar rsyslog-3.20.2/runtime/rsyslog.h rsyslog-3.20.2-patched-and-configured/runtime/rsyslog.h
--- rsyslog-3.20.2/runtime/rsyslog.h	2008-12-04 13:02:55.000000000 +0100
+++ rsyslog-3.20.2-patched-and-configured/runtime/rsyslog.h	2009-03-03 15:49:45.000000000 +0100
@@ -92,7 +92,7 @@
 
 #ifdef __hpux
 typedef unsigned int u_int32_t; /* TODO: is this correct? */
-typedef int socklen_t;
+/*#typedef size_t socklen_t ; */
 #endif 

 /* settings for flow control
diff -Nuar rsyslog-3.20.2/runtime/srutils.c rsyslog-3.20.2-patched-and-configured/runtime/srutils.c
--- rsyslog-3.20.2/runtime/srutils.c	2008-12-04 13:02:55.000000000 +0100
+++ rsyslog-3.20.2-patched-and-configured/runtime/srutils.c	2009-03-03 16:01:39.000000000 +0100
@@ -45,7 +45,7 @@
 #define FALSE 0
 #include "srUtils.h"
 #include "obj.h"
-
+#include <time.h>
 
 /* here we host some syslog specific names. There currently is no better place
  * to do it, but over here is also not ideal... -- rgerhards, 2008-02-14

After patching, I configured with

CC=/opt/hp-gcc/bin/gcc CXX=/opt/hp-gcc/bin/g++ ./configure --prefix=/some/dir/I/can/write/to

Next, I patched the generated config.h and commented out the line

#define realloc rpl_realloc

Note that usually autoconf defines the rpl_ functions when the system malloc() and related functions do not behave like their glibc counterparts. Therefore, a more reliable patch might be to define rpl_realloc in the source code (and leave the above re-definition of realloc active) using something like

void* rpl_realloc(char* p, size_t n) {
  if (n == 0)
    n = 1;
  if (p == 0)
    return malloc(n);
  return malloc(p, n);
}

Next, I ran

make
make install

Running Rsyslogd

I had rsyslogd successfully display its version string by running

cd some/dir/I/can/write/to/sbin
LD_LIBRARY_PATH=/opt/hp-gcc/lib:/some/dir/I/can/write/to/lib/rsyslog ./rsyslogd -v

Really Running Rsyslogd...

Well, TODO is to check whether the compiled binary is actually able to forward log messages to a remote server using some custom formatting (which is why I wanted Rsyslog to compile on HP-UX in the first place).

That would mean that the above patches retain the intended semantics of the program (especially the O_NONBLOCK and rpl_realloc stuff).

Personal tools
language