]> git.ipfire.org Git - thirdparty/suricata-update.git/commitdiff
Check data directory's permission while updating sources 217/head
authorShivani Bhardwaj <shivanib134@gmail.com>
Mon, 7 Oct 2019 10:38:18 +0000 (16:08 +0530)
committerShivani Bhardwaj <shivanib134@gmail.com>
Sun, 22 Dec 2019 17:27:34 +0000 (22:57 +0530)
Closes redmine ticket #3219.

suricata/update/commands/updatesources.py

index a47c24c569ce1495f4c71211b9d98ca1578692c6..06a0d1172748179042add22ee0d03585253957af 100644 (file)
@@ -71,8 +71,12 @@ def compare_sources(initial_content, final_content):
 
 
 def write_and_compare(initial_content, fileobj):
-    with open(local_index_filename, "wb") as outobj:
-        outobj.write(fileobj.getvalue())
+    try:
+        with open(local_index_filename, "wb") as outobj:
+            outobj.write(fileobj.getvalue())
+    except IOError as ioe:
+        logger.error("Failed to open directory: %s", ioe)
+        return 1
     with open(local_index_filename, "rb") as stream:
         final_content = yaml.safe_load(stream)
     compare_sources(initial_content, final_content)