diff options
author | Dan Williams <dcbw@redhat.com> | 2014-06-03 15:58:23 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2014-06-06 13:43:47 -0500 |
commit | fd5761ecb279abc6ecdfb9a3ebcd4c872a96ac56 (patch) | |
tree | 9892d0dae6424ee32bc723f6726ffcbe7687e776 | |
parent | df601ad68c888aa86e37b51ae7e16fc6e7a1837b (diff) | |
download | NetworkManager-fd5761ecb279abc6ecdfb9a3ebcd4c872a96ac56.tar.gz |
dispatcher: don't use NULL error domains
glib doesn't like it, plus we don't use the error anyway, so just
return the constant error string.
-rw-r--r-- | callouts/nm-dispatcher.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/callouts/nm-dispatcher.c b/callouts/nm-dispatcher.c index 6c9c294f27..7d2b7365cc 100644 --- a/callouts/nm-dispatcher.c +++ b/callouts/nm-dispatcher.c @@ -320,33 +320,33 @@ script_timeout_cb (gpointer user_data) } static inline gboolean -check_permissions (struct stat *s, GError **error) +check_permissions (struct stat *s, const char **out_error_msg) { g_return_val_if_fail (s != NULL, FALSE); - g_return_val_if_fail (error != NULL, FALSE); - g_return_val_if_fail (*error == NULL, FALSE); + g_return_val_if_fail (out_error_msg != NULL, FALSE); + g_return_val_if_fail (*out_error_msg == NULL, FALSE); /* Only accept regular files */ if (!S_ISREG (s->st_mode)) { - g_set_error (error, 0, 0, "not a regular file."); + *out_error_msg = "not a regular file."; return FALSE; } /* Only accept files owned by root */ if (s->st_uid != 0) { - g_set_error (error, 0, 0, "not owned by root."); + *out_error_msg = "not owned by root."; return FALSE; } /* Only accept files not writable by group or other, and not SUID */ if (s->st_mode & (S_IWGRP | S_IWOTH | S_ISUID)) { - g_set_error (error, 0, 0, "writable by group or other, or set-UID."); + *out_error_msg = "writable by group or other, or set-UID."; return FALSE; } /* Only accept files executable by the owner */ if (!(s->st_mode & S_IXUSR)) { - g_set_error (error, 0, 0, "not executable by owner."); + *out_error_msg = "not executable by owner."; return FALSE; } @@ -442,6 +442,7 @@ find_scripts (const char *str_action) char *path; struct stat st; int err; + const char *err_msg = NULL; if (!check_filename (filename)) continue; @@ -451,10 +452,9 @@ find_scripts (const char *str_action) err = stat (path, &st); if (err) g_warning ("Failed to stat '%s': %d", path, err); - else if (!check_permissions (&st, &error)) { - g_warning ("Cannot execute '%s': %s", path, error->message); - g_clear_error (&error); - } else { + else if (!check_permissions (&st, &err_msg)) + g_warning ("Cannot execute '%s': %s", path, err_msg); + else { /* success */ sorted = g_slist_insert_sorted (sorted, path, (GCompareFunc) g_strcmp0); } |