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 |
|
|
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 |
|
|
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 |
|
|
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 |
} |
} |
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 |
|
|
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 |
|
|
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) { |
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 |
*/ |
*/ |
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); |