Rizin
unix-like reverse engineering framework and cli tools
|
Go to the source code of this file.
Classes | |
struct | RSysInfo |
Macros | |
#define | RZ_SYS_DEVNULL "/dev/null" |
#define | rz_sys_xsystem(cmd) RZ_V_NOT(rz_sys_system(cmd), -1) |
#define | rz_sys_mkdir_failed() (errno != EEXIST) |
#define | __has_builtin(n) (0) |
#define | rz_sys_trap() __asm__ __volatile__(".word 0"); |
#define | rz_sys_breakpoint() |
Enumerations | |
enum | { RZ_SYS_BITS_8 = 1 , RZ_SYS_BITS_16 = 2 , RZ_SYS_BITS_32 = 4 , RZ_SYS_BITS_64 = 8 } |
#define rz_sys_breakpoint | ( | ) |
#define rz_sys_xsystem | ( | cmd | ) | RZ_V_NOT(rz_sys_system(cmd), -1) |
anonymous enum |
Definition at line 788 of file sys.c.
References arch, arch_bit_array, and i.
Referenced by rz_core_rtr_gdb_run(), rz_debug_gdb_attach(), rz_debug_gdb_reg_profile(), rz_debug_qnx_attach(), and rz_debug_qnx_reg_profile().
Definition at line 798 of file sys.c.
References arch, arch_bit_array, bit, and i.
Referenced by info(), and rz_egg_load_file().
Print the backtrace at the point this function is called from.
Definition at line 265 of file sys.c.
References eprintf.
Referenced by rz_assert_log(), rz_core_is_valid_offset(), rz_io_desc_add(), and winkd_wait_packet().
RZ_API bool rz_sys_chdir | ( | RZ_NONNULL const char * | s | ) |
Change current directory to s
, taking care of home expansion ~.
Definition at line 532 of file sys.c.
References chdir, free(), rz_path_home_expand(), rz_return_val_if_fail, and s.
Referenced by rz_cmd_shell_cd_handler(), rz_main_rizin(), and rz_test_chdir_fromtest().
Clean all environment variables in the calling process.
Please note that environment variables should not be used to store sensitive info as they might be kept elsewhere and there is no access control over that data.
Definition at line 346 of file sys.c.
References e, env, environ, eq, free(), L, len, NULL, RZ_NEWS0, rz_sys_env_init(), and v.
Referenced by rz_run_parseline(), and rz_sys_set_environ().
Definition at line 669 of file sys.c.
References cmd, free(), input(), len, NULL, output, and rz_sys_cmd_str_full().
Referenced by assemble(), getstr(), rz_core_cmd_command(), rz_sys_cmd_strf(), and socket_http_get_recursive().
RZ_API int rz_sys_cmd_str_full | ( | const char * | cmd, |
const char * | input, | ||
char ** | output, | ||
int * | len, | ||
char ** | sterr | ||
) |
Definition at line 590 of file sys.c.
References argv, cmd, rz_subprocess_opt_t::file, input(), len, NULL, output, RZ_LOG_ERROR, rz_str_argv(), rz_str_argv_free(), rz_subprocess_err(), rz_subprocess_fini(), rz_subprocess_free(), rz_subprocess_init(), rz_subprocess_out(), RZ_SUBPROCESS_PIPE_CREATE, RZ_SUBPROCESS_PIPE_NONE, rz_subprocess_start_opt(), rz_subprocess_stdin_write(), rz_subprocess_wait(), stdin_pipe, stdout_pipe, and UT64_MAX.
Referenced by rz_cons_flush(), rz_core_cmd_pipe_old(), and rz_sys_cmd_str().
Referenced by rz_cmd_debug_dmS_handler(), rz_egg_Cfile_parser(), and rz_egg_Cfile_set_cEnv().
Definition at line 644 of file sys.c.
References eprintf, test-lz4-list::exit, free(), NULL, pid, rz_file_binsh(), rz_sys_execl(), rz_sys_fork(), and cmd_descs_generate::str.
Referenced by rz_main_rz_agent().
Definition at line 457 of file sys.c.
References cmd, free(), rz_sys_sigaction(), SIGHUP, signal_handler(), and strdup().
Referenced by rz_main_rizin().
Definition at line 216 of file sys.c.
References fh, free(), HANDLE, INVALID_HANDLE_VALUE, list(), NULL, path, readdir, rz_list_append(), rz_list_new(), rz_list_newf(), strdup(), and sys_opendir().
Referenced by __clear_layout_cb(), __get_panels_config_file_from_dir(), __init_menu_saved_layout(), autocmplt_cmd_arg_file(), autocomplete_process_path(), cmd_print_format(), database_load(), is_cpu_valid(), list_themes_in_path(), load_scripts_for(), recursive_search_glob(), rtr_dir_files(), rz_cons_hud_path(), rz_core_loadlibs(), rz_core_parse_rizinrc(), rz_syscmd_ls(), rz_test_test_database_load_fuzz(), and rzfind_open_dir().
RZ_API void rz_sys_env_init | ( | void | ) |
Definition at line 1108 of file sys.c.
References env, and rz_sys_get_environ().
Referenced by rz_main_rizin(), and rz_sys_clearenv().
Definition at line 1575 of file sys.c.
Referenced by bochs_open(), rz_core_cmd_pipe_old(), rz_run_start(), and rz_sys_cmdbg().
Definition at line 1483 of file sys.c.
Referenced by rz_run_start(), and rz_socket_proc_open().
Definition at line 1525 of file sys.c.
Referenced by rz_subprocess_start_opt().
Definition at line 183 of file sys.c.
References test-lz4-list::exit, and status.
Referenced by lang_pipe_run(), and rz_subprocess_start_opt().
Definition at line 1815 of file sys.c.
References benchmark::FILE, free(), NULL, path, rz_file_is_regular(), rz_path_home_expand(), and rz_return_val_if_fail.
Referenced by __write(), DEFINE_HANDLE_TS_FCN_AND_SYMBOL(), ihex_write(), load_1(), rz_cmd_cmp_file_handler(), rz_cons_flush(), rz_core_cmd_foreach(), rz_core_dump(), rz_file_dump(), rz_file_hexdump(), rz_file_slurp(), rz_file_slurp_hexpairs(), rz_file_slurp_range(), rz_line_hist_load(), rz_line_hist_save(), rz_run_parseline(), rz_save_panels_layout(), and rz_vlog().
Definition at line 1679 of file sys.c.
Referenced by lang_pipe_run(), redirect_socket_to_pty(), rz_core_cmd_pipe_old(), rz_main_rz_agent(), rz_main_rz_bin(), rz_run_config_env(), rz_run_start(), rz_socket_proc_open(), rz_socket_spawn(), rz_subprocess_start_opt(), rz_sys_cmdbg(), rz_sys_run(), rz_sys_run_rop(), rzpipe_open(), and wrap_fork().
RZ_API char** rz_sys_get_environ | ( | void | ) |
Definition at line 1115 of file sys.c.
References env, environ, NULL, and rz_lib_dl_sym().
Referenced by autocmplt_cmd_arg_env(), create_child_env(), rz_cmd_shell_env_handler(), rz_main_rizin(), rz_run_start(), and rz_sys_env_init().
RZ_API char* rz_sys_getdir | ( | void | ) |
Get current working directory.
Definition at line 521 of file sys.c.
References NULL.
Referenced by getcommapath(), rz_cmd_shell_cd_handler(), rz_cmd_shell_pwd_handler(), rz_file_abspath(), rz_test_chdir_fromtest(), rz_test_main(), and windbg_gcore().
Get the value of an environment variable named key
or NULL if none exists.
Definition at line 483 of file sys.c.
References b, free(), getenv(), key, NULL, strdup(), and val.
Referenced by __load_plugins(), binutils_assemble(), create_cache_bins(), find_include(), gdbr_connect(), hash_load_plugins(), interact_commands(), loadSystemPlugins(), parse_signature(), rz_assert_log(), rz_cmd_shell_env_handler(), rz_cons_get_size(), rz_core_config_init(), rz_core_parse_rizinrc(), rz_core_run_script(), rz_core_sysenv_end(), rz_egg_Cfile_getCompiler(), rz_egg_Cfile_set_cEnv(), rz_egg_lang_include_path(), rz_file_binsh(), rz_file_path(), rz_file_tmpdir(), rz_lib_path(), rz_main_rizin(), rz_main_rz_asm(), rz_main_rz_bin(), rz_main_rzpipe(), rz_path_home(), rz_path_home_prefix(), rz_reg_parse_gdb_profile(), rz_reg_set_profile(), rz_run_config_env(), rz_run_parseline(), rz_str_home(), rzp_open_spawn(), set_color_default(), socket_http_get_recursive(), spp_var_get(), windbg_gcore(), windbg_init(), and windbg_open().
Return true if the environment variable has the value 1, false otherwise.
Definition at line 511 of file sys.c.
References env, free(), key, and rz_sys_getenv().
Referenced by rz_core_parse_rizinrc(), and rz_main_rizin().
Definition at line 1164 of file sys.c.
Referenced by num_callback(), sdb_lock(), and TAG_CALLBACK().
Definition at line 1175 of file sys.c.
References DWORD, key, major, minor, NULL, RZ_NEW0, rz_str_newf(), rz_sys_info_free(), rz_sys_perror, si, strdup(), autogen_x86imm::tmp, type, and uname.
Referenced by __is_windows_ten(), and rz_cmd_shell_uname_handler().
Send signal sig
to process with pid pid
.
pid | PID of the process to send the signal to |
sig | Signal to send to the process. |
Definition at line 1850 of file sys.c.
References kill, pid, and rz_return_val_if_fail.
Referenced by rz_debug_signal_send(), rz_main_rz_agent(), and rz_sys_stop().
Definition at line 678 of file sys.c.
Referenced by rz_sys_mkdirp().
Definition at line 691 of file sys.c.
References eprintf, free(), p, path, RZ_SYS_DIR, rz_sys_mkdir(), rz_sys_mkdir_failed, and strdup().
Referenced by __create_panels_config_path(), download_and_write(), extract_binobj(), rz_line_hist_save(), rz_syscmd_mkdir(), and sdb_disk_create().
Definition at line 1740 of file sys.c.
References DWORD, flags, free(), h, HANDLE, INVALID_HANDLE_VALUE, NULL, O_APPEND, O_CREAT, O_EXCL, O_RDWR, O_TRUNC, O_WRONLY, path, rz_path_home_expand(), and rz_return_val_if_fail.
Referenced by apprentice_compile(), apprentice_map(), binutils_assemble(), buf_file_init(), langFromHashbang(), procfs_pid_slurp(), rz_cons_pipe_open(), rz_core_editor(), rz_file_mkstemp(), rz_file_mmap(), rz_file_mmap_resize(), rz_file_truncate(), rz_sys_aslr(), rz_sys_truncate(), and sp_open().
Convert rizin permissions (RZ_PERM_*) to posix permissions that can be passed to rz_sys_open .
rz_sys_open accepts posix permissions for now, not the arch-independent ones provided by RZ_PERM_*. This function is an helper to convert from rizin permissions to posix ones.
Definition at line 1718 of file sys.c.
References O_CREAT, O_RDONLY, O_RDWR, O_WRONLY, RZ_PERM_CREAT, RZ_PERM_R, and RZ_PERM_W.
Referenced by rz_io_ar_open(), rz_io_ar_open_many(), and rz_io_def_mmap_create_new_file().
Definition at line 737 of file sys.c.
References DWORD, eprintf, err, free(), NULL, and rz_str_endswith().
Definition at line 920 of file sys.c.
References argv, d, DWORD, eprintf, FALSE, free(), getenv(), HANDLE, L, len, length, malloc(), name, NULL, ok, p, path, pid, readlink, rz_str_ncpy(), rz_str_newf(), snprintf, sp, stat, strdup(), and autogen_x86imm::tmp.
Referenced by cmd_debug_pid(), and rz_debug_get_baddr().
Definition at line 1458 of file sys.c.
Referenced by bochs_open(), handle_redirection(), lang_pipe_run(), rz_core_cmd_pipe_old(), rz_run_config_env(), rz_socket_proc_open(), rz_subprocess_init(), rz_subprocess_start_opt(), and rzpipe_open().
Definition at line 1462 of file sys.c.
Referenced by bochs_open(), handle_redirection(), lang_pipe_run(), rz_core_cmd_pipe_old(), rz_run_config_env(), rz_subprocess_fini(), rz_subprocess_free(), rz_subprocess_init(), rz_subprocess_start_opt(), rz_subprocess_wait(), rzpipe_close(), and rzpipe_open().
Definition at line 809 of file sys.c.
References cb, eprintf, test-lz4-list::exit, free(), int, len, malloc(), memcpy(), num, p, pid, rz_mem_protect(), and rz_sys_fork().
Referenced by rz_egg_run().
Definition at line 861 of file sys.c.
References eprintf, test-lz4-list::exit, free(), len, malloc(), memcpy(), num, pid, RZ_SYS_ASM_START_ROP, and rz_sys_fork().
Referenced by rz_egg_run_rop().
RZ_API void rz_sys_set_environ | ( | char ** | e | ) |
Definition at line 1128 of file sys.c.
References e, env, environ, free(), NULL, rz_sys_clearenv(), rz_sys_setenv(), and val.
Referenced by rz_subprocess_start_opt().
Set an environment variable in the calling process.
Definition at line 405 of file sys.c.
References free(), key, L, LPWSTR, and value.
Referenced by ARG_CALLBACK(), cb_dirhome(), cb_dirtmp(), env(), rcc_next(), rz_cmd_shell_env_handler(), rz_core_cmd_subst_i(), rz_core_config_init(), rz_core_sysenv_begin(), rz_core_sysenv_end(), rz_egg_lang_include_init(), rz_egg_lang_include_path(), rz_main_rz_bin(), rz_run_config_env(), rz_run_parseline(), rz_test_main(), spp_var_set(), TAG_CALLBACK(), and tmpenvs_free().
Definition at line 162 of file sys.c.
References EINVAL, eprintf, i, int, and signal.
Referenced by rz_sys_crash_handler(), and rz_sys_signal().
Definition at line 178 of file sys.c.
References rz_sys_sigaction(), and s.
Referenced by activateDieTime(), rz_cons_break_end(), rz_cons_context_break_pop(), rz_cons_context_break_push(), rz_cons_new(), rz_core_cmd_pipe_old(), rz_socket_connect(), rz_socket_listen(), rz_socket_new(), rz_socket_write(), rz_subprocess_fini(), rz_subprocess_init(), rz_subprocess_stdin_write(), and tcpme().
Sleep for secs
seconds.
Definition at line 300 of file sys.c.
References NULL, timespec::tv_nsec, and timespec::tv_sec.
Referenced by qnxr_attach(), rtr_visual(), rz_cmd_shell_sleep_handler(), rz_core_visual_esil(), rz_core_visual_show_char(), rz_core_visual_trackflags(), rz_main_rizin(), rz_run_config_env(), rz_socket_spawn(), and sdb_lock_wait().
Send SIGTSTP signal to every process in this process group.
Definition at line 1864 of file sys.c.
References rz_sys_kill().
Referenced by rz_cons_controlz().
Definition at line 1658 of file sys.c.
Referenced by binutils_assemble(), handle_redirection_proc(), rz_cmd_shell_mv_handler(), rz_egg_Cfile_parser(), rz_run_start(), rz_sys_cmdf(), rz_test_test_run_unit(), and rzpipe_open().
Definition at line 1692 of file sys.c.
References close, eprintf, fd, O_RDWR, r, rz_sys_open(), rz_sys_truncate_fd(), and truncate.
Referenced by rz_core_dump(), rz_file_dump(), rz_file_hexdump(), and rz_file_mmap_resize().
Definition at line 1684 of file sys.c.
References fd, ftruncate, and length.
Referenced by buf_file_resize(), and rz_sys_truncate().
Sleep for usecs
microseconds.
Definition at line 317 of file sys.c.
References NULL, timespec::tv_nsec, and timespec::tv_sec.
Referenced by basefind_thread_ui(), run_basic_block_analysis(), rz_cmd_debug(), rz_cons_flush(), rz_core_rtr_cmds_query(), rz_core_rtr_http_run(), rz_core_visual_esil(), rz_diff_draw_tui(), rz_socket_spawn(), rz_th_yield(), and visual_seek_animation().
RZ_API char* rz_sys_whoami | ( | char * | buf | ) |
RZ_API RZ_OWN char* rz_syscmd_cat | ( | RZ_NONNULL const char * | file | ) |
Definition at line 442 of file syscmd.c.
References eprintf, file, free(), NULL, p, rz_file_slurp(), rz_return_val_if_fail, rz_str_trim(), and strdup().
Referenced by rz_cmd_shell_cat_handler().
RZ_API RZ_OWN char* rz_syscmd_head | ( | RZ_NONNULL const char * | file, |
int | count | ||
) |
Definition at line 284 of file syscmd.c.
References count, eprintf, file, free(), NULL, p, rz_file_slurp_lines(), rz_return_val_if_fail, rz_str_trim(), and strdup().
RZ_API RZ_OWN char* rz_syscmd_join | ( | RZ_NONNULL const char * | file1, |
RZ_NONNULL const char * | file2 | ||
) |
Definition at line 367 of file syscmd.c.
References test_evm::end, eprintf, free(), list(), NULL, out, rz_file_slurp(), rz_list_append(), rz_list_free(), rz_list_newf(), rz_list_to_str(), rz_return_val_if_fail, rz_str_append(), rz_str_new(), rz_str_split_list(), rz_str_startswith(), rz_str_trim(), and strdup().
RZ_API RZ_OWN char* rz_syscmd_ls | ( | RZ_NONNULL const char * | input | ) |
Definition at line 121 of file syscmd.c.
References calloc(), d, eprintf, files, FMT_JSON, FMT_RAW, free(), input(), memcpy(), n, name, needs_newline, NULL, off, p, path, rz_file_is_directory(), rz_file_is_regular(), rz_list_free(), rz_path_home_expand(), rz_str_append(), rz_str_glob(), rz_str_home(), rz_str_startswith(), rz_str_trim_head_ro(), rz_sys_dir(), showfile(), and strdup().
Referenced by rz_cmd_shell_ls_handler().
RZ_API RZ_OWN char* rz_syscmd_mkdir | ( | RZ_NONNULL const char * | dir | ) |
Definition at line 468 of file syscmd.c.
References free(), NULL, rz_return_val_if_fail, rz_str_dup(), rz_str_newf(), rz_str_trim(), rz_str_trim_head_ro(), rz_sys_mkdir_failed, rz_sys_mkdirp(), strdup(), and suffix.
Referenced by rz_cmd_shell_mkdir_handler().
RZ_API RZ_OWN char* rz_syscmd_sort | ( | RZ_NONNULL const char * | file | ) |
Definition at line 254 of file syscmd.c.
References cmpstr(), eprintf, file, free(), list(), NULL, p, rz_file_slurp(), rz_list_free(), rz_list_sort(), rz_list_to_str(), rz_return_val_if_fail, rz_str_split_list(), rz_str_trim(), and strdup().
Referenced by rz_cmd_shell_sort_handler().
RZ_API RZ_OWN char* rz_syscmd_tail | ( | RZ_NONNULL const char * | file, |
int | count | ||
) |
Definition at line 308 of file syscmd.c.
References count, eprintf, file, free(), NULL, p, rz_file_slurp_lines_from_bottom(), rz_return_val_if_fail, rz_str_trim(), and strdup().
RZ_API RZ_OWN char* rz_syscmd_uniq | ( | RZ_NONNULL const char * | file | ) |
Definition at line 334 of file syscmd.c.
References cmpstr(), eprintf, file, free(), list(), NULL, p, rz_file_slurp(), rz_list_free(), rz_list_to_str(), rz_list_uniq(), rz_return_val_if_fail, rz_str_split_list(), rz_str_trim(), and strdup().
Referenced by rz_cmd_shell_uniq_handler().