Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/syslogd/syslogd.c
| Show First 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | |||||
| static int no_compress; /* don't compress messages (1=pipes, 2=all) */ | static int no_compress; /* don't compress messages (1=pipes, 2=all) */ | ||||
| static int logflags = O_WRONLY|O_APPEND; /* flags used to open log files */ | static int logflags = O_WRONLY|O_APPEND; /* flags used to open log files */ | ||||
| static char bootfile[MAXLINE+1]; /* booted kernel file */ | static char bootfile[MAXLINE+1]; /* booted kernel file */ | ||||
| struct allowedpeer *AllowedPeers; /* List of allowed peers */ | struct allowedpeer *AllowedPeers; /* List of allowed peers */ | ||||
| static int NumAllowed; /* Number of entries in AllowedPeers */ | static int NumAllowed; /* Number of entries in AllowedPeers */ | ||||
| static int RemoteAddDate; /* Always set the date on remote messages */ | static int RemoteAddDate; /* Always set the date on remote messages */ | ||||
| static int RemoteAddForwardedFrom = 1; /* Add "Forwarded From" for forwarded remote messages */ | |||||
| static int UniquePriority; /* Only log specified priority? */ | static int UniquePriority; /* Only log specified priority? */ | ||||
| static int LogFacPri; /* Put facility and priority in log message: */ | static int LogFacPri; /* Put facility and priority in log message: */ | ||||
| /* 0=no, 1=numeric, 2=names */ | /* 0=no, 1=numeric, 2=names */ | ||||
| static int KeepKernFac; /* Keep remotely logged kernel facility */ | static int KeepKernFac; /* Keep remotely logged kernel facility */ | ||||
| static int needdofsync = 0; /* Are any file(s) waiting to be fsynced? */ | static int needdofsync = 0; /* Are any file(s) waiting to be fsynced? */ | ||||
| static struct pidfh *pfh; | static struct pidfh *pfh; | ||||
| ▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | main(int argc, char *argv[]) | ||||
| pid_t ppid = 1, spid; | pid_t ppid = 1, spid; | ||||
| socklen_t len; | socklen_t len; | ||||
| if (madvise(NULL, 0, MADV_PROTECT) != 0) | if (madvise(NULL, 0, MADV_PROTECT) != 0) | ||||
| dprintf("madvise() failed: %s\n", strerror(errno)); | dprintf("madvise() failed: %s\n", strerror(errno)); | ||||
| STAILQ_INIT(&hqueue); | STAILQ_INIT(&hqueue); | ||||
| while ((ch = getopt(argc, argv, "468Aa:b:cCdf:Fkl:m:nNop:P:sS:Tuv")) | while ((ch = getopt(argc, argv, "468Aa:b:cCdf:Fkl:m:nNop:P:sS:tTuv")) | ||||
| != -1) | != -1) | ||||
| switch (ch) { | switch (ch) { | ||||
| case '4': | case '4': | ||||
| family = PF_INET; | family = PF_INET; | ||||
| break; | break; | ||||
| #ifdef INET6 | #ifdef INET6 | ||||
| case '6': | case '6': | ||||
| family = PF_INET6; | family = PF_INET6; | ||||
| ▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | #endif | ||||
| case 's': /* no network mode */ | case 's': /* no network mode */ | ||||
| SecureMode++; | SecureMode++; | ||||
| break; | break; | ||||
| case 'S': /* path for privileged originator */ | case 'S': /* path for privileged originator */ | ||||
| if (strlen(optarg) >= sizeof(sunx.sun_path)) | if (strlen(optarg) >= sizeof(sunx.sun_path)) | ||||
| errx(1, "%s path too long, exiting", optarg); | errx(1, "%s path too long, exiting", optarg); | ||||
| funix_secure.name = optarg; | funix_secure.name = optarg; | ||||
| break; | break; | ||||
| case 't': /* supress "Forwarded from" for forwarded remote messages */ | |||||
| RemoteAddForwardedFrom = 0; | |||||
| break; | |||||
| case 'T': | case 'T': | ||||
| RemoteAddDate = 1; | RemoteAddDate = 1; | ||||
| break; | break; | ||||
| case 'u': /* only log specified priority */ | case 'u': /* only log specified priority */ | ||||
| UniquePriority++; | UniquePriority++; | ||||
| break; | break; | ||||
| case 'v': /* log facility and priority */ | case 'v': /* log facility and priority */ | ||||
| LogFacPri++; | LogFacPri++; | ||||
| ▲ Show 20 Lines • Show All 736 Lines • ▼ Show 20 Lines | case F_FORW: | ||||
| port = (int)ntohs(((struct sockaddr_in *) | port = (int)ntohs(((struct sockaddr_in *) | ||||
| (f->f_un.f_forw.f_addr->ai_addr))->sin_port); | (f->f_un.f_forw.f_addr->ai_addr))->sin_port); | ||||
| if (port != 514) { | if (port != 514) { | ||||
| dprintf(" %s:%d\n", f->f_un.f_forw.f_hname, port); | dprintf(" %s:%d\n", f->f_un.f_forw.f_hname, port); | ||||
| } else { | } else { | ||||
| dprintf(" %s\n", f->f_un.f_forw.f_hname); | dprintf(" %s\n", f->f_un.f_forw.f_hname); | ||||
| } | } | ||||
| /* check for local vs remote messages */ | /* check for local vs remote messages */ | ||||
| if (strcasecmp(f->f_prevhost, LocalHostName)) | if (RemoteAddForwardedFrom && strcasecmp(f->f_prevhost, LocalHostName)) | ||||
| l = snprintf(line, sizeof line - 1, | l = snprintf(line, sizeof line - 1, | ||||
| "<%d>%.15s Forwarded from %s: %s", | "<%d>%.15s Forwarded from %s: %s", | ||||
| f->f_prevpri, (char *)iov[0].iov_base, | f->f_prevpri, (char *)iov[0].iov_base, | ||||
| f->f_prevhost, (char *)iov[5].iov_base); | f->f_prevhost, (char *)iov[5].iov_base); | ||||
| else | else | ||||
| l = snprintf(line, sizeof line - 1, "<%d>%.15s %s", | l = snprintf(line, sizeof line - 1, "<%d>%.15s %s", | ||||
| f->f_prevpri, (char *)iov[0].iov_base, | f->f_prevpri, (char *)iov[0].iov_base, | ||||
| (char *)iov[5].iov_base); | (char *)iov[5].iov_base); | ||||
| ▲ Show 20 Lines • Show All 1,655 Lines • Show Last 20 Lines | |||||