From: Tobias Stoeckmann Date: Tue, 7 Apr 2026 18:40:33 +0000 (+0200) Subject: agetty: Always use syslog X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e2941891105eb93b58060b32df02c51bf14d581;p=thirdparty%2Futil-linux.git agetty: Always use syslog No known systems exist which use agetty and are neither Linux, GNU, nor FreeBSD. Even MinGW/MSYS use syslog. Alternative systems which could use the fallback do not build agetty, e.g. OpenIndiana or other such systems. This gets rid of a bug in custom /dev/console code in which the formatter could be modified by a link to agetty containing more printf modifiers in its name. It's not worth to fix it. Signed-off-by: Tobias Stoeckmann --- diff --git a/term-utils/agetty.c b/term-utils/agetty.c index 0ce8fca61..ee7ce5feb 100644 --- a/term-utils/agetty.c +++ b/term-utils/agetty.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "strutils.h" #include "all-io.h" @@ -85,18 +86,6 @@ #ifdef __linux__ # include -# define USE_SYSLOG -#elif defined(__GNU__) -# define USE_SYSLOG -#endif - -#ifdef __FreeBSD_kernel__ -#define USE_SYSLOG -#endif - -/* If USE_SYSLOG is undefined all diagnostics go to /dev/console. */ -#ifdef USE_SYSLOG -# include #endif /* @@ -689,9 +678,6 @@ static void output_version(void) #ifdef AGETTY_RELOAD "reload", #endif -#ifdef USE_SYSLOG - "syslog", -#endif #ifdef USE_SYSTEMD "systemd", #endif @@ -2539,44 +2525,16 @@ static void list_speeds(void) } /* - * Helper function reports errors to console or syslog. + * Helper function reports errors to syslog. * Will be used by log_err() and log_warn() therefore * it takes a format as well as va_list. */ static void dolog(int priority -#ifndef USE_SYSLOG - __attribute__((__unused__)) -#endif , const char *fmt, va_list ap) { -#ifdef USE_SYSLOG - /* - * If the diagnostic is reported via syslog(3), the process name is - * automatically prepended to the message. If we write directly to - * /dev/console, we must prepend the process name ourselves. - */ openlog("agetty", LOG_PID, LOG_AUTHPRIV); vsyslog(priority, fmt, ap); closelog(); -#else - /* - * Write the diagnostic directly to /dev/console if we do not use - * the syslog(3) facility. - */ - char buf[BUFSIZ]; - char new_fmt[BUFSIZ]; - int fd; - - snprintf(new_fmt, sizeof(new_fmt), "%s: %s\r\n", - program_invocation_short_name, fmt); - /* Terminate with CR-LF since the console mode is unknown. */ - vsnprintf(buf, sizeof(buf), new_fmt, ap); - - if ((fd = open("/dev/console", 1)) >= 0) { - write_all(fd, buf, strlen(buf)); - close(fd); - } -#endif /* USE_SYSLOG */ } static void exit_slowly(int code)