1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-09-19 10:10:40 +03:00

Avoid using hardcoded paths in log file enumeration

Hardcoded paths are used in log file enumeration such as LogFileList
command or GenerateEraseFileList function to delete old log files when
disk free space is lacking.

Fixes: SoftEtherVPN/SoftEtherVPN#972
This commit is contained in:
Koichiro IWAO 2019-09-13 09:51:20 +09:00
parent 9e46402e6b
commit 21e3ce104b
3 changed files with 25 additions and 20 deletions

View File

@ -434,19 +434,23 @@
#define LOG_ENGINE_BUFFER_CACHE_SIZE_MAX (10 * 1024 * 1024) // Write cache size
// Constant such as a file name
#define SERVER_LOG_DIR_NAME "@server_log"
#define SERVER_LOG_DIR "server_log"
#define SERVER_LOG_DIR_NAME "@"SERVER_LOG_DIR
#define BRIDGE_LOG_DIR_NAME SERVER_LOG_DIR_NAME
#define SERVER_LOG_PERFIX "vpn"
#define HUB_SECURITY_LOG_DIR_NAME "@security_log"
#define HUB_SECURITY_LOG_FILE_NAME "@security_log/%s"
#define HUB_SECURITY_LOG_DIR "security_log"
#define HUB_SECURITY_LOG_DIR_NAME "@"HUB_SECURITY_LOG_DIR
#define HUB_SECURITY_LOG_FILE_NAME HUB_SECURITY_LOG_DIR_NAME"/%s"
#define HUB_SECURITY_LOG_PREFIX "sec"
#define HUB_PACKET_LOG_DIR_NAME "@packet_log"
#define HUB_PACKET_LOG_FILE_NAME "@packet_log/%s"
#define HUB_PACKET_LOG_DIR "packet_log"
#define HUB_PACKET_LOG_DIR_NAME "@"HUB_PACKET_LOG_DIR
#define HUB_PACKET_LOG_FILE_NAME HUB_PACKET_LOG_DIR_NAME"/%s"
#define HUB_PACKET_LOG_PREFIX "pkt"
#define NAT_LOG_DIR_NAME "@secure_nat_log"
#define NAT_LOG_FILE_NAME "@secure_nat_log/%s"
#define NAT_LOG_DIR "secure_nat_log"
#define NAT_LOG_DIR_NAME "@"NAT_LOG_DIR
#define NAT_LOG_FILE_NAME NAT_LOG_DIR_NAME"/%s"
#define NAT_LOG_PREFIX "snat"
#define CLIENT_LOG_DIR_NAME "@client_log"
@ -567,8 +571,9 @@
#define EL_ADMIN_PORT 22888
#define EL_CONFIG_FILENAME "@etherlogger.config"
#define EL_PACKET_LOG_DIR_NAME "@etherlogger_log"
#define EL_PACKET_LOG_FILE_NAME "@etherlogger_log/%s"
#define EL_PACKET_LOG_DIR "etherlogger_log"
#define EL_PACKET_LOG_DIR_NAME "@"EL_PACKET_LOG_DIR
#define EL_PACKET_LOG_FILE_NAME EL_PACKET_LOG_DIR_NAME"/%s"
#define EL_PACKET_LOG_PREFIX "pkt"
#define EL_LICENSE_CHECK_SPAN (10 * 1000)

View File

@ -14,11 +14,11 @@ static char *delete_targets[] =
"backup.vpn_server.config",
"backup.vpn_gate_svc.config",
"backup.etherlogger.config",
"packet_log",
"etherlogger_log",
HUB_PACKET_LOG_DIR,
EL_PACKET_LOG_DIR,
"secure_nat_log",
"security_log",
"server_log",
HUB_SECURITY_LOG_DIR,
SERVER_LOG_DIR,
"bridge_log",
"packet_log_archive",
"azure_log",

View File

@ -969,11 +969,11 @@ LIST *EnumLogFile(char *hubname)
// Enumerate in the server_log
if (hubname == NULL)
{
EnumLogFileDir(o, "server_log");
EnumLogFileDir(o, SERVER_LOG_DIR);
}
// Enumerate in the packet_log
Format(tmp, sizeof(tmp), "%s/packet_log", exe_dir);
Format(tmp, sizeof(tmp), "%s/"HUB_PACKET_LOG_DIR, exe_dir);
if (hubname == NULL)
{
@ -988,7 +988,7 @@ LIST *EnumLogFile(char *hubname)
if (e->Folder)
{
char dir_name[MAX_PATH];
Format(dir_name, sizeof(dir_name), "packet_log/%s", e->FileName);
Format(dir_name, sizeof(dir_name), HUB_PACKET_LOG_DIR"/%s", e->FileName);
EnumLogFileDir(o, dir_name);
}
}
@ -1000,13 +1000,13 @@ LIST *EnumLogFile(char *hubname)
{
char dir_name[MAX_PATH];
Format(dir_name, sizeof(dir_name), "packet_log/%s", hubname);
Format(dir_name, sizeof(dir_name), HUB_PACKET_LOG_DIR"/%s", hubname);
EnumLogFileDir(o, dir_name);
}
// Enumerate in the security_log
Format(tmp, sizeof(tmp), "%s/security_log", exe_dir);
Format(tmp, sizeof(tmp), "%s/"HUB_SECURITY_LOG_DIR, exe_dir);
if (hubname == NULL)
{
@ -1022,7 +1022,7 @@ LIST *EnumLogFile(char *hubname)
{
char dir_name[MAX_PATH];
Format(dir_name, sizeof(dir_name), "security_log/%s", e->FileName);
Format(dir_name, sizeof(dir_name), HUB_SECURITY_LOG_DIR"/%s", e->FileName);
EnumLogFileDir(o, dir_name);
}
@ -1035,7 +1035,7 @@ LIST *EnumLogFile(char *hubname)
{
char dir_name[MAX_PATH];
Format(dir_name, sizeof(dir_name), "security_log/%s", hubname);
Format(dir_name, sizeof(dir_name), HUB_SECURITY_LOG_DIR"/%s", hubname);
EnumLogFileDir(o, dir_name);
}