summaryrefslogtreecommitdiff
path: root/src/nm-dcb.c
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-07-31 14:02:22 -0500
committerDan Williams <dcbw@redhat.com>2014-09-11 12:11:56 -0500
commit544fc82aa722ef2a510969394c82fe88710162cd (patch)
treef5ae373b2926436a92c842613614bdd9627ae5cb /src/nm-dcb.c
parent053c8fa5df1b2df552d83d90ac75a3bfff3fa869 (diff)
downloadNetworkManager-544fc82aa722ef2a510969394c82fe88710162cd.tar.gz
core: consolidate helper progam searching (bgo #734131)
Instead of having basically the same code in a bunch of different place to find helper programs, just have one place do it. Yes, this does mean that the same sequence of paths is searched for all helpers (so for example, dnsmasq will no longer be found first in /usr/local) but I think consistency is the better option here. https://bugzilla.gnome.org/show_bug.cgi?id=734131
Diffstat (limited to 'src/nm-dcb.c')
-rw-r--r--src/nm-dcb.c39
1 files changed, 6 insertions, 33 deletions
diff --git a/src/nm-dcb.c b/src/nm-dcb.c
index 3bdbf7d5ed..3829e1a2e9 100644
--- a/src/nm-dcb.c
+++ b/src/nm-dcb.c
@@ -296,47 +296,20 @@ _fcoe_cleanup (const char *iface,
return do_helper (NULL, FCOEADM, run_func, user_data, error, "-d %s", iface);
}
-
-static const char *dcbpaths[] = {
- "/sbin/dcbtool",
- "/usr/sbin/dcbtool",
- "/usr/local/sbin/dcbtool",
- NULL
-};
-static const char *fcoepaths[] = {
- "/sbin/fcoeadm",
- "/usr/sbin/fcoeadm",
- "/usr/local/sbin/fcoeadm",
- NULL
-};
-
-
static gboolean
run_helper (char **argv, guint which, gpointer user_data, GError **error)
{
- static const char *helper_path[2] = { NULL, NULL };
+ const char *helper_path;
int exit_status = 0;
gboolean success;
char *errmsg = NULL, *outmsg = NULL;
- const char **iter;
char *cmdline;
- if (G_UNLIKELY (helper_path[which] == NULL)) {
- iter = (which == DCBTOOL) ? dcbpaths : fcoepaths;
- while (*iter) {
- if (g_file_test (*iter, G_FILE_TEST_EXISTS))
- helper_path[which] = *iter;
- iter++;
- }
- if (!helper_path[which]) {
- g_set_error (error, NM_DCB_ERROR, NM_DCB_ERROR_HELPER_NOT_FOUND,
- "%s not found",
- which == DCBTOOL ? "dcbtool" : "fcoadm");
- return FALSE;
- }
- }
+ helper_path = nm_utils_find_helper ((which == DCBTOOL) ? "dcbtool" : "fcoeadm", NULL, error);
+ if (!helper_path)
+ return FALSE;
- argv[0] = (char *) helper_path[which];
+ argv[0] = (char *) helper_path;
cmdline = g_strjoinv (" ", argv);
nm_log_dbg (LOGD_DCB, "%s", cmdline);
@@ -359,9 +332,9 @@ run_helper (char **argv, guint which, gpointer user_data, GError **error)
success = FALSE;
}
}
+
g_free (outmsg);
g_free (errmsg);
-
g_free (cmdline);
return success;
}