#include <stdio.h>#include <stdarg.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include <errno.h>#include <syslog.h>#include <strutil.h>#include <configfile.h>Include dependency graph for log.c:

Go to the source code of this file.
Defines | |
| #define | SYSLOG_NAMES |
Functions | |
| int | writeLog (const char *fmt,...) |
| int | inform (char *fmt,...) |
| char * | sysLogPriId (int pri) |
| int | sysLogPri (char *name) |
| char * | sysLogFacId (int fac) |
| int | sysLogFac (char *name) |
|
|
|
|
||||||||||||
|
inform does a printf to the syslog and in an email to the mailto address Definition at line 42 of file log.c. References confVarPath(), confVarText(), and writeLog(). Referenced by undropIp(). 00042 { 00043 char cmdbuf[32767]; 00044 char obuf[1024]; 00045 int x; 00046 char * mailfrom; 00047 char * mailto; 00048 char * sendmail; 00049 FILE *p; 00050 va_list ap; 00051 00052 sendmail = confVarPath("sendmail",&x); 00053 mailfrom = confVarText("mailfrom",&x); 00054 mailto = confVarText("mailto",&x); 00055 00056 va_start(ap,fmt); 00057 x = vsnprintf(obuf,sizeof(obuf),fmt,ap); 00058 va_end(ap); 00059 00060 writeLog(obuf); 00061 sprintf(cmdbuf, "%s -F%s %s",sendmail,mailfrom,mailto); 00062 if((p = popen(cmdbuf,"w")) == NULL) { 00063 writeLog("Could not send mail [%s] %m",cmdbuf); 00064 return; 00065 } 00066 fprintf(p,"Subject: %s\n",obuf); 00067 fprintf(p,"subject: %s\n\n",obuf); 00068 fprintf(p,"%s\n",obuf); 00069 fclose(p); 00070 return x; 00071 }
Here is the call graph for this function: ![]() |
|
|
sysLogFac returns an integer representing the syslog facility given or -1 if name is unknown. Definition at line 109 of file log.c. Referenced by main(), and readConfig(). 00109 { 00110 int i; 00111 for(i = 0; facilitynames[i].c_name != NULL; i++) 00112 if(strcmp(name,facilitynames[i].c_name) == 0) 00113 return facilitynames[i].c_val; 00114 return -1; 00115 }
|
|
|
sysLogFac returns a pointer to a string representing the given log facility or NULL if fac is unknown. Definition at line 98 of file log.c. Referenced by dumpConfig(), and usage(). 00098 { 00099 int i; 00100 for(i = 0; facilitynames[i].c_name != NULL; i++) 00101 if(facilitynames[i].c_val == fac) 00102 return facilitynames[i].c_name; 00103 return NULL; 00104 }
|
|
|
sysLogPri returns an integer representing the syslog priority given or -1 if name is unknown. Definition at line 87 of file log.c. Referenced by main(), and readConfig(). 00087 { 00088 int i; 00089 for(i = 0; prioritynames[i].c_name != NULL; i++) 00090 if(strcmp(name,prioritynames[i].c_name) == 0) 00091 return prioritynames[i].c_val; 00092 return -1; 00093 }
|
|
|
sysLogPri returns a pointer to a string representing the given log priority or NULL if pri is unknown. Definition at line 76 of file log.c. Referenced by dumpConfig(), and usage(). 00076 { 00077 int i; 00078 for(i = 0; prioritynames[i].c_name != NULL; i++) 00079 if(prioritynames[i].c_val == pri) 00080 return prioritynames[i].c_name; 00081 return NULL; 00082 }
|
|
||||||||||||
|
write, printf-style, a message to the system log Definition at line 26 of file log.c. References confVarSyslog(). Referenced by compactIpList(), inform(), ipadd(), loadIpList(), and secwatch(). 00026 { 00027 va_list ap; 00028 static int fac=-1, pri, e; 00029 if(fac == -1) { 00030 fac = confVarSyslog("logfac",&e); 00031 pri = confVarSyslog("logpri",&e); 00032 } 00033 openlog("secwatch",LOG_PID,fac); 00034 va_start(ap,fmt); 00035 vsyslog(pri,fmt,ap); 00036 va_end(ap); 00037 return 1; 00038 }
Here is the call graph for this function: ![]() |
1.4.6