static int run_mysqlcheck_upgrade(my_bool mysql_db_only) { const char *what= mysql_db_only ? "mysql database" : "tables"; const char *arg1= mysql_db_only ? "--databases" : "--all-databases"; const char *arg2= mysql_db_only ? "mysql" : "--skip-database=mysql"; int retch; if (opt_systables_only && !mysql_db_only) { verbose("Phase %d/%d: Checking and upgrading %s... Skipped", ++phase, phases_total, what); return 0; } verbose("Phase %d/%d: Checking and upgrading %s", ++phase, phases_total, what); print_conn_args("mysqlcheck"); retch= run_tool(mysqlcheck_path, NULL, /* Send output from mysqlcheck directly to screen */ "--no-defaults", ds_args.str, "--check-upgrade", "--auto-repair", !opt_silent || opt_verbose >= 1 ? "--verbose" : "", opt_verbose >= 2 ? "--verbose" : "", opt_verbose >= 3 ? "--verbose" : "", opt_silent ? "--silent": "", opt_write_binlog ? "--write-binlog" : "--skip-write-binlog", arg1, arg2, "2>&1", NULL); return retch; }
static int run_mysqlcheck_views(void) { const char *upgrade_views="--process-views=YES"; if (upgrade_from_mysql) { /* this has to ignore opt_systables_only, because upgrade_from_mysql is determined by analyzing systables. if we honor opt_systables_only here, views won't be fixed by subsequent mysql_upgrade runs */ upgrade_views="--process-views=UPGRADE_FROM_MYSQL"; verbose("Phase %d/%d: Fixing views from mysql", ++phase, phases_total); } else if (opt_systables_only) { verbose("Phase %d/%d: Fixing views... Skipped", ++phase, phases_total); return 0; } else verbose("Phase %d/%d: Fixing views", ++phase, phases_total); print_conn_args("mysqlcheck"); return run_tool(mysqlcheck_path, NULL, /* Send output from mysqlcheck directly to screen */ "--no-defaults", ds_args.str, "--all-databases", "--repair", upgrade_views, "--skip-process-tables", opt_verbose ? "--verbose": "", opt_silent ? "--silent": "", opt_write_binlog ? "--write-binlog" : "--skip-write-binlog", "2>&1", NULL); }
static int run_mysqlcheck_fixnames(void) { if (opt_systables_only) { verbose("Phase %d/%d: Fixing table and database names ... Skipped", ++phase, phases_total); return 0; } verbose("Phase %d/%d: Fixing table and database names", ++phase, phases_total); print_conn_args("mysqlcheck"); return run_tool(mysqlcheck_path, NULL, /* Send output from mysqlcheck directly to screen */ "--no-defaults", ds_args.str, "--all-databases", "--fix-db-names", "--fix-table-names", opt_verbose >= 1 ? "--verbose" : "", opt_verbose >= 2 ? "--verbose" : "", opt_verbose >= 3 ? "--verbose" : "", opt_silent ? "--silent": "", opt_write_binlog ? "--write-binlog" : "--skip-write-binlog", "2>&1", NULL); }
static int run_query(const char *query, DYNAMIC_STRING *ds_res, my_bool force) { int ret; File fd; char query_file_path[FN_REFLEN]; const uchar sql_log_bin[]= "SET SQL_LOG_BIN=0;"; DBUG_ENTER("run_query"); DBUG_PRINT("enter", ("query: %s", query)); if ((fd= create_temp_file(query_file_path, opt_tmpdir[0] ? opt_tmpdir : NULL, "sql", O_CREAT | O_SHARE | O_RDWR, MYF(MY_WME))) < 0) die("Failed to create temporary file for defaults"); /* Master and slave should be upgraded separately. All statements executed by mysql_upgrade will not be binlogged. 'SET SQL_LOG_BIN=0' is executed before any other statements. */ if (!opt_write_binlog) { if (my_write(fd, sql_log_bin, sizeof(sql_log_bin)-1, MYF(MY_FNABP | MY_WME))) { my_close(fd, MYF(0)); my_delete(query_file_path, MYF(0)); die("Failed to write to '%s'", query_file_path); } } if (my_write(fd, (uchar*) query, strlen(query), MYF(MY_FNABP | MY_WME))) { my_close(fd, MYF(0)); my_delete(query_file_path, MYF(0)); die("Failed to write to '%s'", query_file_path); } ret= run_tool(mysql_path, ds_res, "--no-defaults", ds_args.str, "--database=mysql", "--batch", /* Turns off pager etc. */ force ? "--force": "--skip-force", ds_res || opt_silent ? "--silent": "", "<", query_file_path, "2>&1", NULL); my_close(fd, MYF(0)); my_delete(query_file_path, MYF(0)); DBUG_RETURN(ret); }
static int run_mysqlcheck_upgrade(void) { verbose("Running 'mysqlcheck'..."); return run_tool(mysqlcheck_path, NULL, /* Send output from mysqlcheck directly to screen */ "--no-defaults", ds_args.str, "--check-upgrade", "--all-databases", "--auto-repair", NULL); }
static int run_mysqlcheck_fixnames(void) { print_conn_args("mysqlcheck"); return run_tool(mysqlcheck_path, NULL, /* Send output from mysqlcheck directly to screen */ "--no-defaults", ds_args.str, "--all-databases", "--fix-db-names", "--fix-table-names", opt_write_binlog ? "--write-binlog" : "--skip-write-binlog", NULL); }
static int run_mysqlcheck_upgrade(void) { print_conn_args("mysqlcheck"); return run_tool(mysqlcheck_path, NULL, /* Send output from mysqlcheck directly to screen */ "--no-defaults", ds_args.str, "--check-upgrade", "--all-databases", "--auto-repair", opt_write_binlog ? "--write-binlog" : "--skip-write-binlog", NULL); }
char* get_digitizer_string() { char *cmd, *tmp; // Find a digitizer in the IO Registry cmd = "ioreg -l | grep -A15 -E \"\\+-o (DIGI|WACM|COMA)\" | grep -m1 \\\"name\\\" | sed -E \"s/.*<\\\"?([^\\\">]+)\\\"?>/\\\\1/\""; char *digitizer_string = run_tool(cmd); if (digitizer_string != NULL) { // If not found then try an alternative method if (strlen(digitizer_string) == 0) { cmd = "ioreg -l | grep -E \"\\\"name\\\" = <\\\"(WAC|FUJ|FPI|574143|46554a|465049)[0-9A-F]+\\\">\" | sed -E \"s/.*<\\\"?([^\\\">]+)\\\"?>/\\\\1/\""; tmp = digitizer_string; digitizer_string = run_tool(cmd); free(tmp); } } // asprintf(&digitizer_string, "WACF005"); // FOR TESTING ONLY! // If we got a digitizer string, continue if (digitizer_string != NULL) { clean_string(digitizer_string); // If the string was very long, convert hex to decimal if (strlen(digitizer_string) > 12) { (void)asprintf(&cmd, "echo %s | xxd -r -p", digitizer_string); tmp = digitizer_string; digitizer_string = run_tool(cmd); clean_string(digitizer_string); free(tmp); free(cmd); } } return digitizer_string; }
int main(int argc, char** argv) { int worker_id = wx_env_get_worker_id(); if (worker_id < 0) { return run_tool(argc, argv); } // char _b[64]={0}; // sprintf(_b, "./profiler-%d.pprof", worker_id); // ProfilerStart(_b); int listen_fd = wx_env_get_listen_fd(); if (listen_fd < 0) { wx_err("listen_fd < 0"); return EXIT_FAILURE; } int worker_count = wx_env_get_worker_count(); if (worker_count < 0) { wx_err("worker_count < 0"); return EXIT_FAILURE; } char buf32[32]={0}; size_t connections = 1024; if (0 == wx_conf_get("connection", buf32, sizeof(buf32))) { connections = (size_t)atoi(buf32); } if (0 != conns_alloc(connections)) { wx_err("conns_alloc"); return EXIT_FAILURE; } l5_shm_init(); wx_worker_init(listen_fd, accept_cb, alloc_cb, read_cb); int r = wx_worker_run(); l5_shm_detach(); conns_free(); // ProfilerStop(); wx_err("worker stop"); return r; }
static int run_mysqlcheck_upgrade(void) { verbose("Phase 2/3: Checking and upgrading tables"); print_conn_args("mysqlcheck"); return run_tool(mysqlcheck_path, NULL, /* Send output from mysqlcheck directly to screen */ "--no-defaults", ds_args.str, "--check-upgrade", "--all-databases", "--auto-repair", !opt_silent || opt_verbose ? "--verbose": "", opt_silent ? "--silent": "", opt_write_binlog ? "--write-binlog" : "--skip-write-binlog", NULL); }
static int run_mysqlcheck_fixnames(void) { verbose("Phase 1/3: Fixing table and database names"); print_conn_args("mysqlcheck"); return run_tool(mysqlcheck_path, NULL, /* Send output from mysqlcheck directly to screen */ "--no-defaults", ds_args.str, "--all-databases", "--fix-db-names", "--fix-table-names", opt_verbose ? "--verbose": "", opt_silent ? "--silent": "", opt_write_binlog ? "--write-binlog" : "--skip-write-binlog", NULL); }
static void main_menu() { while (true) { print_header(); console_puts("It will attempt to completley destory ALL DATA on SELECTED ATA DISKS.\n\n"); console_puts("The following devices have been detected:\n"); uint8_t devices = 0; for (uint8_t i = 0; i < 4; i++) { if (ide_device_is_present(i) && ide_device_get_type(i) == 0) { console_putsf(" - ATA Device %u (%s) %7uMB - %s\n", i, ide_device_is_dma_capable(i) ? "DMA" : "PIO", ide_device_get_size(i) / 1024 / 2, ide_device_get_string(i, IDE_STRING_MODEL)); devices++; } } if (devices == 0) { console_color(0x0C); console_puts("\nNo devices have been detected. You cannot run this tool.\n"); console_color(0x07); } for (uint8_t i = 0; i < 12 - devices + 1 - (devices ? 0 : 2); i++) console_puts("\n"); console_puts("Press \"i\" to view technical information.\n"); if (devices == 0) { console_puts("You may turn the computer off."); } else { console_puts("Press \"ENTER\" to continue."); } char c = get_key(); switch (c) { case 'i': print_tech_info(); break; case '\n': if(devices) run_tool(devices); break; } } }
static int run_query(const char *query, DYNAMIC_STRING *ds_res, my_bool force) { int ret; File fd; char query_file_path[FN_REFLEN]; DBUG_ENTER("run_query"); DBUG_PRINT("enter", ("query: %s", query)); if ((fd= create_temp_file(query_file_path, opt_tmpdir, "sql", O_CREAT | O_SHARE | O_RDWR, MYF(MY_WME))) < 0) die("Failed to create temporary file for defaults"); if (my_write(fd, query, strlen(query), MYF(MY_FNABP | MY_WME))) { my_close(fd, MYF(0)); my_delete(query_file_path, MYF(0)); die("Failed to write to '%s'", query_file_path); } ret= run_tool(mysql_path, ds_res, "--no-defaults", ds_args.str, "--database=mysql", "--batch", /* Turns off pager etc. */ force ? "--force": "--skip-force", ds_res ? "--silent": "", "<", query_file_path, "2>&1", NULL); my_close(fd, MYF(0)); my_delete(query_file_path, MYF(0)); DBUG_RETURN(ret); }
/** Look for the filename of given tool, with the presumption that it is in the same directory as mysql_upgrade and that the same executable-searching mechanism will be used when we run our sub-shells with popen() later. */ static void find_tool(char *tool_executable_name, const char *tool_name, const char *self_name) { char *last_fn_libchar; DYNAMIC_STRING ds_tmp; DBUG_ENTER("find_tool"); DBUG_PRINT("enter", ("progname: %s", my_progname)); if (init_dynamic_string(&ds_tmp, "", 32, 32)) die("Out of memory"); last_fn_libchar= strrchr(self_name, FN_LIBCHAR); if (last_fn_libchar == NULL) { /* mysql_upgrade was found by the shell searching the path. A sibling next to us should be found the same way. */ strncpy(tool_executable_name, tool_name, FN_REFLEN); } else { int len; /* mysql_upgrade was run absolutely or relatively. We can find a sibling by replacing our name after the LIBCHAR with the new tool name. */ /* When running in a not yet installed build and using libtool, the program(mysql_upgrade) will be in .libs/ and executed through a libtool wrapper in order to use the dynamic libraries from this build. The same must be done for the tools(mysql and mysqlcheck). Thus if path ends in .libs/, step up one directory and execute the tools from there */ if (((last_fn_libchar - 6) >= self_name) && (strncmp(last_fn_libchar - 5, ".libs", 5) == 0) && (*(last_fn_libchar - 6) == FN_LIBCHAR)) { DBUG_PRINT("info", ("Chopping off \".libs\" from end of path")); last_fn_libchar -= 6; } len= last_fn_libchar - self_name; my_snprintf(tool_executable_name, FN_REFLEN, "%.*s%c%s", len, self_name, FN_LIBCHAR, tool_name); } if (opt_verbose) verbose("Looking for '%s' as: %s", tool_name, tool_executable_name); /* Make sure it can be executed */ if (run_tool(tool_executable_name, &ds_tmp, /* Get output from command, discard*/ "--no-defaults", "--help", "2>&1", IF_WIN("> NUL", "> /dev/null"), NULL)) die("Can't execute '%s'", tool_executable_name); dynstr_free(&ds_tmp); DBUG_VOID_RETURN; }
void run_exif() {run_tool("exif");}
void run_spoon() {run_tool("spoon");}
int main(int argc, char* argv[]) { int retval; int input_num; int found = 0; int this_arg; int tool; int count; struct stat st; for (input_num = 0; input_num < NUMBER_OF_INPUTS_TO_SCAN; input_num++) { memset(input_number, 0x00, MAX_STRING_LEN); snprintf(input_number, MAX_STRING_LEN, "%s%d/%s", INPUT_PATH, input_num, BUILDID_FILENAME); retval = stat(input_number, &st); if (retval == 0) { snprintf(driver_path, MAX_STRING_LEN, "%s%d", INPUT_PATH, input_num); found = 1; break; } } if (!found) { printf("ERROR: input driver not found\n"); error_exit(ENODEV); } if (argc > 1) { if (strcmp(argv[1], "fw_update") == 0) { tool = FW_UPDATE; } else if (strcmp(argv[1], "read_report") == 0) { tool = READ_REPORT; } else if (strcmp(argv[1], "reg_access") == 0) { tool = REG_ACCESS; } else if (strcmp(argv[1], "backdoor_access") == 0) { tool = BACKDOOR_ACCESS; } else if (strcmp(argv[1], "data_logger") == 0) { tool = DATA_LOGGER; } else { printf("ERROR: invalid tool name\n"); error_exit(EINVAL); } if (argc == 2) { printf("ERROR: tool parameters missing\n"); print_tool_usage(tool); error_exit(EINVAL); } this_arg = 2; count = 0; while (this_arg < argc) { arg[count] = argv[this_arg]; this_arg++; count++; } run_tool(tool, count); return 0; } usage(); get_line(); parse_args(); switch (*arg[0]) { case '1': case '2': case '3': case '4': tool = stdin_input[0] - '0'; break; case '*': get_line(); if ((stdin_input[0] == '8') && (stdin_input[1] == '1')) { tool = BACKDOOR_ACCESS; break; } default: printf("ERROR: invalid input\n"); error_exit(EINVAL); } tool_parameters: printf("Enter tool parameters (? for help): "); get_line(); count = parse_args(); if (*arg[0] == '?') { print_tool_usage(tool); goto tool_parameters; } else if (count > 0) { run_tool(tool, count); } return 0; }