comparison 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
comparison
equal deleted inserted replaced
361:51ff319947c3 362:d8f147d6e872
227 if (enable || loadfiles) { 227 if (enable || loadfiles) {
228 if (root_dir) { 228 if (root_dir) {
229 int l = strlen(root_dir); 229 int l = strlen(root_dir);
230 if (l < 1) { 230 if (l < 1) {
231 scr_LogPrint("root_dir too short"); 231 scr_LogPrint("root_dir too short");
232 UseFileLogging = FALSE; 232 UseFileLogging = FileLoadLogs = FALSE;
233 return; 233 return;
234 } 234 }
235 // RootDir must be slash-terminated 235 // RootDir must be slash-terminated
236 if (root_dir[l-1] == '/') 236 if (root_dir[l-1] == '/')
237 RootDir = g_strdup(root_dir); 237 RootDir = g_strdup(root_dir);
245 char *dir = "/.mcabber/histo/"; 245 char *dir = "/.mcabber/histo/";
246 RootDir = g_new(char, strlen(home) + strlen(dir) + 1); 246 RootDir = g_new(char, strlen(home) + strlen(dir) + 1);
247 strcpy(RootDir, home); 247 strcpy(RootDir, home);
248 strcat(RootDir, dir); 248 strcat(RootDir, dir);
249 } 249 }
250 // FIXME 250 // Check directory permissions (should not be readable by group/others)
251 // We should check the directory actually exists 251 if (checkset_perm(RootDir, TRUE) == -1) {
252 } else // Disable history logging 252 // The directory does not actually exists
253 if (RootDir) { 253 g_free(RootDir);
254 g_free(RootDir); 254 scr_LogPrint("ERROR: Can't access history log directory");
255 UseFileLogging = FileLoadLogs = FALSE;
256 }
257 } else { // Disable history logging
258 if (RootDir)
259 g_free(RootDir);
255 } 260 }
256 } 261 }
257 262
258 inline void hlog_write_message(const char *jid, time_t timestamp, int sent, 263 inline void hlog_write_message(const char *jid, time_t timestamp, int sent,
259 const char *msg) 264 const char *msg)