@ -51,6 +51,8 @@
pthread_t ddd_pid = 0 ;
pthread_t scque_pid = 0 ;
static int startup_checks ( struct onas_context * ctx ) ;
int main ( int argc , char * * argv )
{
const struct optstruct * opts ;
@ -73,9 +75,34 @@ int main(int argc, char **argv)
}
ctx - > opts = opts ;
if ( optget ( opts , " help " ) - > enabled ) {
help ( ) ;
ret = 2 ;
clamdopts = optparse ( optget ( opts , " config-file " ) - > strarg , 0 , NULL , 1 , OPT_CLAMD , 0 , NULL ) ;
if ( clamdopts = = NULL ) {
logg ( " !Clamonacc: can't parse clamd configuration file %s \n " , optget ( opts , " config-file " ) - > strarg ) ;
return 2 ;
}
ctx - > clamdopts = clamdopts ;
/* Setup our client */
switch ( onas_setup_client ( & ctx ) ) {
case CL_SUCCESS :
if ( CL_SUCCESS = = onas_check_client_connection ( & ctx ) ) {
break ;
}
case CL_BREAK :
ret = 0 ;
logg ( " *Clamonacc: not setting up client \n " ) ;
goto clean_up ;
break ;
case CL_EARG :
default :
logg ( " !Clamonacc: can't setup client \n " ) ;
ret = 2 ;
goto clean_up ;
break ;
}
ret = startup_checks ( ctx ) ;
if ( ret ) {
goto clean_up ;
}
@ -88,13 +115,6 @@ int main(int argc, char **argv)
}
# endif
clamdopts = optparse ( optget ( opts , " config-file " ) - > strarg , 0 , NULL , 1 , OPT_CLAMD , 0 , NULL ) ;
if ( clamdopts = = NULL ) {
logg ( " !Clamonacc: can't parse clamd configuration file %s \n " , optget ( opts , " config-file " ) - > strarg ) ;
return 2 ;
}
ctx - > clamdopts = clamdopts ;
ctx - > maxthreads = optget ( ctx - > clamdopts , " OnAccessMaxThreads " ) - > numarg ;
/* Setup our event queue */
@ -111,24 +131,6 @@ int main(int argc, char **argv)
break ;
}
/* Setup our client */
switch ( onas_setup_client ( & ctx ) ) {
case CL_SUCCESS :
if ( CL_SUCCESS = = onas_check_client_connection ( & ctx ) ) {
break ;
}
case CL_BREAK :
ret = 0 ;
logg ( " *Clamonacc: not setting up client \n " ) ;
goto clean_up ;
break ;
case CL_EARG :
default :
logg ( " !Clamonacc: can't setup client \n " ) ;
ret = 2 ;
goto clean_up ;
break ;
}
# if defined(FANOTIFY)
/* Setup fanotify */
switch ( onas_setup_fanotif ( & ctx ) ) {
@ -216,6 +218,35 @@ int onas_start_eloop(struct onas_context **ctx) {
return ret ;
}
static int startup_checks ( struct onas_context * ctx ) {
int ret = 0 ;
cl_error_t err = CL_SUCCESS ;
if ( optget ( ctx - > opts , " help " ) - > enabled ) {
help ( ) ;
ret = 2 ;
goto done ;
}
if ( optget ( ctx - > opts , " version " ) - > enabled ) {
onas_print_server_version ( & ctx ) ;
ret = 2 ;
goto done ;
}
if ( 0 = = onas_check_remote ( & ctx , & err ) ) {
if ( ! optget ( ctx - > clamdopts , " OnAccessExcludeUID " ) - > enabled & &
! optget ( ctx - > clamdopts , " OnAccessExcludeUname " ) - > enabled ) {
logg ( " !Clamonacc: neither OnAccessExcludeUID or OnAccessExcludeUname is specified ... it is reccomended you exclude the clamd instance UID or uname to prevent infinite event scanning loops \n " ) ;
ret = 2 ;
goto done ;
}
}
done :
return ret ;
}
void help ( void )
{
mprintf_stdout = 1 ;