diff mcabber/src/histolog.c @ 362:d8f147d6e872

Check directory and config file permissions * Check history directory and configuration file permissions, and correct them to 0700 and 0600 if necessary. * Warn when mcabber main directory ($HOME/.mcabber) has bad permissions * Reset UseFileLogging & FileLoadLogs when the log dir does not exist
author Mikael Berthe <mikael@lilotux.net>
date Sun, 24 Jul 2005 14:37:27 +0100
parents e7e2f2fcc765
children 33b8e801ffa6
line wrap: on
line diff
--- a/mcabber/src/histolog.c	Sat Jul 23 21:50:06 2005 +0100
+++ b/mcabber/src/histolog.c	Sun Jul 24 14:37:27 2005 +0100
@@ -229,7 +229,7 @@
       int l = strlen(root_dir);
       if (l < 1) {
         scr_LogPrint("root_dir too short");
-        UseFileLogging = FALSE;
+        UseFileLogging = FileLoadLogs = FALSE;
         return;
       }
       // RootDir must be slash-terminated
@@ -247,11 +247,16 @@
       strcpy(RootDir, home);
       strcat(RootDir, dir);
     }
-    // FIXME
-    // We should check the directory actually exists
-  } else    // Disable history logging
-    if (RootDir) {
-    g_free(RootDir);
+    // Check directory permissions (should not be readable by group/others)
+    if (checkset_perm(RootDir, TRUE) == -1) {
+      // The directory does not actually exists
+      g_free(RootDir);
+      scr_LogPrint("ERROR: Can't access history log directory");
+      UseFileLogging = FileLoadLogs = FALSE;
+    }
+  } else {  // Disable history logging
+    if (RootDir)
+      g_free(RootDir);
   }
 }