diff options
Diffstat (limited to 'src/nm-dcb.c')
-rw-r--r-- | src/nm-dcb.c | 39 |
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; } |