177 |
|
|
178 |
FILE *F= NULL; |
FILE *F= NULL; |
179 |
|
|
180 |
|
ASSERT(pidfile); |
181 |
|
|
182 |
umask(PIDMASK); |
umask(PIDMASK); |
183 |
|
|
184 |
if ((F= fopen(pidfile,"w")) == (FILE *)NULL) { |
if ((F= fopen(pidfile,"w")) == (FILE *)NULL) { |
229 |
|
|
230 |
struct stat buf; |
struct stat buf; |
231 |
|
|
232 |
|
ASSERT(file); |
233 |
|
|
234 |
if(!stat(file, &buf)) |
if(!stat(file, &buf)) |
235 |
if(S_ISREG(buf.st_mode)) |
if(S_ISREG(buf.st_mode)) |
236 |
return MAXIMUM(buf.st_mtime, buf.st_ctime); |
return MAXIMUM(buf.st_mtime, buf.st_ctime); |
244 |
* Secure check the monitrc file. The run control file must have the |
* Secure check the monitrc file. The run control file must have the |
245 |
* same uid as the REAL uid of this process, it must have permissions |
* same uid as the REAL uid of this process, it must have permissions |
246 |
* no greater than 700 and it must not be a symbolic link. We check |
* no greater than 700 and it must not be a symbolic link. We check |
247 |
* these conditions here. (Inspired by code from fetchmail) |
* these conditions here. |
248 |
* @param rcfile The monitrc file |
* @param rcfile The monitrc file |
249 |
* @return TRUE if the test passed otherwise FALSE |
* @return TRUE if the test passed otherwise FALSE |
250 |
*/ |
*/ |
251 |
int check_rcfile(char *rcfile) { |
int check_rcfile(char *rcfile) { |
252 |
|
|
253 |
return check_file(rcfile, |
ASSERT(rcfile); |
254 |
"control file", |
|
255 |
S_IRUSR | S_IWUSR | S_IXUSR); |
return check_file(rcfile, "control file", S_IRUSR | S_IWUSR | S_IXUSR); |
256 |
|
|
257 |
} |
} |
258 |
|
|
266 |
|
|
267 |
struct stat buf; |
struct stat buf; |
268 |
|
|
269 |
|
ASSERT(file); |
270 |
|
|
271 |
return (stat(file, &buf) == 0 && S_ISREG(buf.st_mode)); |
return (stat(file, &buf) == 0 && S_ISREG(buf.st_mode)); |
272 |
|
|
273 |
} |
} |
282 |
|
|
283 |
struct stat buf; |
struct stat buf; |
284 |
|
|
285 |
return (stat(file, &buf) == 0); |
ASSERT(file); |
|
|
|
|
} |
|
|
|
|
286 |
|
|
287 |
/** |
return (stat(file, &buf) == 0); |
|
* Check all files of the ssl related files if they match |
|
|
* the security policy of monit |
|
|
* @file A path to the file to check |
|
|
* @return TRUE if file exist otherwise FALSE |
|
|
*/ |
|
|
int check_ssl_files(void) { |
|
|
|
|
|
int return_value= TRUE; |
|
|
|
|
|
if(Run.httpdssl==TRUE) { |
|
|
|
|
|
return_value&= check_file(Run.httpsslpem, |
|
|
"SSL server PEM file", |
|
|
S_IRWXU ); |
|
|
|
|
|
} |
|
|
|
|
|
if(Run.httpdssl==TRUE) { |
|
|
|
|
|
return_value&= check_file(Run.httpsslclientpem, |
|
|
"SSL client PEM file", |
|
|
S_IRWXU | S_IRGRP | S_IROTH); |
|
|
|
|
|
} |
|
|
|
|
|
return return_value; |
|
288 |
|
|
289 |
} |
} |
290 |
|
|
299 |
* @param permmask The permission mask for the file |
* @param permmask The permission mask for the file |
300 |
* @return TRUE if the test passed otherwise FALSE |
* @return TRUE if the test passed otherwise FALSE |
301 |
*/ |
*/ |
302 |
int check_file(char *filename, char *description, |
int check_file(char *filename, char *description, int permmask) { |
|
int permmask) { |
|
303 |
|
|
304 |
struct stat buf; |
struct stat buf; |
305 |
errno= 0; |
errno= 0; |