summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2014-06-30 13:55:04 +0200
committerJiří Klimeš <jklimes@redhat.com>2014-07-14 17:36:07 +0200
commit70e930bc0e7e52ed7f420cea07c40d10387d7cb2 (patch)
treeee3673d0f2cf83ea28c14f60dd8c41dbf20086e2
parent568742ed4138b909c6c1f3588920f93f81f08d32 (diff)
downloadNetworkManager-70e930bc0e7e52ed7f420cea07c40d10387d7cb2.tar.gz
utils: add nm_utils_is_specific_hostname()
The function detects whether the hostname is a specific hostname diferrent from default hostnames like localhost, localhost[6].localdomain[6].
-rw-r--r--src/NetworkManagerUtils.c16
-rw-r--r--src/NetworkManagerUtils.h4
2 files changed, 18 insertions, 2 deletions
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c
index 6b23d76dae..369ae2ca46 100644
--- a/src/NetworkManagerUtils.c
+++ b/src/NetworkManagerUtils.c
@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Copyright (C) 2004 - 2012 Red Hat, Inc.
+ * Copyright (C) 2004 - 2014 Red Hat, Inc.
* Copyright (C) 2005 - 2008 Novell, Inc.
*/
@@ -1574,3 +1574,17 @@ fail:
g_error ("FATAL: Failed asserting path component: %s", name ? name : "(null)");
}
+gboolean
+nm_utils_is_specific_hostname (const char *name)
+{
+ if (!name)
+ return FALSE;
+ if ( strcmp (name, "(none)")
+ && strcmp (name, "localhost")
+ && strcmp (name, "localhost6")
+ && strcmp (name, "localhost.localdomain")
+ && strcmp (name, "localhost6.localdomain6"))
+ return TRUE;
+ return FALSE;
+}
+
diff --git a/src/NetworkManagerUtils.h b/src/NetworkManagerUtils.h
index 06143673c6..719a51b726 100644
--- a/src/NetworkManagerUtils.h
+++ b/src/NetworkManagerUtils.h
@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Copyright (C) 2004 - 2011 Red Hat, Inc.
+ * Copyright (C) 2004 - 2014 Red Hat, Inc.
* Copyright (C) 2005 - 2008 Novell, Inc.
*/
@@ -134,4 +134,6 @@ gint32 nm_utils_get_monotonic_timestamp_s (void);
const char *ASSERT_VALID_PATH_COMPONENT (const char *name) G_GNUC_WARN_UNUSED_RESULT;
const char *nm_utils_ip6_property_path (const char *ifname, const char *property);
+gboolean nm_utils_is_specific_hostname (const char *name);
+
#endif /* NETWORK_MANAGER_UTILS_H */