[tracker-miners/sam/no-device-nodes] miners/fs: Don't index special files like device nodes and pipes



commit 320e4f0d749e0d2e455339de80fe80e84a8e0a98
Author: Sam Thursfield <sam afuera me uk>
Date:   Mon Mar 23 00:51:19 2020 +0100

    miners/fs: Don't index special files like device nodes and pipes
    
    Otherwise, it's possible to run "tracker index --file /dev" and do all
    kinds of ill-advised IO.

 src/miners/fs/tracker-miner-files.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
---
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index 36829354b..1408fab0d 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -2443,6 +2443,7 @@ process_file_cb (GObject      *object,
        gchar *uri, *sparql_str, *sparql_update_str, *time_str;
        GError *error = NULL;
        gboolean is_iri;
+       gboolean is_special;
        gboolean is_directory;
 
        data = user_data;
@@ -2458,6 +2459,18 @@ process_file_cb (GObject      *object,
                return;
        }
 
+       is_special = (g_file_info_get_file_type (file_info) == G_FILE_TYPE_SPECIAL ?
+                       TRUE : FALSE);
+       if (is_special) {
+               error = g_error_new (TRACKER_MINER_ERROR,
+                                    0,
+                                    "File is a device, socket or pipe. Refusing to index it.");
+               tracker_miner_fs_notify_finish (TRACKER_MINER_FS (data->miner), data->task, NULL, error);
+               priv->extraction_queue = g_list_remove (priv->extraction_queue, data);
+               process_file_data_free (data);
+               return;
+       }
+
        uri = g_file_get_uri (file);
        mime_type = g_file_info_get_content_type (file_info);
        urn = miner_files_get_file_urn (TRACKER_MINER_FILES (data->miner), file, &is_iri);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]