feat: python3 support
This commit is contained in:
parent
cd5323d561
commit
b96a93e957
@ -30,6 +30,7 @@ void print_help(char *self) {
|
|||||||
LOG_WARN(" --file_output path to output file");
|
LOG_WARN(" --file_output path to output file");
|
||||||
LOG_WARN(" --file_info path to info file");
|
LOG_WARN(" --file_info path to info file");
|
||||||
LOG_WARN(" --program program to run");
|
LOG_WARN(" --program program to run");
|
||||||
|
LOG_WARN(" --program_arg program argument (only accept one argument)");
|
||||||
LOG_WARN(" --help print this help message");
|
LOG_WARN(" --help print this help message");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ void parse(int argc, char *argv[]) {
|
|||||||
[CFG_FILE_OUTPUT] = {"file_output", required_argument, NULL, 0},
|
[CFG_FILE_OUTPUT] = {"file_output", required_argument, NULL, 0},
|
||||||
[CFG_FILE_INFO] = {"file_info", required_argument, NULL, 0},
|
[CFG_FILE_INFO] = {"file_info", required_argument, NULL, 0},
|
||||||
[CFG_PROGRAM] = {"program", required_argument, NULL, 0},
|
[CFG_PROGRAM] = {"program", required_argument, NULL, 0},
|
||||||
|
[CFG_PROGRAM_ARG] = {"program_arg", required_argument, NULL, 0},
|
||||||
[CFG_IS_VALID] = {"help", no_argument, NULL, 0},
|
[CFG_IS_VALID] = {"help", no_argument, NULL, 0},
|
||||||
[CFG_IS_VALID + 1] = {NULL, 0, NULL, 0}
|
[CFG_IS_VALID + 1] = {NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
@ -74,7 +76,7 @@ void parse(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void launch_child() {
|
void launch_child() {
|
||||||
char *args[] = {config[CFG_PROGRAM], NULL};
|
char *args[] = {config[CFG_PROGRAM], config[CFG_PROGRAM_ARG], NULL};
|
||||||
|
|
||||||
/* build stdin */ {
|
/* build stdin */ {
|
||||||
int fd = open(config[CFG_FILE_INPUT], O_RDONLY);
|
int fd = open(config[CFG_FILE_INPUT], O_RDONLY);
|
||||||
@ -141,6 +143,8 @@ int main(int argc, char *argv[]) {
|
|||||||
ret = wait4(child, &status, 0, &usage);
|
ret = wait4(child, &status, 0, &usage);
|
||||||
clock_gettime(CLOCK_MONOTONIC, &time_end);
|
clock_gettime(CLOCK_MONOTONIC, &time_end);
|
||||||
|
|
||||||
|
// LOG_DEBUG("Children exited, status = %d, ret = %d", status, ret);
|
||||||
|
|
||||||
long long time_usage =
|
long long time_usage =
|
||||||
(time_end.tv_sec - time_begin.tv_sec) * 1000 + (time_end.tv_nsec - time_begin.tv_nsec) / 1000000;
|
(time_end.tv_sec - time_begin.tv_sec) * 1000 + (time_end.tv_nsec - time_begin.tv_nsec) / 1000000;
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ enum ConfigIndex {
|
|||||||
CFG_FILE_OUTPUT,
|
CFG_FILE_OUTPUT,
|
||||||
CFG_FILE_INFO,
|
CFG_FILE_INFO,
|
||||||
CFG_PROGRAM,
|
CFG_PROGRAM,
|
||||||
|
CFG_PROGRAM_ARG,
|
||||||
CFG_IS_VALID
|
CFG_IS_VALID
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ void setup_lang_c_cpp(scmp_filter_ctx ctx) {
|
|||||||
SCMP_SYS(clone), // 56
|
SCMP_SYS(clone), // 56
|
||||||
SCMP_SYS(futex), // 202
|
SCMP_SYS(futex), // 202
|
||||||
SCMP_SYS(set_tid_address), // 218
|
SCMP_SYS(set_tid_address), // 218
|
||||||
SCMP_SYS(exit_group), // 231
|
|
||||||
SCMP_SYS(set_robust_list), // 273
|
SCMP_SYS(set_robust_list), // 273
|
||||||
SCMP_SYS(get_robust_list), // 274
|
SCMP_SYS(get_robust_list), // 274
|
||||||
SCMP_SYS(rseq), // 334
|
SCMP_SYS(rseq), // 334
|
||||||
|
@ -11,7 +11,6 @@ void setup_lang_go(scmp_filter_ctx ctx) {
|
|||||||
SCMP_SYS(sigaltstack), // 131
|
SCMP_SYS(sigaltstack), // 131
|
||||||
SCMP_SYS(gettid), // 186
|
SCMP_SYS(gettid), // 186
|
||||||
SCMP_SYS(sched_getaffinity), // 204
|
SCMP_SYS(sched_getaffinity), // 204
|
||||||
SCMP_SYS(exit_group), // 231
|
|
||||||
};
|
};
|
||||||
ADD_RULE_LIST(white, SCMP_ACT_ALLOW);
|
ADD_RULE_LIST(white, SCMP_ACT_ALLOW);
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ void setup_common(scmp_filter_ctx ctx, const char *exe_path) {
|
|||||||
SCMP_SYS(clock_gettime), // 228
|
SCMP_SYS(clock_gettime), // 228
|
||||||
SCMP_SYS(clock_getres), // 229
|
SCMP_SYS(clock_getres), // 229
|
||||||
SCMP_SYS(clock_nanosleep), // 230
|
SCMP_SYS(clock_nanosleep), // 230
|
||||||
|
SCMP_SYS(exit_group), // 231
|
||||||
SCMP_SYS(newfstatat), // 262
|
SCMP_SYS(newfstatat), // 262
|
||||||
SCMP_SYS(getrandom), // 318
|
SCMP_SYS(getrandom), // 318
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#define COLOR_RED "\x1B[1;31m"
|
#define COLOR_RED "\x1B[1;31m"
|
||||||
#define COLOR_YELLOW "\x1B[1;33m"
|
#define COLOR_YELLOW "\x1B[1;33m"
|
||||||
#define COLOR_GREEN "\x1B[1;32m"
|
#define COLOR_GREEN "\x1B[1;32m"
|
||||||
|
#define COLOR_GRAY "\x1B[1;37m"
|
||||||
#define COLOR_STDOUT_RESET "\x1B[0m"
|
#define COLOR_STDOUT_RESET "\x1B[0m"
|
||||||
|
|
||||||
#define _LOG(color, level, fmt, ...) \
|
#define _LOG(color, level, fmt, ...) \
|
||||||
@ -15,8 +16,9 @@
|
|||||||
##__VA_ARGS__); \
|
##__VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define LOG_INFO(fmt, ...) _LOG(COLOR_GREEN, "I", fmt, ##__VA_ARGS__)
|
#define LOG_DEBUG(fmt, ...) _LOG(COLOR_GRAY, "D", fmt, ##__VA_ARGS__)
|
||||||
#define LOG_WARN(fmt, ...) _LOG(COLOR_YELLOW, "W", fmt, ##__VA_ARGS__)
|
#define LOG_INFO(fmt, ...) _LOG(COLOR_GREEN, "I", fmt, ##__VA_ARGS__)
|
||||||
#define LOG_ERR(fmt, ...) _LOG(COLOR_RED, "E", fmt, ##__VA_ARGS__)
|
#define LOG_WARN(fmt, ...) _LOG(COLOR_YELLOW, "W", fmt, ##__VA_ARGS__)
|
||||||
|
#define LOG_ERR(fmt, ...) _LOG(COLOR_RED, "E", fmt, ##__VA_ARGS__)
|
||||||
|
|
||||||
#endif // WOJ_SANDBOX_LOG_H
|
#endif // WOJ_SANDBOX_LOG_H
|
||||||
|
Loading…
Reference in New Issue
Block a user