summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-03-05 07:01:35 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-03-05 07:01:35 +0000
commit80e69562be86d149d753530a8a57c5babbb3f4c3 (patch)
tree021a608559e734833a7d23f03444fde66bf38076
parent05ba3fbffeaa3142e917ea69e9e39209e893581a (diff)
downloadrsyslog-80e69562be86d149d753530a8a57c5babbb3f4c3.tar.gz
rsyslog-80e69562be86d149d753530a8a57c5babbb3f4c3.tar.xz
rsyslog-80e69562be86d149d753530a8a57c5babbb3f4c3.zip
did some portability changes to make rsyslog compile on HP UX
-rw-r--r--ChangeLog3
-rw-r--r--conf.c11
-rw-r--r--configure.ac4
-rw-r--r--msg.c10
-rw-r--r--net.c15
-rw-r--r--net.h1
-rw-r--r--omusrmsg.c7
-rw-r--r--outchannel.c2
-rw-r--r--pidfile.c4
-rw-r--r--queue.c1
-rw-r--r--rsyslog.h4
-rwxr-xr-xsrUtils.c25
-rwxr-xr-xsrUtils.h7
-rw-r--r--stream.c1
-rwxr-xr-xstringbuf.h12
-rw-r--r--syslogd-types.h4
-rw-r--r--syslogd.c72
-rw-r--r--syslogd.h14
-rw-r--r--wti.c2
-rw-r--r--wtp.c2
20 files changed, 143 insertions, 58 deletions
diff --git a/ChangeLog b/ChangeLog
index c59b68dc..934ec9da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,11 @@
---------------------------------------------------------------------------
+---------------------------------------------------------------------------
Version 3.12.1 (rgerhards), 2008-0?-??
- improved debugging support; debug runtime options can now be set via
an environment variable
- bugfix: removed debugging code that I forgot to remove before releasing
3.12.0 (does not cause harm and happened only during startup)
- internal code improvements (more code converted into classes)
-- changed the default omsnmp mib/oid to a more appropriate value
-- internal code reworking of the imtcp/imgssapi module
---------------------------------------------------------------------------
Version 3.12.0 (rgerhards), 2008-02-28
- added full expression support for filters; filters can now contain
diff --git a/conf.c b/conf.c
index 0c304529..e4fb362b 100644
--- a/conf.c
+++ b/conf.c
@@ -40,6 +40,9 @@
#include <dirent.h>
#include <glob.h>
#include <sys/types.h>
+#ifdef HAVE_LIBGEN_H
+# include <libgen.h>
+#endif
#include "rsyslog.h"
#include "syslogd.h"
@@ -117,8 +120,16 @@ static rsRetVal doIncludeDirectory(uchar *pDirName)
while(readdir_r(pDir, &u.d, &res) == 0) {
if(res == NULL)
break; /* this also indicates end of directory */
+# ifdef DT_REG
+ /* TODO: find an alternate way to checking for special files if this is
+ * not defined. This is currently a known problem on HP UX, but the work-
+ * around is simple: do not create special files in that directory. So
+ * fixing this is actually not the most important thing on earth...
+ * rgerhards, 2008-03-04
+ */
if(res->d_type != DT_REG)
continue; /* we are not interested in special files */
+# endif
if(res->d_name[0] == '.')
continue; /* these files we are also not interested in */
++iEntriesDone;
diff --git a/configure.ac b/configure.ac
index e60b0913..76120db5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,7 +44,7 @@ AC_SUBST(dl_libs)
AC_HEADER_RESOLV
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS([arpa/inet.h fcntl.h locale.h netdb.h netinet/in.h paths.h stddef.h stdlib.h string.h sys/file.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h syslog.h unistd.h utmp.h])
+AC_CHECK_HEADERS([arpa/inet.h libgen.h fcntl.h locale.h netdb.h netinet/in.h paths.h stddef.h stdlib.h string.h sys/file.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h sys/stat.h syslog.h unistd.h utmp.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
@@ -80,7 +80,7 @@ AC_FUNC_STAT
AC_FUNC_STRERROR_R
AC_FUNC_VPRINTF
AC_FUNC_WAIT3
-AC_CHECK_FUNCS([alarm clock_gettime gethostbyname gethostname gettimeofday localtime_r memset mkdir regcomp select setid socket strcasecmp strchr strdup strerror strndup strnlen strrchr strstr strtol strtoul uname ttyname_r])
+AC_CHECK_FUNCS([flock alarm clock_gettime gethostbyname gethostname gettimeofday localtime_r memset mkdir regcomp select setid socket strcasecmp strchr strdup strerror strndup strnlen strrchr strstr strtol strtoul uname ttyname_r])
# Large file support
diff --git a/msg.c b/msg.c
index 7fa8234c..e49413a9 100644
--- a/msg.c
+++ b/msg.c
@@ -31,7 +31,6 @@
#include <stdarg.h>
#include <stdlib.h>
#define SYSLOG_NAMES
-#include <sys/syslog.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
@@ -64,17 +63,22 @@ static syslogCODE rs_prioritynames[] =
{ NULL, -1 }
};
+#ifndef LOG_AUTHPRIV
+# define LOG_AUTHPRIV LOG_AUTH
+#endif
static syslogCODE rs_facilitynames[] =
{
{ "auth", LOG_AUTH },
{ "authpriv", LOG_AUTHPRIV },
{ "cron", LOG_CRON },
{ "daemon", LOG_DAEMON },
- { "ftp", LOG_FTP },
+#if defined(LOG_FTP)
+ {"ftp", LOG_FTP},
+#endif
{ "kern", LOG_KERN },
{ "lpr", LOG_LPR },
{ "mail", LOG_MAIL },
- { "mark", INTERNAL_MARK }, /* INTERNAL */
+ //{ "mark", INTERNAL_MARK }, /* INTERNAL */
{ "news", LOG_NEWS },
{ "security", LOG_AUTH }, /* DEPRECATED */
{ "syslog", LOG_SYSLOG },
diff --git a/net.c b/net.c
index 33dfc851..a4fdfb33 100644
--- a/net.c
+++ b/net.c
@@ -472,7 +472,12 @@ static inline int MaskCmp(struct NetAddr *pAllow, uint8_t bits, struct sockaddr
if(F_ISSET(pAllow->flags, ADDR_NAME)) {
dbgprintf("MaskCmp: host=\"%s\"; pattern=\"%s\"\n", pszFromHost, pAllow->addr.HostWildcard);
- return(fnmatch(pAllow->addr.HostWildcard, pszFromHost, FNM_NOESCAPE|FNM_CASEFOLD) == 0);
+# if !defined(FNM_CASEFOLD)
+ /* TODO: I don't know if that then works, seen on HP UX, what I have not in lab... ;) */
+ return(fnmatch(pAllow->addr.HostWildcard, pszFromHost, FNM_NOESCAPE) == 0);
+# else
+ return(fnmatch(pAllow->addr.HostWildcard, pszFromHost, FNM_NOESCAPE|FNM_CASEFOLD) == 0);
+# endif
} else {/* We need to compare an IP address */
switch (pFrom->sa_family) {
case AF_INET:
@@ -573,11 +578,11 @@ int should_use_so_bsdcompat(void)
static int so_bsdcompat_is_obsolete;
if (!init_done) {
- struct utsname utsname;
+ struct utsname myutsname;
unsigned int version, patchlevel;
init_done = 1;
- if (uname(&utsname) < 0) {
+ if (uname(&myutsname) < 0) {
char errStr[1024];
dbgprintf("uname: %s\r\n", rs_strerror_r(errno, errStr, sizeof(errStr)));
return 1;
@@ -585,9 +590,9 @@ int should_use_so_bsdcompat(void)
/* Format is <version>.<patchlevel>.<sublevel><extraversion>
where the first three are unsigned integers and the last
is an arbitrary string. We only care about the first two. */
- if (sscanf(utsname.release, "%u.%u", &version, &patchlevel) != 2) {
+ if (sscanf(myutsname.release, "%u.%u", &version, &patchlevel) != 2) {
dbgprintf("uname: unexpected release '%s'\r\n",
- utsname.release);
+ myutsname.release);
return 1;
}
/* SO_BSCOMPAT is deprecated and triggers warnings in 2.5
diff --git a/net.h b/net.h
index 2b7a3a73..e5844bf5 100644
--- a/net.h
+++ b/net.h
@@ -25,6 +25,7 @@
#ifdef SYSLOG_INET
#include <netinet/in.h>
+#include <sys/socket.h> /* this is needed on HP UX -- rgerhards, 2008-03-04 */
#define F_SET(where, flag) (where)|=(flag)
#define F_ISSET(where, flag) ((where)&(flag))==(flag)
diff --git a/omusrmsg.c b/omusrmsg.c
index 529366c4..382f6158 100644
--- a/omusrmsg.c
+++ b/omusrmsg.c
@@ -59,6 +59,13 @@
#include "omusrmsg.h"
#include "module-template.h"
+
+/* portability: */
+#ifndef _PATH_DEV
+# define _PATH_DEV "/dev/"
+#endif
+
+
MODULE_TYPE_OUTPUT
/* internal structures
diff --git a/outchannel.c b/outchannel.c
index 9b669cb1..394371f0 100644
--- a/outchannel.c
+++ b/outchannel.c
@@ -286,7 +286,7 @@ void ochPrintList(void)
while(pOch != NULL) {
dbgprintf("Outchannel: Name='%s'\n", pOch->pszName == NULL? "NULL" : pOch->pszName);
dbgprintf("\tFile Template: '%s'\n", pOch->pszFileTemplate == NULL ? "NULL" : (char*) pOch->pszFileTemplate);
- dbgprintf("\tMax Size.....: %lu\n", pOch->uSizeLimit);
+ dbgprintf("\tMax Size.....: %lu\n", (long unsigned) pOch->uSizeLimit);
dbgprintf("\tOnSizeLimtCmd: '%s'\n", pOch->cmdOnSizeLimit == NULL ? "NULL" : (char*) pOch->cmdOnSizeLimit);
pOch = pOch->pNext; /* done, go next */
}
diff --git a/pidfile.c b/pidfile.c
index f5796d57..2be13da6 100644
--- a/pidfile.c
+++ b/pidfile.c
@@ -111,7 +111,7 @@ int write_pid (char *pidfile)
* 2006-02-16 rgerhards
*/
-#ifndef __sun
+#if HAVE_FLOCK
if (flock(fd, LOCK_EX|LOCK_NB) == -1) {
fscanf(f, "%d", &pid);
fclose(f);
@@ -130,7 +130,7 @@ int write_pid (char *pidfile)
}
fflush(f);
-#ifndef __sun
+#if HAVE_FLOCK
if (flock(fd, LOCK_UN) == -1) {
char errStr[1024];
rs_strerror_r(errno, errStr, sizeof(errStr));
diff --git a/queue.c b/queue.c
index 5b75e911..ccc952d8 100644
--- a/queue.c
+++ b/queue.c
@@ -37,6 +37,7 @@
#include <pthread.h>
#include <fcntl.h>
#include <unistd.h>
+#include <sys/stat.h> /* required for HP UX */
#include <errno.h>
#include "rsyslog.h"
diff --git a/rsyslog.h b/rsyslog.h
index 3fa5c52d..c5d352d8 100644
--- a/rsyslog.h
+++ b/rsyslog.h
@@ -49,6 +49,10 @@ typedef long long int64;
typedef long long unsigned uint64;
typedef int64 number_t; /* type to use for numbers - TODO: maybe an autoconf option? */
+#ifdef __hpux
+typedef unsigned int u_int32_t; /* TODO: is this correct? */
+#endif
+
/* The error codes below are orginally "borrowed" from
* liblogging. As such, we reserve values up to -2999
* just in case we need to borrow something more ;)
diff --git a/srUtils.c b/srUtils.c
index b871861b..fa451b7e 100755
--- a/srUtils.c
+++ b/srUtils.c
@@ -67,6 +67,9 @@ syslogName_t syslogPriNames[] = {
{NULL, -1}
};
+#ifndef LOG_AUTHPRIV
+# define LOG_AUTHPRIV LOG_AUTH
+#endif
syslogName_t syslogFacNames[] = {
{"auth", LOG_AUTH},
{"authpriv", LOG_AUTHPRIV},
@@ -449,15 +452,21 @@ srSleep(int iSeconds, int iuSeconds)
* Added 2008-01-30
*/
char *rs_strerror_r(int errnum, char *buf, size_t buflen) {
-#ifdef STRERROR_R_CHAR_P
- char *p = strerror_r(errnum, buf, buflen);
- if (p != buf) {
- strncpy(buf, p, buflen);
- buf[buflen - 1] = '\0';
- }
+#ifdef __hpux
+ char *pszErr;
+ pszErr = strerror(errnum);
+ snprintf(buf, buflen, "%s", pszErr);
#else
- strerror_r(errnum, buf, buflen);
-#endif
+# ifdef STRERROR_R_CHAR_P
+ char *p = strerror_r(errnum, buf, buflen);
+ if (p != buf) {
+ strncpy(buf, p, buflen);
+ buf[buflen - 1] = '\0';
+ }
+# else
+ strerror_r(errnum, buf, buflen);
+# endif
+#endif /* #ifdef __hpux */
return buf;
}
diff --git a/srUtils.h b/srUtils.h
index 1fe56665..ebd6518f 100755
--- a/srUtils.h
+++ b/srUtils.h
@@ -29,10 +29,13 @@
/* syslog names */
+#ifndef LOG_MAKEPRI
+# define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
+#endif
#define INTERNAL_NOPRI 0x10 /* the "no priority" priority */
#define TABLE_NOPRI 0 /* Value to indicate no priority in f_pmask */
#define TABLE_ALLPRI 0xFF /* Value to indicate all priorities in f_pmask */
-#define LOG_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0) /* mark "facility" */
+#define LOG_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0) /* mark "facility" */
typedef struct syslogName_s {
char *c_name;
@@ -76,7 +79,7 @@ unsigned char *srUtilStrDup(unsigned char *pOld, size_t len);
* added 2007-07-17 by rgerhards
*/
int makeFileParentDirs(uchar *szFile, size_t lenFile, mode_t mode, uid_t uid, gid_t gid, int bFailOnChown);
-int execProg(uchar *program, int wait, uchar *arg);
+int execProg(uchar *program, int bWait, uchar *arg);
void skipWhiteSpace(uchar **pp);
rsRetVal genFileName(uchar **ppName, uchar *pDirName, size_t lenDirName, uchar *pFName,
size_t lenFName, long lNum, int lNumDigits);
diff --git a/stream.c b/stream.c
index bc345f93..986d246d 100644
--- a/stream.c
+++ b/stream.c
@@ -36,6 +36,7 @@
#include <pthread.h>
#include <fcntl.h>
#include <unistd.h>
+#include <sys/stat.h> /* required for HP UX */
#include <errno.h>
#include "rsyslog.h"
diff --git a/stringbuf.h b/stringbuf.h
index 6b5826ff..aa31884e 100755
--- a/stringbuf.h
+++ b/stringbuf.h
@@ -72,11 +72,6 @@ void rsCStrDestruct(cstr_t **ppThis);
rsRetVal rsCStrAppendChar(cstr_t *pThis, uchar c);
/**
- * Finish the string buffer dynamic allocation.
- */
-rsRetVal rsCStrFinish(cstr_t *pThis);
-
-/**
* Truncate "n" number of characters from the end of the
* string. The buffer remains unchanged, just the
* string length is manipulated. This is for performance
@@ -156,7 +151,12 @@ rsRetVal rsCStrAppendCStr(cstr_t *pThis, cstr_t *pstrAppend);
* simply needs to do nothing, so that we can save us the function call.
* rgerhards, 2008-02-12
*/
-#define rsCStrFinish(pThis) RS_RET_OK
+# define rsCStrFinish(pThis) RS_RET_OK
+#else
+ /**
+ * Finish the string buffer dynamic allocation.
+ */
+ rsRetVal rsCStrFinish(cstr_t *pThis);
#endif
#define rsCStrGetBufBeg(x) ((x)->pBuf)
diff --git a/syslogd-types.h b/syslogd-types.h
index 26640ddb..1d49cfb5 100644
--- a/syslogd-types.h
+++ b/syslogd-types.h
@@ -29,7 +29,9 @@
#include "stringbuf.h"
#include "net.h"
#include <sys/param.h>
-#include <sys/syslog.h>
+#if HAVE_SYSLOG_H
+#include <syslog.h>
+#endif
#define FALSE 0
#define TRUE 1
diff --git a/syslogd.c b/syslogd.c
index 3befa958..a8cbe45d 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -134,6 +134,10 @@
# include <sys/timespec.h>
#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+
#include <signal.h>
#if HAVE_PATHS_H
@@ -194,12 +198,9 @@ DEFobjCurrIf(vm)
#ifdef __sun
# define LOG_AUTHPRIV LOG_AUTH
#endif
-#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
-#define LOG_PRI(p) ((p) & LOG_PRIMASK)
-#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
#define INTERNAL_NOPRI 0x10 /* the "no priority" priority */
#define LOG_FTP (11<<3) /* ftp daemon */
-#define INTERNAL_MARK LOG_MAKEPRI((LOG_NFACILITIES<<3), 0)
+//#define INTERNAL_MARK LOG_MAKEPRI((LOG_NFACILITIES<<3), 0)
#ifndef UTMP_FILE
@@ -223,30 +224,33 @@ DEFobjCurrIf(vm)
#endif
#if defined(SYSLOGD_PIDNAME)
-#undef _PATH_LOGPID
-#if defined(FSSTND)
-#ifdef BSD
-#define _PATH_VARRUN "/var/run/"
-#endif
-#ifdef __sun
-#define _PATH_VARRUN "/var/run/"
-#endif
-#define _PATH_LOGPID _PATH_VARRUN SYSLOGD_PIDNAME
-#else
-#define _PATH_LOGPID "/etc/" SYSLOGD_PIDNAME
-#endif
-#else
-#ifndef _PATH_LOGPID
-#if defined(FSSTND)
-#define _PATH_LOGPID _PATH_VARRUN "rsyslogd.pid"
+# undef _PATH_LOGPID
+# if defined(FSSTND)
+# ifdef BSD
+# define _PATH_VARRUN "/var/run/"
+# endif
+# if defined(__sun) || defined(__hpux)
+# define _PATH_VARRUN "/var/run/"
+# endif
+# define _PATH_LOGPID _PATH_VARRUN SYSLOGD_PIDNAME
+# else
+# define _PATH_LOGPID "/etc/" SYSLOGD_PIDNAME
+# endif
#else
-#define _PATH_LOGPID "/etc/rsyslogd.pid"
-#endif
-#endif
+# ifndef _PATH_LOGPID
+# if defined(__sun) || defined(__hpux)
+# define _PATH_VARRUN "/var/run/"
+# endif
+# if defined(FSSTND)
+# define _PATH_LOGPID _PATH_VARRUN "rsyslogd.pid"
+# else
+# define _PATH_LOGPID "/etc/rsyslogd.pid"
+# endif
+# endif
#endif
#ifndef _PATH_DEV
-#define _PATH_DEV "/dev/"
+# define _PATH_DEV "/dev/"
#endif
#ifndef _PATH_CONSOLE
@@ -948,9 +952,19 @@ void getCurrTime(struct syslogTime *t)
struct tm *tm;
struct tm tmBuf;
long lBias;
+# if defined(__hpux)
+ struct timezone tz;
+# endif
assert(t != NULL);
- gettimeofday(&tp, NULL);
+# if defined(__hpux)
+ /* TODO: check this: under HP UX, the tz information is actually valid
+ * data. So we need to obtain and process it there.
+ */
+ gettimeofday(&tp, &tz);
+# else
+ gettimeofday(&tp, NULL);
+# endif
tm = localtime_r((time_t*) &(tp.tv_sec), &tmBuf);
t->year = tm->tm_year + 1900;
@@ -967,6 +981,8 @@ void getCurrTime(struct syslogTime *t)
* It is UTC - localtime, which is the opposite sign of mins east of GMT.
*/
lBias = -(daylight ? altzone : timezone);
+# elif defined(__hpux)
+ lBias = tz.tz_dsttime ? - tz.tz_minuteswest : 0;
# else
lBias = tm->tm_gmtoff;
# endif
@@ -1141,7 +1157,11 @@ void untty(void)
if ( !Debug ) {
i = open(_PATH_TTY, O_RDWR);
if (i >= 0) {
- (void) ioctl(i, (int) TIOCNOTTY, (char *)0);
+# if !defined(__hpux)
+ (void) ioctl(i, (int) TIOCNOTTY, (char *)0);
+# else
+ /* TODO: we need to implement something for HP UX! -- rgerhards, 2008-03-04 */
+# endif
(void) close(i);
}
}
diff --git a/syslogd.h b/syslogd.h
index 31b35609..41d2df6c 100644
--- a/syslogd.h
+++ b/syslogd.h
@@ -29,6 +29,20 @@
#include "linkedlist.h"
#include "expr.h"
+/* portability: not all platforms have these defines, so we
+ * define them here if they are missing. -- rgerhards, 2008-03-04
+ */
+#ifndef LOG_MAKEPRI
+# define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
+#endif
+#ifndef LOG_PRI
+# define LOG_PRI(p) ((p) & LOG_PRIMASK)
+#endif
+#ifndef LOG_FAC
+# define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
+#endif
+
+
#ifdef USE_NETZIP
/* config param: minimum message size to try compression. The smaller
* the message, the less likely is any compression gain. We check for
diff --git a/wti.c b/wti.c
index 9fadfdf3..aae456d8 100644
--- a/wti.c
+++ b/wti.c
@@ -367,7 +367,9 @@ wtiWorker(wti_t *pThis)
/* process any pending thread requests */
wtpProcessThrdChanges(pWtp);
pthread_testcancel(); /* see big comment in function header */
+# if !defined(__hpux) /* pthread_yield is missing there! */
pthread_yield(); /* see big comment in function header */
+# endif
wtpSetInactivityGuard(pThis->pWtp, 0, LOCK_MUTEX); /* must be set before usr mutex is locked! */
BEGIN_MTX_PROTECTED_OPERATIONS(pWtp->pmutUsr, LOCK_MUTEX);
diff --git a/wtp.c b/wtp.c
index 83cb5d5e..1c2ea30f 100644
--- a/wtp.c
+++ b/wtp.c
@@ -476,7 +476,9 @@ wtpStartWrkr(wtp_t *pThis, int bLockMutex)
/* we try to give the starting worker a little boost. It won't help much as we still
* hold the queue's mutex, but at least it has a chance to start on a single-CPU system.
*/
+# if !defined(__hpux) /* pthread_yield is missing there! */
pthread_yield();
+# endif
/* indicate we just started a worker and would like to see it running */
wtpSetInactivityGuard(pThis, 1, MUTEX_ALREADY_LOCKED);