static void interpret(char *name, char *val, int comma, int rtype) { int type; while (*name == ' '||*name == '(') name++; /* Do some fixups */ if (rtype == AUDIT_EXECVE && name[0] == 'a') type = T_ESCAPED; else if (rtype == AUDIT_AVC && strcmp(name, "saddr") == 0) type = -1; else if (strcmp(name, "acct") == 0) { // Remove trailing punctuation int len = strlen(val); if (val[len-1] == ':') val[len-1] = 0; if (val[0] == '"') type = T_ESCAPED; else if (is_hex_string(val)) type = T_ESCAPED; else type = -1; } else type = audit_lookup_type(name); switch(type) { case T_UID: print_uid(val); break; case T_GID: print_gid(val); break; case T_SYSCALL: print_syscall(val); break; case T_ARCH: print_arch(val); break; case T_EXIT: print_exit(val); break; case T_ESCAPED: print_escaped(val); break; case T_PERM: print_perm(val); break; case T_MODE: print_mode(val); break; case T_SOCKADDR: print_sockaddr(val); break; case T_FLAGS: print_flags(val); break; case T_PROMISC: print_promiscuous(val); break; case T_CAPABILITY: print_capabilities(val); break; case T_SIGNAL: print_signals(val); break; case T_KEY: print_key(val); break; case T_LIST: print_list(val); break; case T_TTY_DATA: print_tty_data(val); break; default: printf("%s%c", val, comma ? ',' : ' '); } }
/* * This function prints 1 rule from the kernel reply */ static void print_rule(const struct audit_rule_data *r) { unsigned int i, count = 0, sc = 0; size_t boffset = 0; int mach = -1, watch = is_watch(r); unsigned long long a0 = 0, a1 = 0; if (!watch) { /* This is syscall auditing */ printf("-a %s,%s", audit_action_to_name((int)r->action), audit_flag_to_name(r->flags)); // Now find the arch and print it for (i = 0; i < r->field_count; i++) { int field = r->fields[i] & ~AUDIT_OPERATORS; if (field == AUDIT_ARCH) { int op = r->fieldflags[i] & AUDIT_OPERATORS; mach = print_arch(r->values[i], op); } } // And last do the syscalls count = print_syscall(r, &sc); } // Now iterate over the fields for (i = 0; i < r->field_count; i++) { const char *name; int op = r->fieldflags[i] & AUDIT_OPERATORS; int field = r->fields[i] & ~AUDIT_OPERATORS; if (field == AUDIT_ARCH) continue; // already printed name = audit_field_to_name(field); if (name) { // Special cases to print the different field types // in a meaningful way. if (field == AUDIT_MSGTYPE) { if (!audit_msg_type_to_name(r->values[i])) printf(" -F %s%s%d", name, audit_operator_to_symbol(op), r->values[i]); else printf(" -F %s%s%s", name, audit_operator_to_symbol(op), audit_msg_type_to_name( r->values[i])); } else if ((field >= AUDIT_SUBJ_USER && field <= AUDIT_OBJ_LEV_HIGH) && field != AUDIT_PPID) { printf(" -F %s%s%.*s", name, audit_operator_to_symbol(op), r->values[i], &r->buf[boffset]); boffset += r->values[i]; } else if (field == AUDIT_WATCH) { if (watch) printf("-w %.*s", r->values[i], &r->buf[boffset]); else printf(" -F path=%.*s", r->values[i], &r->buf[boffset]); boffset += r->values[i]; } else if (field == AUDIT_DIR) { if (watch) printf("-w %.*s/", r->values[i], &r->buf[boffset]); else printf(" -F dir=%.*s", r->values[i], &r->buf[boffset]); boffset += r->values[i]; } else if (field == AUDIT_FILTERKEY) { char *rkey, *ptr, *saved; if (asprintf(&rkey, "%.*s", r->values[i], &r->buf[boffset]) < 0) rkey = NULL; boffset += r->values[i]; ptr = strtok_r(rkey, key_sep, &saved); while (ptr) { if (watch) printf(" -k %s", ptr); else printf(" -F key=%s", ptr); ptr = strtok_r(NULL, key_sep, &saved); } free(rkey); } else if (field == AUDIT_PERM) { char perms[5]; int val=r->values[i]; perms[0] = 0; if (val & AUDIT_PERM_READ) strcat(perms, "r"); if (val & AUDIT_PERM_WRITE) strcat(perms, "w"); if (val & AUDIT_PERM_EXEC) strcat(perms, "x"); if (val & AUDIT_PERM_ATTR) strcat(perms, "a"); if (watch) printf(" -p %s", perms); else printf(" -F perm=%s", perms); } else if (field == AUDIT_INODE) { // This is unsigned printf(" -F %s%s%u", name, audit_operator_to_symbol(op), r->values[i]); } else if (field == AUDIT_FIELD_COMPARE) { print_field_cmp(r->values[i], op); } else if (field >= AUDIT_ARG0 && field <= AUDIT_ARG3){ if (field == AUDIT_ARG0) a0 = r->values[i]; else if (field == AUDIT_ARG1) a1 = r->values[i]; // Show these as hex if (count > 1 || interpret == 0) printf(" -F %s%s0x%X", name, audit_operator_to_symbol(op), r->values[i]); else { // Use ignore to mean interpret const char *out; idata id; char val[32]; int type; id.syscall = sc; id.machine = mach; id.a0 = a0; id.a1 = a1; id.name = name; snprintf(val, 32, "%x", r->values[i]); id.val = val; type = auparse_interp_adjust_type( AUDIT_SYSCALL, name, val); out = auparse_do_interpretation(type, &id); printf(" -F %s%s%s", name, audit_operator_to_symbol(op), out); free((void *)out); } } else if (field == AUDIT_EXIT) { int e = abs((int)r->values[i]); const char *err = audit_errno_to_name(e); if (((int)r->values[i] < 0) && err) printf(" -F %s%s-%s", name, audit_operator_to_symbol(op), err); else printf(" -F %s%s%d", name, audit_operator_to_symbol(op), (int)r->values[i]); } else { // The default is signed decimal printf(" -F %s%s%d", name, audit_operator_to_symbol(op), r->values[i]); } } else { // The field name is unknown printf(" f%d%s%d", r->fields[i], audit_operator_to_symbol(op), r->values[i]); } } printf("\n"); }
int main (int argc, char *argv[]) { #ifndef SPEC char title[] = "\n\nVPR FPGA Placement and Routing Program Version 4.22 " "by V. Betz.\n" "Source completed Jan. 25, 1999; compiled " __DATE__ ".\n" "This code is licensed only for non-commercial use.\n\n"; #else char title[] = "\n\nVPR FPGA Placement and Routing Program Version 4.00-spec" "\nSource completed Sept. 19, 1997.\n\n"; #endif char net_file[BUFSIZE], place_file[BUFSIZE], arch_file[BUFSIZE]; char route_file[BUFSIZE]; float aspect_ratio; boolean full_stats, user_sized; char pad_loc_file[BUFSIZE]; enum e_operation operation; boolean verify_binary_search; boolean show_graphics; int gr_automode; struct s_annealing_sched annealing_sched; struct s_placer_opts placer_opts; struct s_router_opts router_opts; struct s_det_routing_arch det_routing_arch; t_segment_inf *segment_inf; t_timing_inf timing_inf; t_subblock_data subblock_data; t_chan_width_dist chan_width_dist; float constant_net_delay; printf("%s",title); placer_opts.pad_loc_file = pad_loc_file; /* Parse the command line. */ parse_command (argc, argv, net_file, arch_file, place_file, route_file, &operation, &aspect_ratio, &full_stats, &user_sized, &verify_binary_search, &gr_automode, &show_graphics, &annealing_sched, &placer_opts, &router_opts, &timing_inf.timing_analysis_enabled, &constant_net_delay); /* Parse input circuit and architecture */ get_input (net_file, arch_file, placer_opts.place_cost_type, placer_opts.num_regions, aspect_ratio, user_sized, router_opts.route_type, &det_routing_arch, &segment_inf, &timing_inf, &subblock_data, &chan_width_dist); if (full_stats == TRUE) print_lambda (); #ifdef DEBUG print_netlist ("net.echo", net_file, subblock_data); print_arch (arch_file, router_opts.route_type, det_routing_arch, segment_inf, timing_inf, subblock_data, chan_width_dist); #endif if (operation == TIMING_ANALYSIS_ONLY) { /* Just run the timing analyzer. */ do_constant_net_delay_timing_analysis (timing_inf, subblock_data, constant_net_delay); free_subblock_data (&subblock_data); exit (0); } set_graphics_state (show_graphics, gr_automode, router_opts.route_type); if (show_graphics) { /* Get graphics going */ init_graphics("VPR: Versatile Place and Route for FPGAs"); alloc_draw_structs (); } fflush (stdout); place_and_route (operation, placer_opts, place_file, net_file, arch_file, route_file, full_stats, verify_binary_search, annealing_sched, router_opts, det_routing_arch, segment_inf, timing_inf, &subblock_data, chan_width_dist); if (show_graphics) close_graphics(); /* Close down X Display */ exit (0); }