logger: add support for -H NAME to override system hostname
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
		@@ -37,6 +37,7 @@
 | 
			
		||||
.Op Fl d Ar SD
 | 
			
		||||
.Op Fl f Ar FILE
 | 
			
		||||
.Op Fl h Ar HOST
 | 
			
		||||
.Op Fl H Ar HOSTNAME
 | 
			
		||||
.Op Fl m Ar MSGID
 | 
			
		||||
.Op Fl p Ar PRIO
 | 
			
		||||
.Op Fl P Ar PORT
 | 
			
		||||
@@ -95,6 +96,11 @@ accepts
 | 
			
		||||
.Fl f-
 | 
			
		||||
as an alias for
 | 
			
		||||
.Ar stdout .
 | 
			
		||||
.It Fl H Ar hostname
 | 
			
		||||
Set the hostname in the header of the message to specified value.
 | 
			
		||||
If not specified, host part of
 | 
			
		||||
.Xr gethostname 3
 | 
			
		||||
will be used.
 | 
			
		||||
.It Fl h Ar host
 | 
			
		||||
Send the message to the remote system
 | 
			
		||||
.Ar host
 | 
			
		||||
 
 | 
			
		||||
@@ -236,6 +236,7 @@ static int usage(int code)
 | 
			
		||||
	       "  -d SD     Log SD as RFC5424 style 'structured data' in message\n"
 | 
			
		||||
	       "  -f FILE   Log file to write messages to, instead of syslog daemon\n"
 | 
			
		||||
	       "  -h HOST   Send (UDP) message to this remote syslog server (IP or DNS name)\n"
 | 
			
		||||
	       "  -H NAME   Use NAME instead of system hostname in message header\n"
 | 
			
		||||
	       "  -i        Log process ID of the logger process with each line (LOG_PID)\n"
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
	       "  -k        Log to kernel /dev/kmsg if /dev/log doesn't exist yet\n"
 | 
			
		||||
@@ -277,7 +278,7 @@ int main(int argc, char *argv[])
 | 
			
		||||
	int c, num = 5;
 | 
			
		||||
	int rotate = 0;
 | 
			
		||||
 | 
			
		||||
	while ((c = getopt(argc, argv, "46?bcd:f:h:ikm:np:P:r:st:u:v")) != EOF) {
 | 
			
		||||
	while ((c = getopt(argc, argv, "46?bcd:f:h:H:ikm:np:P:r:st:u:v")) != EOF) {
 | 
			
		||||
		switch (c) {
 | 
			
		||||
		case '4':
 | 
			
		||||
			family = AF_INET;
 | 
			
		||||
@@ -307,6 +308,10 @@ int main(int argc, char *argv[])
 | 
			
		||||
			host = optarg;
 | 
			
		||||
			break;
 | 
			
		||||
 | 
			
		||||
		case 'H':
 | 
			
		||||
			strlcpy(log.log_hostname, optarg, sizeof(log.log_hostname));
 | 
			
		||||
			break;
 | 
			
		||||
 | 
			
		||||
		case 'i':
 | 
			
		||||
			log_opts |= LOG_PID;
 | 
			
		||||
			break;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user