/[monit]/monit/files.c
ViewVC logotype

Diff of /monit/files.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14 by chopp, Sat Nov 2 10:47:22 2002 UTC revision 1.15 by hauk, Sun Nov 3 08:42:00 2002 UTC
# Line 177  int create_pidfile(char *pidfile) { Line 177  int create_pidfile(char *pidfile) {
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) {
# Line 227  time_t file_changedtime(char *file) { Line 229  time_t file_changedtime(char *file) {
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);
# Line 240  time_t file_changedtime(char *file) { Line 244  time_t file_changedtime(char *file) {
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    
# Line 262  int isreg_file(char *file) { Line 266  int isreg_file(char *file) {
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  }  }
# Line 276  int exist_file(char *file) { Line 282  int exist_file(char *file) {
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    
# Line 322  int check_ssl_files(void) { Line 299  int check_ssl_files(void) {
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;

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26