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

Diff of /monit/validate.c

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

revision 1.82 by martinp, Wed Aug 27 21:53:13 2003 UTC revision 1.83 by hauk, Sun Aug 31 20:05:51 2003 UTC
# Line 100  static int  check_file(Service_T); Line 100  static int  check_file(Service_T);
100    
101  static int  check_directory(Service_T);  static int  check_directory(Service_T);
102    
103    static int  check_remote_host(Service_T);
104    
105  static int  check_timestamps(Service_T);  static int  check_timestamps(Service_T);
106  static int  check_timestamp_item(Service_T, Timestamp_T, char *);  static int  check_timestamp_item(Service_T, Timestamp_T, char *);
107    
# Line 174  static void do_validate(Service_T s, Pro Line 176  static void do_validate(Service_T s, Pro
176    sigset_t ns,os;    sigset_t ns,os;
177    
178    ASSERT(s);    ASSERT(s);
   ASSERT(s->path);  
179        
180    set_signal_block(&ns, &os);    set_signal_block(&ns, &os);
181    
# Line 206  static void do_validate(Service_T s, Pro Line 207  static void do_validate(Service_T s, Pro
207            goto reinstall;            goto reinstall;
208        break;        break;
209                
210      case TYPE_REMOTE:
211          if (! check_remote_host(s))
212              goto reinstall;
213          break;
214          
215    default:    default:
216        break;        break;
217                
# Line 315  static int check_directory(Service_T s) Line 321  static int check_directory(Service_T s)
321    char report[STRLEN]= {0};    char report[STRLEN]= {0};
322    
323    if(stat(s->path, &stat_buf) != 0) {    if(stat(s->path, &stat_buf) != 0) {
324      Event_post(s, EVENT_RESTART,      Event_post(s, EVENT_START,
325                 "Event: directory '%s' doesn't exist\n", s->name);                 "Event: directory '%s' doesn't exist\n", s->name);
326      return FALSE;      return FALSE;
327    }    }
328    
329    if(!S_ISDIR(stat_buf.st_mode)) {    if(!S_ISDIR(stat_buf.st_mode)) {
330      Event_post(s, EVENT_RESTART,      Event_post(s, EVENT_STOP,
331                 "Event: '%s' is not directory\n", s->name);                 "Event: '%s' is not directory\n", s->name);
332      return FALSE;      return FALSE;
333    }    }
# Line 361  static int check_file(Service_T s) { Line 367  static int check_file(Service_T s) {
367    char report[STRLEN]= {0};    char report[STRLEN]= {0};
368    
369    if(stat(s->path, &stat_buf) != 0) {    if(stat(s->path, &stat_buf) != 0) {
370      Event_post(s, EVENT_RESTART, "Event: file '%s' doesn't exist\n", s->name);      Event_post(s, EVENT_START, "Event: file '%s' doesn't exist\n", s->name);
371      return FALSE;      return FALSE;
372    }    }
373        
374    if(!S_ISREG(stat_buf.st_mode)) {    if(!S_ISREG(stat_buf.st_mode)) {
375      Event_post(s, EVENT_RESTART, "Event: '%s' is not regular file\n", s->name);      Event_post(s, EVENT_STOP, "Event: '%s' is not regular file\n", s->name);
376      return FALSE;      return FALSE;
377    }    }
378        
# Line 423  static int check_device(Service_T s) { Line 429  static int check_device(Service_T s) {
429    char report[STRLEN]= {0};    char report[STRLEN]= {0};
430    
431    if(stat(s->path, &stat_buf) != 0) {    if(stat(s->path, &stat_buf) != 0) {
432      Event_post(s, EVENT_RESTART, "Event: device '%s' doesn't exist\n", s->name);      Event_post(s, EVENT_START, "Event: device '%s' doesn't exist\n", s->name);
433      return FALSE;      return FALSE;
434    }    }
435        
# Line 449  static int check_device(Service_T s) { Line 455  static int check_device(Service_T s) {
455    /* Test devices */    /* Test devices */
456    if(s->devicelist) {    if(s->devicelist) {
457      if(!DeviceInfo_Usage(s->devinfo, s->path)) {      if(!DeviceInfo_Usage(s->devinfo, s->path)) {
458        Event_post(s, EVENT_RESTART, "Event: unable to read device state\n");        Event_post(s, EVENT_STOP, "Event: unable to read device state\n");
459        return FALSE;        return FALSE;
460      }      }
461      for(td= s->devicelist; td; td= td->next) {      for(td= s->devicelist; td; td= td->next) {
# Line 468  static int check_device(Service_T s) { Line 474  static int check_device(Service_T s) {
474    
475    
476  /**  /**
477     * Validate a remote service.
478     * @param s The remote service to validate
479     * @return FALSE if there was an error otherwise TRUE
480     */
481    static int check_remote_host(Service_T s) {
482    
483      Port_T pp;
484      char report[STRLEN]={0};
485    
486      /* Test each host:port and protocol in the service's portlist */
487      for(pp= s->portlist; pp; pp= pp->next) {
488        if(!check_process_connection(s, pp, report)) {
489          pp->is_available= FALSE;
490          pp->event_flag= TRUE; /* Turn on the object's event_flag to
491                                 * indicate that the port event
492                                 * occured on this particular
493                                 * object */
494          if(! eval_actions(pp->action, s, report, "connection",
495                            EVENT_CONNECTION)) {
496            return FALSE;
497          }
498        } else {
499          pp->is_available= TRUE;
500        }
501      }
502    
503      return TRUE;
504      
505    }
506    
507    
508    /**
509   * Validate a given process service s.  Events are posted according to   * Validate a given process service s.  Events are posted according to
510   * its configuration.  In case of a fatal event FALSE is returned.   * its configuration.  In case of a fatal event FALSE is returned.
511   */   */
# Line 884  static int check_perm(Service_T s, mode_ Line 922  static int check_perm(Service_T s, mode_
922    if(!s->perm)    if(!s->perm)
923      return FALSE;      return FALSE;
924    
925    if( (mode & 07777) != s->perm->perm ) {    if((mode & 07777) != s->perm->perm) {
926      snprintf(report, STRLEN,      snprintf(report, STRLEN,
927               "permission test failed for %s -- current permission is %o",               "permission test failed for %s -- current permission is %o",
928               s->path, mode&07777);               s->path, mode&07777);

Legend:
Removed from v.1.82  
changed lines
  Added in v.1.83

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