From 3a4193a743904cc9526f71b6d9015905566cc5f7 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 2 Apr 2019 18:54:06 +0100 Subject: Fix hostname lookup --- netfs/daemon/daemon.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/netfs/daemon/daemon.cpp b/netfs/daemon/daemon.cpp index a773716..ddd67f2 100644 --- a/netfs/daemon/daemon.cpp +++ b/netfs/daemon/daemon.cpp @@ -21,7 +21,10 @@ NetFSDaemon::hostname() auto hostNameOverride = props->getProperty("NetFSD.HostNameOverride"); if (hostNameOverride.empty()) { std::string buf(128, 0); - gethostname(buf.data(), buf.size()); + if (gethostname(buf.data(), buf.size())) { + throw NetFS::Daemon::HostNotConfigured(strerror(errno)); + } + buf.resize(strlen(buf.data())); return buf; } return hostNameOverride; -- cgit v1.2.3