Browse Source

[syslog] Disable console when no syslog server is defined

Explicitly disable the syslog console when no syslog server is
defined, rather than (ab)using the socket family address as an
equivalent console-enabled flag.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
c72b8969e2
1 changed files with 5 additions and 7 deletions
  1. 5
    7
      src/net/udp/syslog.c

+ 5
- 7
src/net/udp/syslog.c View File

37
 
37
 
38
 /** The syslog server */
38
 /** The syslog server */
39
 static struct sockaddr_tcpip logserver = {
39
 static struct sockaddr_tcpip logserver = {
40
+	.st_family = AF_INET,
40
 	.st_port = htons ( SYSLOG_PORT ),
41
 	.st_port = htons ( SYSLOG_PORT ),
41
 };
42
 };
42
 
43
 
84
 static void syslog_putchar ( int character ) {
85
 static void syslog_putchar ( int character ) {
85
 	int rc;
86
 	int rc;
86
 
87
 
87
-	/* Do nothing if we have no log server */
88
-	if ( ! logserver.st_family )
89
-		return;
90
-
91
 	/* Ignore if we are already mid-logging */
88
 	/* Ignore if we are already mid-logging */
92
 	if ( syslog_entered )
89
 	if ( syslog_entered )
93
 		return;
90
 		return;
136
 /** Syslog console driver */
133
 /** Syslog console driver */
137
 struct console_driver syslog_console __console_driver = {
134
 struct console_driver syslog_console __console_driver = {
138
 	.putchar = syslog_putchar,
135
 	.putchar = syslog_putchar,
136
+	.disabled = 1,
139
 };
137
 };
140
 
138
 
141
 /******************************************************************************
139
 /******************************************************************************
166
 	int rc;
164
 	int rc;
167
 
165
 
168
 	/* Fetch log server */
166
 	/* Fetch log server */
167
+	syslog_console.disabled = 1;
169
 	old_addr.s_addr = sin_logserver->sin_addr.s_addr;
168
 	old_addr.s_addr = sin_logserver->sin_addr.s_addr;
170
-	logserver.st_family = 0;
171
 	if ( ( len = fetch_ipv4_setting ( NULL, &syslog_setting,
169
 	if ( ( len = fetch_ipv4_setting ( NULL, &syslog_setting,
172
 					  &sin_logserver->sin_addr ) ) >= 0 ) {
170
 					  &sin_logserver->sin_addr ) ) >= 0 ) {
173
-		sin_logserver->sin_family = AF_INET;
171
+		syslog_console.disabled = 0;
174
 	}
172
 	}
175
 
173
 
176
 	/* Do nothing unless log server has changed */
174
 	/* Do nothing unless log server has changed */
181
 	intf_restart ( &syslogger, 0 );
179
 	intf_restart ( &syslogger, 0 );
182
 
180
 
183
 	/* Do nothing unless we have a log server */
181
 	/* Do nothing unless we have a log server */
184
-	if ( ! logserver.st_family ) {
182
+	if ( syslog_console.disabled ) {
185
 		DBG ( "SYSLOG has no log server\n" );
183
 		DBG ( "SYSLOG has no log server\n" );
186
 		return 0;
184
 		return 0;
187
 	}
185
 	}

Loading…
Cancel
Save