summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-05-21 17:19:58 +0200
committerLennart Poettering <lennart@poettering.net>2012-05-21 17:19:58 +0200
commit344de60901f0e3ce0d2f112b7be97fc6d0e2f071 (patch)
tree37c5d0b7187f93b6d1cba911f8f134ff9fe6ce2f /src/shared/util.c
parent97f25a02ee3fd6934eec6341373bb22de09e1ce2 (diff)
hostname-setup: also consider (ńone) an unset hostname
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index ae0ce320ad..0234f3b483 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -2949,12 +2949,20 @@ char* gethostname_malloc(void) {
assert_se(uname(&u) >= 0);
- if (u.nodename[0])
+ if (!isempty(u.nodename) && !streq(u.nodename, "(none)"))
return strdup(u.nodename);
return strdup(u.sysname);
}
+bool hostname_is_set(void) {
+ struct utsname u;
+
+ assert_se(uname(&u) >= 0);
+
+ return !isempty(u.nodename) && !streq(u.nodename, "(none)");
+}
+
char* getlogname_malloc(void) {
uid_t uid;
long bufsize;