}
static bool hostname_is_useful(const char *hn) {
- return !isempty(hn) && !streq(hn, "localhost");
+ return !isempty(hn) && !is_localhost(hn);
}
static int context_update_kernel_hostname(Context *c) {
if (isempty(class))
class = streq(type, "unspecified") ? "background" : "user";
- remote = !isempty(remote_host) &&
- !streq_ptr(remote_host, "localhost") &&
- !streq_ptr(remote_host, "localhost.localdomain");
+ remote = !isempty(remote_host) && !is_localhost(remote_host);
/* Talk to logind over the message bus */
return 0;
}
-/* make sure the hostname is not "localhost" */
-static bool is_localhost(const char *hostname) {
- assert(hostname);
-
- return streq(hostname, "localhost") ||
- streq(hostname, "localhost.") ||
- endswith(hostname, ".localhost") ||
- endswith(hostname, ".localhost.") ||
- endswith(hostname, ".localdomain") ||
- endswith(hostname, ".localdomain.");
-}
-
static int link_configure(Link *link) {
int r;
return t;
}
+
+/* make sure the hostname is not "localhost" */
+bool is_localhost(const char *hostname) {
+ assert(hostname);
+
+ /* This tries to identify local hostnames described in RFC6761
+ * plus the redhatism of .localdomain */
+
+ return streq(hostname, "localhost") ||
+ streq(hostname, "localhost.") ||
+ endswith(hostname, ".localhost") ||
+ endswith(hostname, ".localhost.") ||
+ endswith(hostname, ".localdomain") ||
+ endswith(hostname, ".localdomain.");
+}
char *tempfn_xxxxxx(const char *p);
char *tempfn_random(const char *p);
+
+bool is_localhost(const char *hostname);