comparison mcabber/src/settings.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 dea407d53fe6
children 33b8e801ffa6
comparison
equal deleted inserted replaced
361:51ff319947c3 362:d8f147d6e872
90 if ((fp = fopen(filename, "r")) == NULL) { 90 if ((fp = fopen(filename, "r")) == NULL) {
91 fprintf(stderr, "Cannot open config file!\n"); 91 fprintf(stderr, "Cannot open config file!\n");
92 return -1; 92 return -1;
93 } 93 }
94 } 94 }
95 // Check configuration file permissions
96 // As it could contain sensitive data, we make it user-readable only
97 checkset_perm(filename, TRUE);
98 // Check mcabber dir. There we just warn, we don't change the modes
99 sprintf(filename, "%s/.mcabber/", home);
100 checkset_perm(filename, FALSE);
95 g_free(filename); 101 g_free(filename);
96 } 102 } else {
97 else if ((fp = fopen(filename, "r")) == NULL) { 103 if ((fp = fopen(filename, "r")) == NULL) {
98 perror("fopen (cfg_file())"); 104 perror("fopen (cfg_file())");
99 return -1; 105 return -1;
106 }
107 // Check configuration file permissions (see above)
108 checkset_perm(filename, TRUE);
100 } 109 }
101 110
102 buf = g_new(char, 512); 111 buf = g_new(char, 512);
103 112
104 while (fgets(buf+1, 511, fp) != NULL) { 113 while (fgets(buf+1, 511, fp) != NULL) {