core: print warning message when skipping invalid device plugin file

https://mail.gnome.org/archives/networkmanager-list/2014-August/msg00042.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Thomas Haller
2014-08-20 18:59:01 +02:00
parent 6a19e68a7d
commit b59a82d82e

View File

@@ -1974,6 +1974,7 @@ read_device_factory_paths ()
paths = g_array_new (FALSE, FALSE, sizeof (struct read_device_factory_paths_data)); paths = g_array_new (FALSE, FALSE, sizeof (struct read_device_factory_paths_data));
while ((item = g_dir_read_name (dir))) { while ((item = g_dir_read_name (dir))) {
int errsv;
struct read_device_factory_paths_data data; struct read_device_factory_paths_data data;
if (!g_str_has_prefix (item, PLUGIN_PREFIX)) if (!g_str_has_prefix (item, PLUGIN_PREFIX))
@@ -1983,21 +1984,25 @@ read_device_factory_paths ()
data.path = g_build_filename (NMPLUGINDIR, item, NULL); data.path = g_build_filename (NMPLUGINDIR, item, NULL);
if (stat (data.path, &data.st) != 0) if (stat (data.path, &data.st) != 0) {
goto continue_with_error; errsv = errno;
nm_log_warn (LOGD_HW, "device plugin: skip invalid file %s (error during stat: %s)", data.path, strerror (errsv));
goto NEXT;
}
if (!S_ISREG (data.st.st_mode)) if (!S_ISREG (data.st.st_mode))
goto continue_silently; goto NEXT;
if (data.st.st_uid != 0) if (data.st.st_uid != 0) {
goto continue_with_error; nm_log_warn (LOGD_HW, "device plugin: skip invalid file %s (file must be owned by root)", data.path);
if (data.st.st_mode & (S_IWGRP | S_IWOTH | S_ISUID)) goto NEXT;
goto continue_with_error; }
if (data.st.st_mode & (S_IWGRP | S_IWOTH | S_ISUID)) {
nm_log_warn (LOGD_HW, "device plugin: skip invalid file %s (invalid file permissions)", data.path);
goto NEXT;
}
g_array_append_val (paths, data); g_array_append_val (paths, data);
continue; continue;
NEXT:
continue_with_error:
nm_log_dbg (LOGD_HW, "device plugin: skip invalid file %s", data.path);
continue_silently:
g_free (data.path); g_free (data.path);
} }
g_dir_close (dir); g_dir_close (dir);