56 lines
1.4 KiB
C
56 lines
1.4 KiB
C
#ifndef EXEC_HOOK_H
|
||
#define EXEC_HOOK_H
|
||
|
||
#define _GNU_SOURCE
|
||
#include <dlfcn.h>
|
||
#include <errno.h>
|
||
#include <fcntl.h>
|
||
#include <pty.h>
|
||
#include <signal.h>
|
||
#include <stdbool.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <string.h>
|
||
#include <sys/ipc.h>
|
||
#include <sys/select.h>
|
||
#include <sys/shm.h>
|
||
#include <sys/stat.h>
|
||
#include <time.h>
|
||
#include <unistd.h>
|
||
|
||
#include "struct.h"
|
||
|
||
#define COMMAND_NOT_FOUND "/usr/lib/command-not-found"
|
||
|
||
#ifdef DEBUG // 如果是debug模式,在本地目录生成log,方便debug
|
||
|
||
#define LOG_FILE "./logs/execve.log"
|
||
#define LOG_OUT_FILE "./logs/execve_out.log"
|
||
|
||
#else
|
||
|
||
#define CONFIG_FILE ""
|
||
#define LOG_FILE "/tmp/exec_hook/logs/execve.log"
|
||
#define LOG_OUT_FILE "/tmp/exec_hook/logs/execve_out.log"
|
||
|
||
#endif
|
||
|
||
#define MAX_PATH_LEN 256
|
||
|
||
#define GET_LOG_FILE(c_pid, is_stdout) \
|
||
({ \
|
||
static char filename[MAX_PATH_LEN]; \
|
||
snprintf(filename, MAX_PATH_LEN, "%s.%ld.%s", LOG_OUT_FILE, \
|
||
(long)c_pid, (is_stdout) ? "stdout" : "stderr"); \
|
||
filename; \
|
||
})
|
||
|
||
#define ANSI_COLOR_RED "\033[31m"
|
||
#define ANSI_COLOR_YELLOW "\033[33m"
|
||
#define ANSI_COLOR_RESET "\033[0m"
|
||
#define ANSI_COLOR_BLUE "\x1b[34m"
|
||
|
||
#define SHM_KEY 0x78945
|
||
#define SHM_SIZE 512 * 1024
|
||
|
||
#endif // EXEC_HOOK_H
|