summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-10-28 13:41:35 +0100
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-11-03 19:26:00 +0100
commitacd09007a12e4901aa5d221af18de9c42044d970 (patch)
tree8c739436d2993c9b67c4847a1e9e1147939c3e44 /cmd
parentd4ce928fc011700acefefd5472d0a5ef8c72e6c1 (diff)
Remove usyslogd/klogd and syslog utility program
This is split out to a seperate package. Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/Makemodule.am11
-rw-r--r--cmd/syslog.147
-rw-r--r--cmd/syslog.c223
3 files changed, 0 insertions, 281 deletions
diff --git a/cmd/Makemodule.am b/cmd/Makemodule.am
index 76a0e49..30e9619 100644
--- a/cmd/Makemodule.am
+++ b/cmd/Makemodule.am
@@ -31,17 +31,6 @@ service_SOURCES += cmd/service/schedule.c
service_SOURCES += cmd/service/unschedule.c
endif
-if USYSLOGD
-syslog_SOURCES = cmd/syslog.c
-syslog_CPPFLAGS = $(AM_CPPFLAGS)
-syslog_CFLAGS = $(AM_CFLAGS)
-syslog_LDFLAGS = $(AM_LDFLAGS)
-syslog_LDADD = libinit.a
-
-bin_PROGRAMS += syslog
-dist_man1_MANS += cmd/syslog.1
-endif
-
dist_man8_MANS += cmd/shutdown.8 cmd/service/service.8
EXTRA_DIST += $(SRVHEADERS)
diff --git a/cmd/syslog.1 b/cmd/syslog.1
deleted file mode 100644
index 382b568..0000000
--- a/cmd/syslog.1
+++ /dev/null
@@ -1,47 +0,0 @@
-.TH syslog 1 "August 2018" "Pygos Init"
-.SH NAME
-syslog \- send a log message to the syslog daemon
-.SH SYNOPSIS
-.B syslog
-[options] message..
-.SH DESCRIPTION
-The syslog command concatenates all non option arguments to a single message
-that it sends to the syslog daemon.
-.SH OPTIONS
-.TP
-.BR \-h , " \-\-help"
-Display a brief help text, a list of available facilities, log levels, all the
-default setting and exit.
-.TP
-.BR \-V , " \-\-version"
-Print version information and exit.
-.TP
-.BR \-f , " \-\-facility " \fIfacility\fP
-Logging facility name or numeric identifier. Use
-.B \-\-help
-to get a list of all available facility names.
-.TP
-.BR \-l , " \-\-level " \fIlevel\fP
-A log level number from 0 to 8 with 8 being most severe, or a name from
-.I debug
-to
-.I emergency.
-Use
-.B \-\-help
-to get a list of all available log level names.
-.TP
-.BR \-i , " \-\-ident " \fIname\fP
-Program name to specify to syslog. If not set, "(shell)" is used as sensible
-default to indicate that the message came from the command line.
-.TP
-.BR \-c , " \-\-console"
-Try to write directly to the console if opening the syslog socket fails.
-.SH AVAILABILITY
-This program is part of the Pygos init system.
-.SH COPYRIGHT
-Copyright \(co 2018 David Oberhollenzer
-.br
-License: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
-.br
-This is free software: you are free to change and redistribute it.
-There is NO WARRANTY, to the extent permitted by law.
diff --git a/cmd/syslog.c b/cmd/syslog.c
deleted file mode 100644
index 48c9343..0000000
--- a/cmd/syslog.c
+++ /dev/null
@@ -1,223 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-/*
- * Copyright (C) 2018 - David Oberhollenzer
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-#include <getopt.h>
-#include <syslog.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <ctype.h>
-#include "util.h"
-
-static int facility = LOG_USER;
-static int level = LOG_INFO;
-static int flags = LOG_NDELAY | LOG_NOWAIT;
-static const char *ident = "(shell)";
-
-static const enum_map_t facility_map[] = {
- { "auth", LOG_AUTH },
- { "cron", LOG_CRON },
- { "daemon", LOG_DAEMON },
- { "ftp", LOG_FTP },
- { "local0", LOG_LOCAL0 },
- { "local1", LOG_LOCAL1 },
- { "local2", LOG_LOCAL2 },
- { "local3", LOG_LOCAL3 },
- { "local4", LOG_LOCAL4 },
- { "local5", LOG_LOCAL5 },
- { "local6", LOG_LOCAL6 },
- { "local7", LOG_LOCAL7 },
- { "lpr", LOG_LPR },
- { "news", LOG_NEWS },
- { "user", LOG_USER },
- { "uucp", LOG_UUCP },
- { NULL, 0 },
-};
-
-static const enum_map_t level_map[] = {
- { "emergency", LOG_EMERG },
- { "alert", LOG_ALERT },
- { "critical", LOG_CRIT },
- { "error", LOG_ERR },
- { "warning", LOG_WARNING },
- { "notice", LOG_NOTICE },
- { "info", LOG_INFO },
- { "debug", LOG_DEBUG },
- { NULL, 0 },
-};
-
-static const struct option options[] = {
- { "help", no_argument, NULL, 'h' },
- { "version", no_argument, NULL, 'V' },
- { "console", required_argument, NULL, 'c' },
- { "facility", required_argument, NULL, 'f' },
- { "level", required_argument, NULL, 'l' },
- { "ident", required_argument, NULL, 'i' },
- { NULL, 0, NULL, 0 },
-};
-
-static const char *shortopt = "hVcf:l:i:";
-
-static const char *helptext =
-"Usage: syslog [OPTION]... [STRING]...\n\n"
-"Concatenate the given STRINGs and send a log message to the syslog daemon.\n"
-"\n"
-"The following OPTIONSs can be used:\n"
-" -f, --facility <facility> Logging facilty name or numeric identifier.\n"
-" -l, --level <level> Log level name or numeric identifier.\n"
-" -i, --ident <name> Program name for log syslog message.\n"
-" Default is %s.\n\n"
-" -c, --console Write to the console if opening the syslog\n"
-" socket fails.\n\n"
-" -h, --help Print this help text and exit\n"
-" -V, --version Print version information and exit\n\n";
-
-static void print_map(const enum_map_t *map, int defaultval,
- const char *option)
-{
- size_t i;
-
- printf("The following values can be used for %s:\n", option);
-
- for (i = 0; map[i].name != NULL; ++i) {
- if (map[i].value == defaultval) {
- printf(" %s (=%d), set as default\n",
- map[i].name, map[i].value);
- } else {
- printf(" %s (=%d)\n", map[i].name, map[i].value);
- }
- }
-
- fputc('\n', stdout);
-}
-
-static NORETURN void usage(int status)
-{
- if (status != EXIT_SUCCESS) {
- fputs("Try `syslog --help' for more information\n", stderr);
- } else {
- printf(helptext, ident);
- print_map(level_map, level, "--level");
- print_map(facility_map, facility, "--facility");
- }
-
- exit(status);
-}
-
-static int readint(const char *str)
-{
- int x = 0;
-
- if (!isdigit(*str))
- return -1;
-
- while (isdigit(*str))
- x = x * 10 + (*(str++)) - '0';
-
- return (*str == '\0') ? x : -1;
-}
-
-static void process_options(int argc, char **argv)
-{
- const enum_map_t *e;
- int c;
-
- for (;;) {
- c = getopt_long(argc, argv, shortopt, options, NULL);
- if (c == -1)
- break;
-
- switch (c) {
- case 'f':
- facility = readint(optarg);
- if (facility >= 0)
- break;
- e = enum_by_name(facility_map, optarg);
- if (e == NULL) {
- fprintf(stderr, "Unknown facility name '%s'\n",
- optarg);
- usage(EXIT_FAILURE);
- }
- facility = e->value;
- break;
- case 'l':
- level = readint(optarg);
- if (level >= 0)
- break;
- e = enum_by_name(level_map, optarg);
- if (e == NULL) {
- fprintf(stderr, "Unknown log level '%s'\n",
- optarg);
- usage(EXIT_FAILURE);
- }
- level = e->value;
- break;
- case 'i':
- ident = optarg;
- break;
- case 'c':
- flags |= LOG_CONS;
- break;
- case 'h':
- usage(EXIT_SUCCESS);
- case 'V':
- print_version("syslog");
- default:
- usage(EXIT_FAILURE);
- }
- }
-}
-
-
-int main(int argc, char **argv)
-{
- size_t len = 0;
- char *str;
- int i;
-
- process_options(argc, argv);
-
- if (optind >= argc) {
- fputs("Error: no log string provided.\n", stderr);
- usage(EXIT_FAILURE);
- }
-
- for (i = optind; i < argc; ++i)
- len += strlen(argv[i]);
-
- len += argc - optind - 1;
-
- str = calloc(1, len + 1);
- if (str == NULL) {
- fputs("syslog: out of memory\n", stderr);
- return EXIT_FAILURE;
- }
-
- for (i = optind; i < argc; ++i) {
- if (i > optind)
- strcat(str, " ");
- strcat(str, argv[i]);
- }
-
- openlog(ident, flags, facility);
- syslog(level, "%s", str);
- closelog();
-
- free(str);
- return EXIT_SUCCESS;
-}
-