conda fixed

This commit is contained in:
Pan Qiancheng 2025-04-07 09:30:00 +08:00
parent 5178f93e7e
commit 16883041db
2 changed files with 15 additions and 7 deletions

View File

@ -266,6 +266,13 @@ void load_config_if_needed() {
}
int execve(const char *filename, char *const argv[], char *const envp[]) {
// 如果功能被禁用,则直接执行
if (!config.enabled) {
orig_execve_type orig_execve =
(orig_execve_type)dlsym(RTLD_NEXT, "execve");
return orig_execve(filename, argv, envp);
}
// 仅在 shell 终端调用 execve 时拦截
if (!is_terminal_shell()) {
orig_execve_type orig_execve =
@ -276,13 +283,6 @@ int execve(const char *filename, char *const argv[], char *const envp[]) {
// 加载配置(仅在需要时)
load_config_if_needed();
// 如果功能被禁用,则直接执行
if (!config.enabled) {
orig_execve_type orig_execve =
(orig_execve_type)dlsym(RTLD_NEXT, "execve");
return orig_execve(filename, argv, envp);
}
write_log(filename, argv);
const char *basename = argv[0];
@ -290,6 +290,14 @@ int execve(const char *filename, char *const argv[], char *const envp[]) {
basename = argv[2];
}
// 特殊处理以 shell.posix
// 方式执行的命令,直接执行,不进行规则匹配和输出重定向
if (argv[1] != NULL && strcmp(argv[1], "shell.posix") == 0) {
orig_execve_type orig_execve =
(orig_execve_type)dlsym(RTLD_NEXT, "execve");
return orig_execve(filename, argv, envp);
}
for (int i = 0; i < config.rule_count; i++) {
if (strcmp(basename, config.rules[i].cmd) == 0 &&
args_match(argv, &config.rules[i])) {

Binary file not shown.