aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libbb.h3
-rw-r--r--init/init.c4
-rw-r--r--libbb/Makefile.in2
-rw-r--r--libbb/syslog_msg_with_name.c45
-rw-r--r--loginutils/getty.c4
-rw-r--r--networking/telnetd.c12
-rw-r--r--sysklogd/klogd.c19
7 files changed, 22 insertions, 67 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 17a5940ca..c52e65555 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -249,9 +249,6 @@ extern int vdprintf(int d, const char *format, va_list ap);
int nfsmount(const char *spec, const char *node, int *flags,
char **extra_opts, char **mount_opts, int running_bg);
-void syslog_msg_with_name(const char *name, int facility, int pri, const char *msg);
-void syslog_msg(int facility, int pri, const char *msg);
-
/* Include our own copy of struct sysinfo to avoid binary compatability
* problems with Linux 2.4, which changed things. Grumble, grumble. */
struct sysinfo {
diff --git a/init/init.c b/init/init.c
index 588e4e75c..11ebc6bf9 100644
--- a/init/init.c
+++ b/init/init.c
@@ -229,7 +229,9 @@ static void message(int device, const char *fmt, ...)
/* Log the message to syslogd */
if (device & LOG) {
/* don`t out "\r\n" */
- syslog_msg(LOG_DAEMON, LOG_INFO, msg + 1);
+ openlog(bb_applet_name, 0, LOG_DAEMON);
+ syslog(LOG_INFO, "%s", msg);
+ closelog();
}
msg[l++] = '\n';
diff --git a/libbb/Makefile.in b/libbb/Makefile.in
index eff3224b1..f993b21ea 100644
--- a/libbb/Makefile.in
+++ b/libbb/Makefile.in
@@ -41,7 +41,7 @@ LIBBB_SRC:= \
read_package_field.c recursive_action.c remove_file.c \
restricted_shell.c run_parts.c run_shell.c safe_read.c safe_write.c \
safe_strncpy.c setup_environment.c simplify_path.c syscalls.c \
- syslog_msg_with_name.c trim.c u_signal_names.c vdprintf.c verror_msg.c \
+ trim.c u_signal_names.c vdprintf.c verror_msg.c \
vherror_msg.c vperror_msg.c wfopen.c xconnect.c xgetcwd.c \
xgethostbyname.c xgethostbyname2.c xreadlink.c xregcomp.c xgetlarg.c \
get_terminal_width_height.c fclose_nonstdin.c fflush_stdout_and_exit.c \
diff --git a/libbb/syslog_msg_with_name.c b/libbb/syslog_msg_with_name.c
index ac472dbda..e69de29bb 100644
--- a/libbb/syslog_msg_with_name.c
+++ b/libbb/syslog_msg_with_name.c
@@ -1,45 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Utility routines.
- *
- * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
- *
- * 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 2 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <stdio.h>
-#include <sys/syslog.h>
-#include "libbb.h"
-
-void syslog_msg_with_name(const char *name, int facility, int pri, const char *msg)
-{
- openlog(name, 0, facility);
- syslog(pri, "%s", msg);
- closelog();
-}
-
-void syslog_msg(int facility, int pri, const char *msg)
-{
- syslog_msg_with_name(bb_applet_name, facility, pri, msg);
-}
-
-/* END CODE */
-/*
-Local Variables:
-c-file-style: "linux"
-c-basic-offset: 4
-tab-width: 4
-End:
-*/
diff --git a/loginutils/getty.c b/loginutils/getty.c
index 0e475e4c0..b211733ee 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -998,7 +998,9 @@ static void error(const char *fmt, ...)
va_end(va_alist);
#ifdef USE_SYSLOG
- syslog_msg(LOG_AUTH, LOG_ERR, buf);
+ openlog(bb_applet_name, 0, LOG_AUTH);
+ syslog(LOG_ERR, "%s", buf);
+ closelog();
#else
strncat(bp, "\r\n", 256 - strlen(buf));
buf[255] = 0;
diff --git a/networking/telnetd.c b/networking/telnetd.c
index efb2988b3..724c7cf75 100644
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
@@ -1,4 +1,4 @@
-/* $Id: telnetd.c,v 1.11 2004/03/15 08:28:53 andersen Exp $
+/* $Id: telnetd.c,v 1.12 2004/06/22 10:07:17 andersen Exp $
*
* Simple telnet server
* Bjorn Wesen, Axis Communications AB (bjornw@axis.com)
@@ -269,7 +269,7 @@ make_new_session(int sockfd)
pty = getpty(tty_name);
if (pty < 0) {
- syslog_msg(LOG_USER, LOG_ERR, "All network ports in use!");
+ syslog(LOG_ERR, "All network ports in use!");
return 0;
}
@@ -292,7 +292,7 @@ make_new_session(int sockfd)
if ((pid = fork()) < 0) {
- syslog_msg(LOG_USER, LOG_ERR, "Can`t forking");
+ syslog(LOG_ERR, "Can`t forking");
}
if (pid == 0) {
/* In child, open the child's side of the tty. */
@@ -304,7 +304,7 @@ make_new_session(int sockfd)
setsid();
if (open(tty_name, O_RDWR /*| O_NOCTTY*/) < 0) {
- syslog_msg(LOG_USER, LOG_ERR, "Could not open tty");
+ syslog(LOG_ERR, "Could not open tty");
exit(1);
}
dup(0);
@@ -330,7 +330,7 @@ make_new_session(int sockfd)
execv(loginpath, (char *const *)argv_init);
/* NOT REACHED */
- syslog_msg(LOG_USER, LOG_ERR, "execv error");
+ syslog(LOG_ERR, "execv error");
exit(1);
}
@@ -422,6 +422,8 @@ telnetd_main(int argc, char **argv)
argv_init[0] = loginpath;
+ openlog(bb_applet_name, 0, LOG_USER);
+
#ifdef CONFIG_FEATURE_TELNETD_INETD
maxfd = 1;
sessions = make_new_session();
diff --git a/sysklogd/klogd.c b/sysklogd/klogd.c
index 94da61658..9f07d6743 100644
--- a/sysklogd/klogd.c
+++ b/sysklogd/klogd.c
@@ -47,8 +47,8 @@ static void klogd_signal(int sig)
klogctl(7, NULL, 0);
klogctl(0, 0, 0);
/* logMessage(0, "Kernel log daemon exiting."); */
- syslog_msg(LOG_SYSLOG, LOG_NOTICE, "Kernel log daemon exiting.");
- exit(TRUE);
+ syslog(LOG_NOTICE, "Kernel log daemon exiting.");
+ exit(EXIT_SUCCESS);
}
static void doKlogd(const char console_log_level) __attribute__ ((noreturn));
@@ -59,6 +59,8 @@ static void doKlogd(const char console_log_level)
int i, n, lastc;
char *start;
+ openlog("kernel", 0, LOG_KERN);
+
/* Set up sig handlers */
signal(SIGINT, klogd_signal);
signal(SIGKILL, klogd_signal);
@@ -72,22 +74,17 @@ static void doKlogd(const char console_log_level)
if (console_log_level)
klogctl(8, NULL, console_log_level);
- syslog_msg(LOG_SYSLOG, LOG_NOTICE, "klogd started: " BB_BANNER);
+ syslog(LOG_NOTICE, "klogd started: " BB_BANNER);
while (1) {
/* Use kernel syscalls */
memset(log_buffer, '\0', sizeof(log_buffer));
n = klogctl(2, log_buffer, sizeof(log_buffer));
if (n < 0) {
- char message[80];
-
if (errno == EINTR)
continue;
- snprintf(message, 79,
- "klogd: Error return from sys_sycall: %d - %s.\n", errno,
- strerror(errno));
- syslog_msg(LOG_SYSLOG, LOG_ERR, message);
- exit(1);
+ syslog(LOG_ERR, "klogd: Error return from sys_sycall: %d - %s.\n", errno, strerror(errno));
+ exit(EXIT_FAILURE);
}
/* klogctl buffer parsing modelled after code in dmesg.c */
@@ -107,7 +104,7 @@ static void doKlogd(const char console_log_level)
}
if (log_buffer[i] == '\n') {
log_buffer[i] = '\0'; /* zero terminate this message */
- syslog_msg(LOG_KERN, priority, start);
+ syslog(priority, start);
start = &log_buffer[i + 1];
priority = LOG_INFO;
}