Skip to content

Commit

Permalink
client: require directory in --ifconfig compat:/dir (bnc#881544)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtomaschewski committed Jun 5, 2014
1 parent f766062 commit 1a9b4e3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 35 deletions.
32 changes: 12 additions & 20 deletions client/redhat/compat-redhat.c
Expand Up @@ -60,15 +60,15 @@ __ni_redhat_get_interfaces(const char *root, const char *path, ni_compat_netdev_
ni_string_array_t files = NI_STRING_ARRAY_INIT;
ni_bool_t success = FALSE;
char *pathname = NULL;
const char *_path = _PATH_NETCONFIG_DIR;

if (ni_string_empty(path))
path = _PATH_NETCONFIG_DIR;
if (!ni_string_empty(path))
_path = path;

if (ni_string_empty(root))
ni_string_dup(&pathname, path);
ni_string_dup(&pathname, _path);
else
ni_string_printf(&pathname, "%s%s", root, path);

ni_string_printf(&pathname, "%s%s", root, _path);

if (ni_isdir(pathname)) {
unsigned int i;
Expand All @@ -93,24 +93,16 @@ __ni_redhat_get_interfaces(const char *root, const char *path, ni_compat_netdev_
}
} else
if (ni_file_exists(pathname)) {
ni_compat_netdev_t *compat;
const char *filename = ni_basename(pathname);
const char *ifname = filename + sizeof("ifcfg-")-1;

if (strncmp("ifcfg-", filename, sizeof("ifcfg-")-1)) {
ni_error("File does not have ifcfg-prefix: %s", pathname);
goto done;
}

if (!(compat = __ni_redhat_read_interface(pathname, ifname, result)))
goto done;

ni_compat_netdev_client_info_set(compat->dev, pathname);
} else {
ni_error("File or directory does not exist: %s", pathname);
ni_error("Cannot use '%s' to read redhat ifcfg files -- not a directory",
pathname);
goto done;
} else
if (!ni_string_empty(path)) {
ni_error("Configuration directory '%s' does not exist", pathname);
goto done;
}


success = TRUE;
done:
ni_string_free(&pathname);
Expand Down
22 changes: 11 additions & 11 deletions client/suse/compat-suse.c
Expand Up @@ -220,22 +220,17 @@ __ni_suse_get_ifconfig(const char *root, const char *path, ni_compat_ifconfig_t
ni_string_array_t files = NI_STRING_ARRAY_INIT;
ni_bool_t success = FALSE;
char *pathname = NULL;
const char *base;
const char *_path = __NI_SUSE_SYSCONFIG_NETWORK_DIR;
unsigned int i;

if (ni_string_empty(path))
path = __NI_SUSE_SYSCONFIG_NETWORK_DIR;
if (!ni_string_empty(path))
_path = path;

if (ni_string_empty(root))
ni_string_dup(&pathname, path);
ni_string_dup(&pathname, _path);
else
ni_string_printf(&pathname, "%s%s", root, path);
ni_string_printf(&pathname, "%s%s", root, _path);

if (ni_isreg(pathname)) {
if ((base = ni_dirname(pathname)))
ni_string_dup(&pathname, base);
path = ni_dirname(pathname);
}
if (ni_isdir(pathname)) {
if (!__ni_suse_read_globals(root, pathname))
goto done;
Expand Down Expand Up @@ -273,7 +268,12 @@ __ni_suse_get_ifconfig(const char *root, const char *path, ni_compat_ifconfig_t
}
} else
if (ni_file_exists(pathname)) {
ni_error("Cannot use '%s' to read suse ifcfg files", pathname);
ni_error("Cannot use '%s' to read suse ifcfg files -- not a directory",
pathname);
goto done;
} else
if (!ni_string_empty(path)) {
ni_error("Configuration directory '%s' does not exist", pathname);
goto done;
}

Expand Down
6 changes: 2 additions & 4 deletions man/wicked.8.in
Expand Up @@ -187,10 +187,8 @@ If the file name starts with the string \fBcompat:\fP, \fBwicked\fP is
instructed to load the interface configuration from files in the
old-style "ifcfg" syntax, as described by the \fBifcfg\fP(5) manual page.
The string following the \fBcompat:\fP prefix is interpreted as a
path name. If this path name refers to a directory,
\fBwicked\fP will scan it for files with names matching \fBifcfg-*\fP.
If the path name refers to a regular file, it will parse this file, assuming
it is an ifcfg file.
directory name where \fBwicked\fP will scan for files with names matching
\fBifcfg-*\fP and related files, like \fBroutes\fP and \fBifroute-*\fP.
.IP
The special name \fBfirmware:\fP can be used to obtain the interface
definition(s) from firmware services like iBFT.
Expand Down

0 comments on commit 1a9b4e3

Please sign in to comment.