int main(int argc, char *argv[]) { struct daemon_conf config; struct rlimit limit; int rc; /* Check params and build regexpr */ setlocale (LC_ALL, ""); if (check_params(argc, argv)) return 1; /* Raise the rlimits in case we're being started from a shell * with restrictions. Not a fatal error. */ limit.rlim_cur = RLIM_INFINITY; limit.rlim_max = RLIM_INFINITY; setrlimit(RLIMIT_FSIZE, &limit); setrlimit(RLIMIT_CPU, &limit); set_aumessage_mode(MSG_STDERR, DBG_NO); (void) umask( umask( 077 ) | 027 ); very_first_event.sec = 0; reset_counters(); if (user_file == NULL) { /* Load config so we know where logs are */ if (load_config(&config, TEST_SEARCH)) fprintf(stderr, "NOTE - using built-in logs: %s\n", config.log_file); } else { config.sender_ctx = NULL; config.log_file = NULL; config.dispatcher = NULL; config.node_name = NULL; config.space_left_exe = NULL; config.action_mail_acct = NULL; config.admin_space_left_exe = NULL; config.disk_full_exe = NULL; config.disk_error_exe = NULL; config.krb5_principal = NULL; config.krb5_key_file = NULL; } print_title(); lol_create(&lo); if (user_file) rc = process_file(user_file); else if (force_logs) rc = process_logs(&config); else if (is_pipe(0)) rc = process_stdin(); else rc = process_logs(&config); lol_clear(&lo); if (rc) { free_config(&config); return rc; } if (!found && report_detail == D_DETAILED && report_type != RPT_TIME) { printf("<no events of interest were found>\n\n"); destroy_counters(); aulookup_destroy_uid_list(); aulookup_destroy_gid_list(); free_config(&config); return 1; } else print_wrap_up(); destroy_counters(); aulookup_destroy_uid_list(); aulookup_destroy_gid_list(); free_config(&config); free(user_file); return 0; }
int main(int argc, char *argv[]) { struct rlimit limit; int rc; /* Check params and build regexpr */ setlocale (LC_ALL, ""); if (check_params(argc, argv)) return 1; /* Raise the rlimits in case we're being started from a shell * with restrictions. Not a fatal error. */ limit.rlim_cur = RLIM_INFINITY; limit.rlim_max = RLIM_INFINITY; setrlimit(RLIMIT_FSIZE, &limit); setrlimit(RLIMIT_CPU, &limit); set_aumessage_mode(MSG_STDERR, DBG_NO); (void) umask( umask( 077 ) | 027 ); very_first_event.sec = 0; reset_counters(); print_title(); lol_create(&lo); if (user_file) { struct stat sb; if (stat(user_file, &sb) == -1) { perror("stat"); return 1; } else { switch (sb.st_mode & S_IFMT) { case S_IFDIR: userfile_is_dir = 1; rc = process_logs(); break; case S_IFREG: default: rc = process_file(user_file); break; } } } else if (force_logs) rc = process_logs(); else if (is_pipe(0)) rc = process_stdin(); else rc = process_logs(); lol_clear(&lo); if (rc) return rc; if (!found && report_detail == D_DETAILED && report_type != RPT_TIME) { printf("<no events of interest were found>\n\n"); destroy_counters(); aulookup_destroy_uid_list(); aulookup_destroy_gid_list(); return 1; } else print_wrap_up(); destroy_counters(); aulookup_destroy_uid_list(); aulookup_destroy_gid_list(); free(user_file); return 0; }