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].
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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 */
|
||||
|
Reference in New Issue
Block a user