New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
logger: target server required if using port option #2684
Comments
It seems the code in the logger to connect the server is ready (as it uses getaddrinfo() where NULL as the It seems a trivial patch may improve it: diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index e1d270de8..e35220a16 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -923,7 +923,7 @@ static void generate_syslog_header(struct logger_ctl *const ctl)
/* just open, nothing else */
static void __logger_open(struct logger_ctl *ctl)
{
- if (ctl->server) {
+ if (ctl->server || ctl->port) {
ctl->fd = inet_socket(ctl->server, ctl->port, &ctl->socket_type);
} else {
if (!ctl->unix_socket)
The ideal is to use strace to see what happens. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actual Behavior:
A call to logger such as
does not work. It seems that the call MUST include the target syslog server if the port parameter (-P) is specified:
works.
Expected behavior:
Calls to logger specifying a port number should not require that the target server be specified. This is useful for performing local testing of, say, a new ruleset in rsyslog without having to type out the name or address of the target syslog server. The current behavior of logger is not indicated explicitly in the current documentation for logger.
Environment:
devuan daedalus (debian bookworm) / rsyslog 8.2302.0 / logger 2.38.1
devaun chimaera (debian bullseye) / rsyslog 8.2102.0 / logger 2.36.1
possibly other configurations, untested
THERE IS NO SYSTEMD ON DEVUAN
Error Handling;
If the current behavior is intentional, then the user should be alerted to the need to specify a target syslog server with an error message clearly stating this.
If the current behavior is not intentional, then the program should handle the invocation without an error and make its best attempt to send the log message to a default syslog server. (See my comment about this, below.) If, for whatever reason, logger cannot locate a working default syslogger on the local system, then it should error out.
BTW, it is understood that the default UDP protocol does not guarantee delivery of a log message. But if the message is simply headed to the syslog on the local host, it should be able to detect the presence or lack thereof since the facilities are on the same host.
Documentation:
If the current behavior is intentional, then the documentation for logger should be explicit in stating that the syslog server option (-n) MUST be provided if the port (-P) option is specified. This should be pointed out in the paragraph explaining the -P option (and possibly the -n option).
Otherwise, if the current behavior is not intentional, it should be corrected to accept the local syslog server by default. If there are multiple instances of a syslogger running on the local system, then the default should be the same as the default address of the local host. If the default address can not be deduced by fairly straightforward hints and assumptions, then the user should be directed to specify a target. Again, this should be pointed out in the paragraph explaining the -P option in the logger documentation.
If none of this is possible due to support issues for unusual system configurations, the documentation STILL needs to be updated to reflect this.
In conclusion, the documentation needs revision under any circumstances. Too much time is wasted running this issue down when returning to work involving logger calls after long periods of doing other things; it is too difficult to remember this (implicit?) requirement.
The text was updated successfully, but these errors were encountered: