--- /dev/null
+From eaa3940275e6977175754f35b44c3fc646779902 Mon Sep 17 00:00:00 2001
+From: Greg Kurz <groug@kaod.org>
+Date: Sat, 13 Jan 2024 11:05:45 +0100
+Subject: [PATCH] Don't set hostname with the unix backend
+
+The UNIX socket specific initialization functions `init_unix()` and
+`init_unix_custom()` take care of not setting the hostname in the
+header. This is based on the assumption that a syslog relay will
+set the appropriate hostname (see PR #7).
+
+The generic initialization function `init()` that supports UNIX, UDP
+and TCP sockets does set the hostname unconditionally though. Users
+of this API end up with an extra hostname being added to their logs,
+as seen with virtiofsd for example :
+
+Jan 12 17:03:04 myhostname virtiofsd[70727]: myhostname virtiofsd[70725]: Waiting for vhost-user socket connection...
+
+Only set the hostname for UDP and TCP.
+
+Signed-off-by: Greg Kurz <groug@kaod.org>
+---
+ src/lib.rs | 16 +++++++++-------
+ 1 file changed, 9 insertions(+), 7 deletions(-)
+
+Index: syslog/src/lib.rs
+===================================================================
+--- syslog.orig/src/lib.rs
++++ syslog/src/lib.rs
+@@ -474,9 +474,9 @@ pub fn init(
+ ) -> Result<()> {
+ let (process_name, pid) = get_process_info()?;
+ let process = application_name.map(From::from).unwrap_or(process_name);
+- let formatter = Formatter3164 {
++ let mut formatter = Formatter3164 {
+ facility,
+- hostname: get_hostname().ok(),
++ hostname: None,
+ process,
+ pid,
+ };
+@@ -484,11 +484,13 @@ pub fn init(
+ let backend = unix(formatter.clone())
+ .map(|logger: Logger<LoggerBackend, Formatter3164>| logger.backend)
+ .or_else(|_| {
+- TcpStream::connect(("127.0.0.1", 601)).map(|s| LoggerBackend::Tcp(BufWriter::new(s)))
+- })
+- .or_else(|_| {
+- let udp_addr = "127.0.0.1:514".parse().unwrap();
+- UdpSocket::bind(("127.0.0.1", 0)).map(|s| LoggerBackend::Udp(s, udp_addr))
++ formatter.hostname = get_hostname().ok();
++ TcpStream::connect(("127.0.0.1", 601))
++ .map(|s| LoggerBackend::Tcp(BufWriter::new(s)))
++ .or_else(|_| {
++ let udp_addr = "127.0.0.1:514".parse().unwrap();
++ UdpSocket::bind(("127.0.0.1", 0)).map(|s| LoggerBackend::Udp(s, udp_addr))
++ })
+ })?;
+ log::set_boxed_logger(Box::new(BasicLogger::new(Logger { formatter, backend })))
+ .chain_err(|| ErrorKind::Initialization)?;