2009-03-26 16:57:55 -04:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
|
|
|
|
/* NetworkManager system settings service
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
*
|
2012-03-07 14:05:47 +01:00
|
|
|
* (C) Copyright 2008 - 2012 Red Hat, Inc.
|
2009-03-26 16:57:55 -04:00
|
|
|
*/
|
|
|
|
|
|
2014-11-13 10:07:02 -05:00
|
|
|
#include "config.h"
|
|
|
|
|
|
2009-03-26 16:57:55 -04:00
|
|
|
#include <glib.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
2014-10-21 22:09:52 -04:00
|
|
|
|
|
|
|
|
#include "nm-core-internal.h"
|
2014-12-18 14:23:28 +01:00
|
|
|
#include "nm-utils-internal.h"
|
|
|
|
|
#include "NetworkManagerUtils.h"
|
2014-10-21 22:09:52 -04:00
|
|
|
|
2009-03-26 16:57:55 -04:00
|
|
|
#include "utils.h"
|
|
|
|
|
#include "shvar.h"
|
|
|
|
|
|
2012-03-07 14:05:47 +01:00
|
|
|
/*
|
|
|
|
|
* utils_single_quote_string
|
|
|
|
|
*
|
|
|
|
|
* Put string inside single quotes and remove CR, LF characters. If single quote
|
|
|
|
|
* is present, escape it with a backslash and prepend the whole string with $
|
|
|
|
|
* in order to have $'string'. That allows us to use single quote inside
|
|
|
|
|
* single quotes without breaking bash syntax. (man bash, section QUOTING).
|
|
|
|
|
*
|
|
|
|
|
* Caller is responsible for freeing the returned string.
|
|
|
|
|
*/
|
|
|
|
|
char *
|
|
|
|
|
utils_single_quote_string (const char *str)
|
|
|
|
|
{
|
2014-07-26 23:02:44 +02:00
|
|
|
static const char *drop_chars = "\r\n"; /* drop CR and LF */
|
2012-03-07 14:05:47 +01:00
|
|
|
static const char escape_char = '\\'; /* escape char is backslash */
|
|
|
|
|
static const char quote_char = '\''; /* quote char is single quote */
|
|
|
|
|
size_t i, slen, j = 0;
|
|
|
|
|
size_t drop = 0, extra = 0;
|
|
|
|
|
char *new_str;
|
|
|
|
|
|
|
|
|
|
slen = strlen (str);
|
|
|
|
|
for (i = 0; i < slen; i++) {
|
|
|
|
|
if (str[i] == quote_char)
|
|
|
|
|
extra++;
|
|
|
|
|
if (strchr (drop_chars, str[i]))
|
|
|
|
|
drop++;
|
|
|
|
|
}
|
|
|
|
|
new_str = g_malloc0 (slen + extra - drop + 4); /* 4 is for $''\0*/
|
|
|
|
|
|
|
|
|
|
if (extra > 0)
|
|
|
|
|
new_str[j++] = '$';
|
|
|
|
|
new_str[j++] = quote_char;
|
|
|
|
|
for (i = 0; i < slen; i++) {
|
|
|
|
|
if (strchr (drop_chars, str[i]))
|
|
|
|
|
continue;
|
|
|
|
|
if (str[i] == quote_char)
|
|
|
|
|
new_str[j++] = escape_char;
|
|
|
|
|
new_str[j++] = str[i];
|
|
|
|
|
}
|
|
|
|
|
new_str[j] = quote_char;
|
|
|
|
|
|
|
|
|
|
return new_str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* utils_single_unquote_string
|
|
|
|
|
*
|
|
|
|
|
* Remove string from single (or double) quotes, and remove escaping of '.
|
|
|
|
|
* Also remove first $ if the string is in the form of $'string'.
|
|
|
|
|
*
|
|
|
|
|
* Caller is responsible for freeing the returned string.
|
|
|
|
|
*/
|
|
|
|
|
char *
|
|
|
|
|
utils_single_unquote_string (const char *str)
|
|
|
|
|
{
|
|
|
|
|
static const char escape_char = '\\'; /* escape char is backslash */
|
|
|
|
|
static const char q_char = '\''; /* quote char is single quote */
|
|
|
|
|
static const char dq_char = '"'; /* double quote char */
|
|
|
|
|
size_t i, slen, j = 0, quote = 0, dollar = 0;
|
|
|
|
|
char *new_str;
|
|
|
|
|
|
|
|
|
|
slen = strlen (str);
|
|
|
|
|
new_str = g_malloc0 (slen + 1);
|
|
|
|
|
|
|
|
|
|
if ( (slen >= 2 && (str[0] == dq_char || str[0] == q_char) && str[0] == str[slen-1])
|
|
|
|
|
|| (slen >= 3 && str[0] == '$' && str[1] == q_char && str[1] == str[slen-1])) {
|
|
|
|
|
quote = 1;
|
|
|
|
|
if (str[0] == '$') dollar = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i = quote + dollar;
|
|
|
|
|
while (i < slen - quote) {
|
2012-06-22 13:04:18 +02:00
|
|
|
if (str[i] == escape_char && str[i+1] == q_char && i+1 < slen-quote)
|
2012-03-07 14:05:47 +01:00
|
|
|
i++;
|
|
|
|
|
new_str[j++] = str[i++];
|
|
|
|
|
}
|
|
|
|
|
new_str[j] = '\0';
|
|
|
|
|
|
|
|
|
|
return new_str;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-02 12:15:54 +01:00
|
|
|
/*
|
|
|
|
|
* Check ';[a-fA-F0-9]{8}' file suffix used for temporary files by rpm when
|
|
|
|
|
* installing packages.
|
|
|
|
|
*
|
|
|
|
|
* Implementation taken from upstart.
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
|
|
|
|
check_rpm_temp_suffix (const char *path)
|
|
|
|
|
{
|
|
|
|
|
const char *ptr;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (path != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
/* Matches *;[a-fA-F0-9]{8}; used by rpm */
|
|
|
|
|
ptr = strrchr (path, ';');
|
|
|
|
|
if (ptr && (strspn (ptr + 1, "abcdefABCDEF0123456789") == 8)
|
|
|
|
|
&& (! ptr[9]))
|
|
|
|
|
return TRUE;
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-30 16:30:41 -06:00
|
|
|
static gboolean
|
|
|
|
|
check_suffix (const char *base, const char *tag)
|
|
|
|
|
{
|
|
|
|
|
int len, tag_len;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (base != NULL, TRUE);
|
|
|
|
|
g_return_val_if_fail (tag != NULL, TRUE);
|
|
|
|
|
|
|
|
|
|
len = strlen (base);
|
|
|
|
|
tag_len = strlen (tag);
|
|
|
|
|
if ((len > tag_len) && !strcasecmp (base + len - tag_len, tag))
|
|
|
|
|
return TRUE;
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
utils_should_ignore_file (const char *filename, gboolean only_ifcfg)
|
|
|
|
|
{
|
|
|
|
|
char *base;
|
|
|
|
|
gboolean ignore = TRUE;
|
|
|
|
|
gboolean is_ifcfg = FALSE;
|
|
|
|
|
gboolean is_other = FALSE;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (filename != NULL, TRUE);
|
|
|
|
|
|
|
|
|
|
base = g_path_get_basename (filename);
|
|
|
|
|
g_return_val_if_fail (base != NULL, TRUE);
|
|
|
|
|
|
|
|
|
|
/* Only handle ifcfg, keys, and routes files */
|
|
|
|
|
if (!strncmp (base, IFCFG_TAG, strlen (IFCFG_TAG)))
|
|
|
|
|
is_ifcfg = TRUE;
|
|
|
|
|
|
|
|
|
|
if (only_ifcfg == FALSE) {
|
|
|
|
|
if ( !strncmp (base, KEYS_TAG, strlen (KEYS_TAG))
|
2010-01-05 19:05:01 -06:00
|
|
|
|| !strncmp (base, ROUTE_TAG, strlen (ROUTE_TAG))
|
|
|
|
|
|| !strncmp (base, ROUTE6_TAG, strlen (ROUTE6_TAG)))
|
2009-12-30 16:30:41 -06:00
|
|
|
is_other = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* But not those that have certain suffixes */
|
|
|
|
|
if ( (is_ifcfg || is_other)
|
|
|
|
|
&& !check_suffix (base, BAK_TAG)
|
|
|
|
|
&& !check_suffix (base, TILDE_TAG)
|
|
|
|
|
&& !check_suffix (base, ORIG_TAG)
|
|
|
|
|
&& !check_suffix (base, REJ_TAG)
|
2010-08-09 12:05:57 -05:00
|
|
|
&& !check_suffix (base, RPMNEW_TAG)
|
|
|
|
|
&& !check_suffix (base, AUGNEW_TAG)
|
2010-11-02 12:15:54 +01:00
|
|
|
&& !check_suffix (base, AUGTMP_TAG)
|
|
|
|
|
&& !check_rpm_temp_suffix (base))
|
2009-12-30 16:30:41 -06:00
|
|
|
ignore = FALSE;
|
|
|
|
|
|
|
|
|
|
g_free (base);
|
|
|
|
|
return ignore;
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-26 16:57:55 -04:00
|
|
|
char *
|
2009-03-31 07:29:31 -04:00
|
|
|
utils_cert_path (const char *parent, const char *suffix)
|
2009-03-26 16:57:55 -04:00
|
|
|
{
|
2009-12-30 16:30:41 -06:00
|
|
|
const char *name;
|
|
|
|
|
char *dir, *path;
|
2009-03-26 16:57:55 -04:00
|
|
|
|
2009-12-30 16:30:41 -06:00
|
|
|
g_return_val_if_fail (parent != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (suffix != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
name = utils_get_ifcfg_name (parent, FALSE);
|
2009-03-26 16:57:55 -04:00
|
|
|
dir = g_path_get_dirname (parent);
|
2009-03-31 07:29:31 -04:00
|
|
|
path = g_strdup_printf ("%s/%s-%s", dir, name, suffix);
|
2009-03-26 16:57:55 -04:00
|
|
|
g_free (dir);
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-30 16:30:41 -06:00
|
|
|
const char *
|
|
|
|
|
utils_get_ifcfg_name (const char *file, gboolean only_ifcfg)
|
2009-03-26 16:57:55 -04:00
|
|
|
{
|
2014-12-18 14:23:28 +01:00
|
|
|
const char *name;
|
2009-03-26 16:57:55 -04:00
|
|
|
|
2009-12-30 16:30:41 -06:00
|
|
|
g_return_val_if_fail (file != NULL, NULL);
|
|
|
|
|
|
2014-12-18 14:23:28 +01:00
|
|
|
name = strrchr (file, '/');
|
|
|
|
|
if (!name)
|
|
|
|
|
name = file;
|
|
|
|
|
else
|
|
|
|
|
name++;
|
|
|
|
|
if (!*name)
|
2009-03-26 16:57:55 -04:00
|
|
|
return NULL;
|
|
|
|
|
|
2014-12-18 14:23:28 +01:00
|
|
|
#define MATCH_TAG_AND_RETURN(name, TAG) \
|
|
|
|
|
G_STMT_START { \
|
|
|
|
|
if (strncmp (name, TAG, STRLEN (TAG)) == 0) { \
|
|
|
|
|
name += STRLEN (TAG); \
|
|
|
|
|
if (name[0] == '\0') \
|
|
|
|
|
return NULL; \
|
|
|
|
|
else \
|
|
|
|
|
return name; \
|
|
|
|
|
} \
|
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
|
|
MATCH_TAG_AND_RETURN (name, IFCFG_TAG);
|
|
|
|
|
if (!only_ifcfg) {
|
|
|
|
|
MATCH_TAG_AND_RETURN (name, KEYS_TAG);
|
|
|
|
|
MATCH_TAG_AND_RETURN (name, ROUTE_TAG);
|
|
|
|
|
MATCH_TAG_AND_RETURN (name, ROUTE6_TAG);
|
2009-12-30 16:30:41 -06:00
|
|
|
}
|
|
|
|
|
|
2014-12-18 14:23:28 +01:00
|
|
|
return NULL;
|
2009-03-26 16:57:55 -04:00
|
|
|
}
|
|
|
|
|
|
2009-12-30 16:30:41 -06:00
|
|
|
/* Used to get any ifcfg/extra file path from any other ifcfg/extra path
|
|
|
|
|
* in the form <tag><name>.
|
2009-12-07 14:23:26 -08:00
|
|
|
*/
|
2009-12-30 16:30:41 -06:00
|
|
|
static char *
|
2009-12-07 14:23:26 -08:00
|
|
|
utils_get_extra_path (const char *parent, const char *tag)
|
2009-03-26 16:57:55 -04:00
|
|
|
{
|
2009-12-30 16:30:41 -06:00
|
|
|
char *item_path = NULL, *dirname;
|
|
|
|
|
const char *name;
|
2009-03-26 16:57:55 -04:00
|
|
|
|
2009-12-30 16:30:41 -06:00
|
|
|
g_return_val_if_fail (parent != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (tag != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
dirname = g_path_get_dirname (parent);
|
|
|
|
|
if (!dirname)
|
2009-03-26 16:57:55 -04:00
|
|
|
return NULL;
|
|
|
|
|
|
2009-12-30 16:30:41 -06:00
|
|
|
name = utils_get_ifcfg_name (parent, FALSE);
|
|
|
|
|
if (name) {
|
|
|
|
|
if (!strcmp (dirname, "."))
|
|
|
|
|
item_path = g_strdup_printf ("%s%s", tag, name);
|
|
|
|
|
else
|
|
|
|
|
item_path = g_strdup_printf ("%s/%s%s", dirname, tag, name);
|
|
|
|
|
}
|
|
|
|
|
g_free (dirname);
|
2009-03-26 16:57:55 -04:00
|
|
|
|
2009-12-30 16:30:41 -06:00
|
|
|
return item_path;
|
|
|
|
|
}
|
2009-03-26 16:57:55 -04:00
|
|
|
|
2009-12-30 16:30:41 -06:00
|
|
|
char *
|
|
|
|
|
utils_get_ifcfg_path (const char *parent)
|
|
|
|
|
{
|
|
|
|
|
return utils_get_extra_path (parent, IFCFG_TAG);
|
2009-12-07 14:23:26 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
utils_get_keys_path (const char *parent)
|
|
|
|
|
{
|
|
|
|
|
return utils_get_extra_path (parent, KEYS_TAG);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
utils_get_route_path (const char *parent)
|
|
|
|
|
{
|
|
|
|
|
return utils_get_extra_path (parent, ROUTE_TAG);
|
2009-03-26 16:57:55 -04:00
|
|
|
}
|
|
|
|
|
|
2010-01-05 19:05:01 -06:00
|
|
|
char *
|
|
|
|
|
utils_get_route6_path (const char *parent)
|
|
|
|
|
{
|
|
|
|
|
return utils_get_extra_path (parent, ROUTE6_TAG);
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-26 16:57:55 -04:00
|
|
|
shvarFile *
|
2009-12-07 14:23:26 -08:00
|
|
|
utils_get_extra_ifcfg (const char *parent, const char *tag, gboolean should_create)
|
2009-03-26 16:57:55 -04:00
|
|
|
{
|
|
|
|
|
shvarFile *ifcfg = NULL;
|
|
|
|
|
char *path;
|
|
|
|
|
|
2009-12-07 14:23:26 -08:00
|
|
|
path = utils_get_extra_path (parent, tag);
|
2009-03-26 16:57:55 -04:00
|
|
|
if (!path)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if (should_create && !g_file_test (path, G_FILE_TEST_EXISTS))
|
|
|
|
|
ifcfg = svCreateFile (path);
|
|
|
|
|
|
|
|
|
|
if (!ifcfg)
|
2014-03-18 13:13:12 -04:00
|
|
|
ifcfg = svOpenFile (path, NULL);
|
2009-03-26 16:57:55 -04:00
|
|
|
|
|
|
|
|
g_free (path);
|
|
|
|
|
return ifcfg;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-07 14:23:26 -08:00
|
|
|
shvarFile *
|
|
|
|
|
utils_get_keys_ifcfg (const char *parent, gboolean should_create)
|
|
|
|
|
{
|
|
|
|
|
return utils_get_extra_ifcfg (parent, KEYS_TAG, should_create);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shvarFile *
|
|
|
|
|
utils_get_route_ifcfg (const char *parent, gboolean should_create)
|
|
|
|
|
{
|
|
|
|
|
return utils_get_extra_ifcfg (parent, ROUTE_TAG, should_create);
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-05 19:05:01 -06:00
|
|
|
shvarFile *
|
|
|
|
|
utils_get_route6_ifcfg (const char *parent, gboolean should_create)
|
|
|
|
|
{
|
|
|
|
|
return utils_get_extra_ifcfg (parent, ROUTE6_TAG, should_create);
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-07 14:23:26 -08:00
|
|
|
/* Finds out if route file has new or older format
|
|
|
|
|
* Returns TRUE - new syntax (ADDRESS<n>=a.b.c.d ...), error opening file or empty
|
2010-01-05 19:05:01 -06:00
|
|
|
* FALSE - older syntax, i.e. argument to 'ip route add' (1.2.3.0/24 via 11.22.33.44)
|
2009-12-07 14:23:26 -08:00
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
utils_has_route_file_new_syntax (const char *filename)
|
|
|
|
|
{
|
|
|
|
|
char *contents = NULL;
|
|
|
|
|
gsize len = 0;
|
|
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
const char *pattern = "^[[:space:]]*ADDRESS[0-9]+=";
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (filename != NULL, TRUE);
|
|
|
|
|
|
|
|
|
|
if (!g_file_get_contents (filename, &contents, &len, NULL))
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
if (len <= 0) {
|
|
|
|
|
ret = TRUE;
|
|
|
|
|
goto gone;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (g_regex_match_simple (pattern, contents, G_REGEX_MULTILINE, 0))
|
|
|
|
|
ret = TRUE;
|
|
|
|
|
|
|
|
|
|
gone:
|
|
|
|
|
g_free (contents);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-05 13:18:24 -05:00
|
|
|
gboolean
|
2012-07-23 10:39:05 -04:00
|
|
|
utils_ignore_ip_config (NMConnection *connection)
|
2012-03-05 13:18:24 -05:00
|
|
|
{
|
|
|
|
|
NMSettingConnection *s_con;
|
|
|
|
|
|
|
|
|
|
s_con = nm_connection_get_setting_connection (connection);
|
|
|
|
|
g_assert (s_con);
|
|
|
|
|
|
2012-07-23 10:39:05 -04:00
|
|
|
/* bonding slaves have no IP configuration, and the system
|
|
|
|
|
* scripts just ignore it if it's there.
|
|
|
|
|
*/
|
2012-05-23 16:19:28 +02:00
|
|
|
if ( nm_setting_connection_is_slave_type (s_con, NM_SETTING_BOND_SETTING_NAME)
|
2014-04-10 16:13:18 -04:00
|
|
|
|| nm_setting_connection_is_slave_type (s_con, NM_SETTING_BRIDGE_SETTING_NAME)
|
|
|
|
|
|| nm_setting_connection_is_slave_type (s_con, NM_SETTING_TEAM_SETTING_NAME))
|
2012-03-05 13:18:24 -05:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2014-02-19 16:10:36 -05:00
|
|
|
|
|
|
|
|
/* Find out if the 'alias' file name might be an alias file for 'ifcfg' file name,
|
|
|
|
|
* or any alias when 'ifcfg' is NULL. Does not check that it's actually a valid
|
|
|
|
|
* alias name; that happens in reader.c
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
utils_is_ifcfg_alias_file (const char *alias, const char *ifcfg)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (alias != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
if (strncmp (alias, IFCFG_TAG, strlen (IFCFG_TAG)))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (ifcfg) {
|
|
|
|
|
size_t len = strlen (ifcfg);
|
|
|
|
|
|
|
|
|
|
return (strncmp (alias, ifcfg, len) == 0 && alias[len] == ':');
|
|
|
|
|
} else {
|
|
|
|
|
return (strchr (alias, ':') != NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
utils_get_ifcfg_from_alias (const char *alias)
|
|
|
|
|
{
|
|
|
|
|
char *base, *ptr, *ifcfg = NULL;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (alias != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
base = g_path_get_basename (alias);
|
|
|
|
|
g_return_val_if_fail (base != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
if (utils_is_ifcfg_alias_file (base, NULL)) {
|
|
|
|
|
ifcfg = g_strdup (alias);
|
|
|
|
|
ptr = strrchr (ifcfg, ':');
|
|
|
|
|
if (ptr)
|
|
|
|
|
*ptr = '\0';
|
|
|
|
|
else {
|
|
|
|
|
g_free (ifcfg);
|
|
|
|
|
ifcfg = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_free (base);
|
|
|
|
|
return ifcfg;
|
|
|
|
|
}
|