diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2006-02-16 13:57:35 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2006-02-16 13:57:35 +0000 |
commit | 0faf9d9dbaa92266dcaa62d552b12cc922b55d9d (patch) | |
tree | 8222728e86c02d0d128aaac50963a7005ec17a8c | |
parent | 324afbb734d9e36ce474f2b549f50b8a10fb2264 (diff) | |
download | rsyslog-0faf9d9dbaa92266dcaa62d552b12cc922b55d9d.tar.gz rsyslog-0faf9d9dbaa92266dcaa62d552b12cc922b55d9d.tar.xz rsyslog-0faf9d9dbaa92266dcaa62d552b12cc922b55d9d.zip |
now it compiles under solaris, but I could not yet test it (need to find
out how to disable stock syslogd on this platform ;))
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | master.make | 2 | ||||
-rw-r--r-- | pidfile.c | 15 | ||||
-rw-r--r-- | solaris/Makefile | 100 | ||||
-rw-r--r-- | syslogd.c | 32 |
5 files changed, 147 insertions, 4 deletions
@@ -1,6 +1,8 @@ ---------------------------------------------------------------------------
Version 1.12.x (RGer), 2006-xx-xx
- implemented some changes to support Solaris +- commented out (via #if 0) some methods that are currently not being used + but should be kept for further use ---------------------------------------------------------------------------
Version 1.12.2 (RGer), 2006-02-15
- fixed a bug in the RFC 3339 date formatter. An extra space was added
diff --git a/master.make b/master.make index 06c18f7a..aaa916ec 100644 --- a/master.make +++ b/master.make @@ -42,7 +42,7 @@ test: syslog_tst tsyslogd install: install_man install_exec syslogd: syslogd.o pidfile.o template.o stringbuf.o srUtils.o outchannel.o parse.o - ${CC} ${LDFLAGS} $(LPTHREAD) -o syslogd syslogd.o pidfile.o template.o outchannel.o stringbuf.o srUtils.o parse.o ${LIBS} + ${CC} ${LDFLAGS} ${EXTRALIB} $(LPTHREAD) -o syslogd syslogd.o pidfile.o template.o outchannel.o stringbuf.o srUtils.o parse.o ${LIBS} rfc3195d: rfc3195d.o ${CC} ${LDFLAGS} -o rfc3195d rfc3195d.o ${LIBLOGGING_BIN} @@ -31,6 +31,9 @@ #include <string.h> #include <errno.h> #include <signal.h> +#ifdef __sun +#include <fcntl.h> +#endif /* read_pid * @@ -93,12 +96,22 @@ int write_pid (char *pidfile) return 0; } + /* It seems to be acceptable that we do not lock the pid file + * if we run under Solaris. In any case, it is highly unlikely + * that two instances try to access this file. And flock is really + * causing me grief on my initial steps on Solaris. Some time later, + * we might re-enable it (or use some alternate method). + * 2006-02-16 rgerhards + */ + +#ifndef __sun if (flock(fd, LOCK_EX|LOCK_NB) == -1) { fscanf(f, "%d", &pid); fclose(f); printf("Can't lock, lock is held by pid %d.\n", pid); return 0; } +#endif pid = getpid(); if (!fprintf(f,"%d\n", pid)) { @@ -108,11 +121,13 @@ int write_pid (char *pidfile) } fflush(f); +#ifndef __sun if (flock(fd, LOCK_UN) == -1) { printf("Can't unlock pidfile %s, %s.\n", pidfile, strerror(errno)); close(fd); return 0; } +#endif close(fd); return pid; diff --git a/solaris/Makefile b/solaris/Makefile new file mode 100644 index 00000000..efb04144 --- /dev/null +++ b/solaris/Makefile @@ -0,0 +1,100 @@ +# Makefile for rsyslog +# Copyright (C) 2004, 2005 Rainer Gerhards and Adiscon GmbH +# This is the distro-specifc part of the Makefile. +# This makefile here should be suitable for all flavours +# of linux. +# For details, see http://www.rsyslog.com/doc + +############################################################# +# USER SETTINGS # +# ------------- # +# The following lines allow you to customize the way # +# rsyslog is build. All variables take a value of 0 or zero # +# with 1 meaning true and 0 meaning false (in most cases # +# equivalent to "disabled"). If you need to customize any- # +# thing do it here - and stay away from all other parts # +# of this file! # +# # +# IMPORTANT: after you have made changes, run "make clean" # +# before any other command! # +############################################################# + +# Enable large file support (typically on, not needed for +# 64 bit operating systems) +FEATURE_LARGEFILE=1 + +# Enable database support (off by default, must be turned +# on when support for MySQL is desired). +FEATURE_DB=0 + +# Enable regular expressions +FEATURE_REGEXP=1 + +# Enable RFC 3195 support (REQUIRES LIBLOGGING 0.6.0 or above!) +FEATURE_RFC3195=0 + +# Enable multithreading via pthreads (experimental!) +FEATURE_PTHREADS=1 + +# Enable debug mode (much slower code) +FEATURE_DEBUG=1 + +# The following defines tell us where liblogging is located. This +# is only needed if we build with RFC 3195 support. By default, +# liblogging is expected to be present in the our parent directory. +# +# THESE PATHES MUST ONLY BE SET IF RSYSLOG IS BUILD WITH +# RFC 3195 SUPPORT! +LIBLOGGING_INC=-I../../liblogging/src +LIBLOGGING_BIN=../../liblogging/src/linux/liblogging.a + +############################################################# +# END OF USER SETTINGS # +# -------------------- # +# DO NOT MAKE ANY MODIFICATIONS BELOW THIS POINT! # +############################################################# + +INSTALL = install +BINDIR = /usr/sbin +MANDIR = /usr/share/man + +# now comes the evaluation of the FEATURE_* settings +ifeq ($(strip $(FEATURE_LARGEFILE)), 0) + NOLARGEFILE = -DNOLARGEFILE +endif + +ifeq ($(strip $(FEATURE_DB)), 1) + WITHDB=-DWITH_DB +endif + +ifeq ($(strip $(FEATURE_REGEXP)), 1) + F_REGEXP=-DFEATURE_REGEXP +endif + +ifeq ($(strip $(FEATURE_PTHREADS)), 1) + F_PTHREADS=-DUSE_PTHREADS + LPTHREAD=-lpthread +endif + +ifeq ($(strip $(FEATURE_RFC3195)), 1) + F_RFC3195=-DFEATURE_RFC3195 +else + LIBLOGGING_INC= + LIBLOGGING_BIN= +endif + +ifeq ($(strip $(FEATURE_DEBUG)), 0) + DBG=-DNDEBUG +endif + +# Include MySQL client lib if DB is selected +ifdef WITHDB +LIBS = -lmysqlclient -L/usr/local/lib/mysql +endif + +# we use gcc under Solaris (mostly because that was the easiest for me ;)) +CC=gcc +EXTRALIB=-lsocket -lnsl + +VPATH = ../ +include ../master.make @@ -183,6 +183,12 @@ #include <paths.h> #endif +/* handle some defines missing on more than one platform */ +#ifndef SUN_LEN +#define SUN_LEN(su) \ + (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) +#endif + /* missing definitions for solaris * 2006-02-16 Rger */ @@ -191,6 +197,9 @@ #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) typedef struct _code { char *c_name; int c_val; @@ -2068,6 +2077,7 @@ static int formatTimestamp3164(struct syslogTime *ts, char* pBuf, size_t iLenBuf * returns the size of the timestamp written in bytes (without * the string termnator). If 0 is returend, an error occured. */ +#if 0 /* This method is currently not called, be we like to preserve it */ static int formatTimestamp(struct syslogTime *ts, char* pBuf, size_t iLenBuf) { assert(ts != NULL); @@ -2083,6 +2093,7 @@ static int formatTimestamp(struct syslogTime *ts, char* pBuf, size_t iLenBuf) return(0); } +#endif /** @@ -2115,7 +2126,14 @@ static void getCurrTime(struct syslogTime *t) t->secfrac = tp.tv_usec; t->secfracPrecision = 6; - lBias = tm->tm_gmtoff; +# if __sun + /* Solaris uses a different method of exporting the time zone. + * It is UTC - localtime, which is the opposite sign of mins east of GMT. + */ + lBias = -(daylight ? altzone : timezone); +# else + lBias = tm->tm_gmtoff; +# endif if(lBias < 0) { t->OffsetMode = '-'; @@ -2526,10 +2544,12 @@ static rsRetVal MsgSetMSGID(struct msg *pMsg, char* pszMSGID) /* rgerhards, 2005-11-24 */ +#if 0 /* This method is currently not called, be we like to preserve it */ static int getMSGIDLen(struct msg *pM) { return (pM->pCSMSGID == NULL) ? 1 : rsCStrLen(pM->pCSMSGID); } +#endif /* rgerhards, 2005-11-24 @@ -2604,6 +2624,7 @@ static void tryEmulateTAG(struct msg *pM) } +#if 0 /* This method is currently not called, be we like to preserve it */ static int getTAGLen(struct msg *pM) { if(pM == NULL) @@ -2616,6 +2637,7 @@ static int getTAGLen(struct msg *pM) return pM->iLenTAG; } } +#endif static char *getTAG(struct msg *pM) @@ -2684,10 +2706,12 @@ static rsRetVal MsgSetStructuredData(struct msg *pMsg, char* pszStrucData) /* get the length of the "STRUCTURED-DATA" sz string * rgerhards, 2005-11-24 */ +#if 0 /* This method is currently not called, be we like to preserve it */ static int getStructuredDataLen(struct msg *pM) { return (pM->pCSStrucData == NULL) ? 1 : rsCStrLen(pM->pCSStrucData); } +#endif /* get the "STRUCTURED-DATA" as sz string @@ -2921,6 +2945,7 @@ static int MsgSetHOSTNAME(struct msg *pMsg, char* pszHOSTNAME) * function is a performance optimization over MsgSetUxTradMsg(). * rgerhards 2004-11-19 */ +#if 0 /* This method is currently not called, be we like to preserve it */ static void MsgAssignUxTradMsg(struct msg *pMsg, char *pBuf) { assert(pMsg != NULL); @@ -2928,6 +2953,7 @@ static void MsgAssignUxTradMsg(struct msg *pMsg, char *pBuf) pMsg->iLenUxTradMsg = strlen(pBuf); pMsg->pszUxTradMsg = pBuf; } +#endif /* rgerhards 2004-11-17: set the traditional Unix message in msg object @@ -5635,7 +5661,7 @@ static void die(int sig) (void) snprintf(buf, sizeof(buf) / sizeof(char), " [origin software=\"rsyslogd\" " "swVersion=\"" VERSION "." \ PATCHLEVEL "\" x-pid=\"%d\"]" " exiting on signal %d.", - myPid, sig); + (int) myPid, sig); errno = 0; logmsgInternal(LOG_SYSLOG|LOG_INFO, buf, LocalHostName, ADDDATE); } @@ -6210,7 +6236,7 @@ static void init() PATCHLEVEL "\" x-pid=\"%d\"][x-configInfo udpReception=\"%s\" " \ "udpPort=\"%d\" tcpReception=\"%s\" tcpPort=\"%d\"]" \ " restart", - myPid, + (int) myPid, AcceptRemote ? "Yes" : "No", LogPort, bEnableTCP ? "Yes" : "No", TCPLstnPort ); logmsgInternal(LOG_SYSLOG|LOG_INFO, bufStartUpMsg, LocalHostName, ADDDATE); |