[BusyBox-cvs] CVS update of busybox (include/libbb.h init/init.c libbb/Makefile.in libbb/syslog_msg_with_name.c loginutils/getty.c networking/telnetd.c sysklogd/klogd.c)
Erik Andersen
andersen at codepoet.org
Tue Jun 22 10:07:18 UTC 2004
Date: Tuesday, June 22, 2004 @ 04:07:18
Author: andersen
Path: /var/cvs/busybox
Modified: include/libbb.h (1.131 -> 1.132) init/init.c (1.202 -> 1.203)
libbb/Makefile.in (1.35 -> 1.36) libbb/syslog_msg_with_name.c
(1.6 -> 1.7) loginutils/getty.c (1.10 -> 1.11)
networking/telnetd.c (1.11 -> 1.12) sysklogd/klogd.c (1.20 ->
1.21)
Patch from Bastian Blank:
On Sat, Jun 19, 2004 at 10:57:37PM +0200, Bastian Blank wrote:
> The following patch changes klogd to use openlog/syslog themself
> instead of calling syslog_msg which always calls the triple
> openlog/syslog/closelog.
Updated patch: get rid of syslog_msg entirely. Request from Erik Andersen.
Bastian
Index: busybox/include/libbb.h
diff -u busybox/include/libbb.h:1.131 busybox/include/libbb.h:1.132
--- busybox/include/libbb.h:1.131 Tue Jun 22 02:29:44 2004
+++ busybox/include/libbb.h Tue Jun 22 04:07:15 2004
@@ -249,9 +249,6 @@
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 {
Index: busybox/init/init.c
diff -u busybox/init/init.c:1.202 busybox/init/init.c:1.203
--- busybox/init/init.c:1.202 Mon Apr 12 13:21:54 2004
+++ busybox/init/init.c Tue Jun 22 04:07:15 2004
@@ -229,7 +229,9 @@
/* 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';
Index: busybox/libbb/Makefile.in
diff -u busybox/libbb/Makefile.in:1.35 busybox/libbb/Makefile.in:1.36
--- busybox/libbb/Makefile.in:1.35 Fri Apr 30 19:27:30 2004
+++ busybox/libbb/Makefile.in Tue Jun 22 04:07:16 2004
@@ -41,7 +41,7 @@
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 \
Index: busybox/libbb/syslog_msg_with_name.c
diff -u busybox/libbb/syslog_msg_with_name.c:1.6 busybox/libbb/syslog_msg_with_name.c:1.7
--- busybox/libbb/syslog_msg_with_name.c:1.6 Mon Mar 15 01:28:43 2004
+++ busybox/libbb/syslog_msg_with_name.c Tue Jun 22 04:07:16 2004
@@ -1,45 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Utility routines.
- *
- * Copyright (C) 1999-2004 by Erik Andersen <andersen at 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:
-*/
Index: busybox/loginutils/getty.c
diff -u busybox/loginutils/getty.c:1.10 busybox/loginutils/getty.c:1.11
--- busybox/loginutils/getty.c:1.10 Mon Mar 15 01:28:46 2004
+++ busybox/loginutils/getty.c Tue Jun 22 04:07:16 2004
@@ -998,7 +998,9 @@
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;
Index: busybox/networking/telnetd.c
diff -u busybox/networking/telnetd.c:1.11 busybox/networking/telnetd.c:1.12
--- busybox/networking/telnetd.c:1.11 Mon Mar 15 01:28:53 2004
+++ busybox/networking/telnetd.c Tue Jun 22 04:07:17 2004
@@ -269,7 +269,7 @@
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 @@
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 @@
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 @@
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 @@
argv_init[0] = loginpath;
+ openlog(bb_applet_name, 0, LOG_USER);
+
#ifdef CONFIG_FEATURE_TELNETD_INETD
maxfd = 1;
sessions = make_new_session();
Index: busybox/sysklogd/klogd.c
diff -u busybox/sysklogd/klogd.c:1.20 busybox/sysklogd/klogd.c:1.21
--- busybox/sysklogd/klogd.c:1.20 Mon Mar 15 01:29:16 2004
+++ busybox/sysklogd/klogd.c Tue Jun 22 04:07:17 2004
@@ -47,8 +47,8 @@
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 @@
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 @@
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 @@
}
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;
}
More information about the busybox-cvs
mailing list