summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--netfs/daemon/daemon.cpp5
1 files changed, 4 insertions, 1 deletions
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;