2 ashd - A Sane HTTP Daemon
3 Copyright (C) 2008 Fredrik Tolf <fredrik@dolda2000.com>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
29 static void logloop(int fd)
36 while(fgets(buf, sizeof(buf), in) != NULL) {
38 if(buf[len - 1] == '\n')
40 syslog(prio, "%s", buf);
45 static void usage(FILE *out)
47 fprintf(out, "usage: errlogger [-h] [-n NAME] [-f FACILITY] [-p PRIO] PROGRAM [ARGS...]\n");
50 int main(int argc, char **argv)
61 while((c = getopt(argc, argv, "hn:p:f:")) >= 0) {
67 if(!strcmp(optarg, "auth")) {
69 } else if(!strcmp(optarg, "authpriv")) {
71 } else if(!strcmp(optarg, "cron")) {
73 } else if(!strcmp(optarg, "daemon")) {
75 } else if(!strcmp(optarg, "ftp")) {
77 } else if(!strcmp(optarg, "kern")) {
79 } else if(!strcmp(optarg, "lpr")) {
81 } else if(!strcmp(optarg, "mail")) {
83 } else if(!strcmp(optarg, "news")) {
85 } else if(!strcmp(optarg, "user")) {
87 } else if(!strcmp(optarg, "uucp")) {
89 } else if(!strncmp(optarg, "local", 5) && (optarg[5] >= '0') && (optarg[5] <= '7') && !optarg[6]) {
90 fac = LOG_LOCAL0 + (optarg[5] - '0');
92 fprintf(stderr, "errlogger: unknown facility %s\n", optarg);
97 if(!strcmp(optarg, "emerg")) {
99 } else if(!strcmp(optarg, "alert")) {
101 } else if(!strcmp(optarg, "crit")) {
103 } else if(!strcmp(optarg, "err")) {
105 } else if(!strcmp(optarg, "warning")) {
107 } else if(!strcmp(optarg, "notice")) {
109 } else if(!strcmp(optarg, "info")) {
111 } else if(!strcmp(optarg, "debug")) {
114 fprintf(stderr, "errlogger: unknown priorty %s\n", optarg);
126 if(argc - optind < 1) {
132 openlog(name, 0, fac);
134 if((ch = fork()) == 0) {
140 execvp(argv[optind], argv + optind);
141 fprintf(stderr, "errlogger: %s: %s", argv[optind], strerror(errno));
145 signal(SIGCHLD, SIG_IGN);