diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-03-05 07:01:35 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-03-05 07:01:35 +0000 |
commit | 80e69562be86d149d753530a8a57c5babbb3f4c3 (patch) | |
tree | 021a608559e734833a7d23f03444fde66bf38076 | |
parent | 05ba3fbffeaa3142e917ea69e9e39209e893581a (diff) | |
download | rsyslog-80e69562be86d149d753530a8a57c5babbb3f4c3.tar.gz rsyslog-80e69562be86d149d753530a8a57c5babbb3f4c3.tar.bz2 rsyslog-80e69562be86d149d753530a8a57c5babbb3f4c3.zip |
did some portability changes to make rsyslog compile on HP UX
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | conf.c | 11 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | msg.c | 10 | ||||
-rw-r--r-- | net.c | 15 | ||||
-rw-r--r-- | net.h | 1 | ||||
-rw-r--r-- | omusrmsg.c | 7 | ||||
-rw-r--r-- | outchannel.c | 2 | ||||
-rw-r--r-- | pidfile.c | 4 | ||||
-rw-r--r-- | queue.c | 1 | ||||
-rw-r--r-- | rsyslog.h | 4 | ||||
-rwxr-xr-x | srUtils.c | 25 | ||||
-rwxr-xr-x | srUtils.h | 7 | ||||
-rw-r--r-- | stream.c | 1 | ||||
-rwxr-xr-x | stringbuf.h | 12 | ||||
-rw-r--r-- | syslogd-types.h | 4 | ||||
-rw-r--r-- | syslogd.c | 72 | ||||
-rw-r--r-- | syslogd.h | 14 | ||||
-rw-r--r-- | wti.c | 2 | ||||
-rw-r--r-- | wtp.c | 2 |
20 files changed, 143 insertions, 58 deletions
@@ -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 @@ -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 @@ -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 }, @@ -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 @@ -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) @@ -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 */ } @@ -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)); @@ -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" @@ -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 ;) @@ -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; } @@ -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); @@ -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 @@ -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); } } @@ -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 @@ -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); @@ -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); |