From 501135ea15c90299d6ed7184f2b756bdc9e5f09a Mon Sep 17 00:00:00 2001 From: Koichiro IWAO Date: Wed, 11 Sep 2019 16:17:36 +0900 Subject: [PATCH] Use seperate logdir, dbdir and piddir, do not put them in exedir --- src/Cedar/Admin.c | 2 +- src/Cedar/Cedar.h | 4 ++-- src/Cedar/Client.h | 4 ++-- src/Cedar/Logging.c | 2 +- src/Cedar/Nat.h | 2 +- src/Cedar/Protocol.c | 4 ++-- src/Cedar/Server.c | 16 ++++++++-------- src/Cedar/Server.h | 2 +- src/Mayaqua/Cfg.c | 6 +++--- src/Mayaqua/Cfg.h | 2 +- src/Mayaqua/FileIO.c | 40 ++++++++++++++++++++++++++++++++++++++-- src/Mayaqua/FileIO.h | 6 ++++++ src/Mayaqua/Network.c | 2 +- src/Mayaqua/Network.h | 2 +- src/Mayaqua/Table.h | 2 +- src/Mayaqua/Unix.c | 6 +++--- 16 files changed, 72 insertions(+), 30 deletions(-) diff --git a/src/Cedar/Admin.c b/src/Cedar/Admin.c index c9714de5a..8e88ed3cc 100644 --- a/src/Cedar/Admin.c +++ b/src/Cedar/Admin.c @@ -11435,7 +11435,7 @@ void SiReadLocalLogFile(SERVER *s, char *filepath, UINT offset, RPC_READ_LOG_FIL Zero(t, sizeof(RPC_READ_LOG_FILE)); - GetExeDir(exe_dir, sizeof(exe_dir)); + GetLogDir(exe_dir, sizeof(exe_dir)); Format(full_path, sizeof(full_path), "%s/%s", exe_dir, filepath); // Read file diff --git a/src/Cedar/Cedar.h b/src/Cedar/Cedar.h index b5ad275e0..bd9b8975e 100644 --- a/src/Cedar/Cedar.h +++ b/src/Cedar/Cedar.h @@ -516,7 +516,7 @@ // Expiration date of random size cache #define RAND_SIZE_CACHE_EXPIRE (24 * 60 * 60 * 1000) // Management allowed IP address list file name -#define ADMINIP_TXT "@adminip.txt" +#define ADMINIP_TXT "$adminip.txt" #define NON_SSL_MIN_COUNT 60 #define NON_SSL_ENTRY_EXPIRES (10 * 60 * 1000) @@ -567,7 +567,7 @@ ////////////////////////////////////////////////////////////////////// #define EL_ADMIN_PORT 22888 -#define EL_CONFIG_FILENAME "@etherlogger.config" +#define EL_CONFIG_FILENAME "$etherlogger.config" #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" diff --git a/src/Cedar/Client.h b/src/Cedar/Client.h index c5dde36fd..0ddfbf7c3 100644 --- a/src/Cedar/Client.h +++ b/src/Cedar/Client.h @@ -19,7 +19,7 @@ // Constants -#define CLIENT_CONFIG_FILE_NAME "@vpn_client.config" +#define CLIENT_CONFIG_FILE_NAME "$vpn_client.config" #define CLIENT_DEFAULT_KEEPALIVE_HOST "keepalive.softether.org" #define CLIENT_DEFAULT_KEEPALIVE_PORT 80 #define CLIENT_DEFAULT_KEEPALIVE_INTERVAL KEEP_INTERVAL_DEFAULT @@ -39,7 +39,7 @@ #define CLIENT_WIN32_EXE_FILENAME_X64 "vpnclient_x64.exe" #define CLIENT_WIN32_EXE_FILENAME_IA64 "vpnclient_ia64.exe" -#define CLIENT_CUSTOM_INI_FILENAME "@custom.ini" +#define CLIENT_CUSTOM_INI_FILENAME "$custom.ini" #define CLIENT_GLOBAL_PULSE_NAME "clientglobalpulse" diff --git a/src/Cedar/Logging.c b/src/Cedar/Logging.c index 1df57ce44..1ab8964c3 100644 --- a/src/Cedar/Logging.c +++ b/src/Cedar/Logging.c @@ -419,7 +419,7 @@ ERASER *NewEraser(LOG *log, UINT64 min_size) e = ZeroMalloc(sizeof(ERASER)); - GetExeDir(dir, sizeof(dir)); + GetLogDir(dir, sizeof(dir)); e->Log = log; e->MinFreeSpace = min_size; diff --git a/src/Cedar/Nat.h b/src/Cedar/Nat.h index 2cb230906..70cf601e1 100644 --- a/src/Cedar/Nat.h +++ b/src/Cedar/Nat.h @@ -9,7 +9,7 @@ #define NAT_H // Constants -#define NAT_CONFIG_FILE_NAME "@vpn_router.config" // NAT configuration file +#define NAT_CONFIG_FILE_NAME "$vpn_router.config" // NAT configuration file #define DEFAULT_NAT_ADMIN_PORT 2828 // Default port number for management #define NAT_ADMIN_PORT_LISTEN_INTERVAL 1000 // Interval for trying to open a port for management #define NAT_FILE_SAVE_INTERVAL (30 * 1000) // Interval to save diff --git a/src/Cedar/Protocol.c b/src/Cedar/Protocol.c index fce8b428f..773ef9a4a 100644 --- a/src/Cedar/Protocol.c +++ b/src/Cedar/Protocol.c @@ -57,7 +57,7 @@ bool TryGetRootCertChain(LIST *o, X *x, bool auto_save, X **found_root_x) wchar_t dirname[MAX_SIZE]; wchar_t exedir[MAX_SIZE]; - GetExeDirW(exedir, sizeof(exedir)); + GetDbDirW(exedir, sizeof(exedir)); CombinePathW(dirname, sizeof(dirname), exedir, L"chain_certs"); MakeDirExW(dirname); @@ -363,7 +363,7 @@ void AddAllChainCertsToCertList(LIST *o) return; } - GetExeDirW(exedir, sizeof(exedir)); + GetDbDirW(exedir, sizeof(exedir)); CombinePathW(dirname, sizeof(dirname), exedir, L"chain_certs"); diff --git a/src/Cedar/Server.c b/src/Cedar/Server.c index 68f000cf3..0ee48b842 100644 --- a/src/Cedar/Server.c +++ b/src/Cedar/Server.c @@ -9,12 +9,12 @@ static SERVER *server = NULL; static LOCK *server_lock = NULL; -char *SERVER_CONFIG_FILE_NAME = "@vpn_server.config"; -char *SERVER_CONFIG_FILE_NAME_IN_CLIENT = "@vpn_gate_svc.config"; -char *SERVER_CONFIG_FILE_NAME_IN_CLIENT_RELAY = "@vpn_gate_relay.config"; -char *BRIDGE_CONFIG_FILE_NAME = "@vpn_bridge.config"; -char *SERVER_CONFIG_TEMPLATE_NAME = "@vpn_server_template.config"; -char *BRIDGE_CONFIG_TEMPLATE_NAME = "@vpn_server_template.config"; +char *SERVER_CONFIG_FILE_NAME = "$vpn_server.config"; +char *SERVER_CONFIG_FILE_NAME_IN_CLIENT = "$vpn_gate_svc.config"; +char *SERVER_CONFIG_FILE_NAME_IN_CLIENT_RELAY = "$vpn_gate_relay.config"; +char *BRIDGE_CONFIG_FILE_NAME = "$vpn_bridge.config"; +char *SERVER_CONFIG_TEMPLATE_NAME = "$vpn_server_template.config"; +char *BRIDGE_CONFIG_TEMPLATE_NAME = "$vpn_server_template.config"; static bool server_reset_setting = false; @@ -964,7 +964,7 @@ LIST *EnumLogFile(char *hubname) hubname = NULL; } - GetExeDir(exe_dir, sizeof(exe_dir)); + GetLogDir(exe_dir, sizeof(exe_dir)); // Enumerate in the server_log if (hubname == NULL) @@ -1056,7 +1056,7 @@ void EnumLogFileDir(LIST *o, char *dirname) return; } - GetExeDir(exe_dir, sizeof(exe_dir)); + GetLogDir(exe_dir, sizeof(exe_dir)); Format(dir_full_path, sizeof(dir_full_path), "%s/%s", exe_dir, dirname); dir = EnumDir(dir_full_path); diff --git a/src/Cedar/Server.h b/src/Cedar/Server.h index 2c0cdba18..ab0ccc27b 100644 --- a/src/Cedar/Server.h +++ b/src/Cedar/Server.h @@ -48,7 +48,7 @@ extern char *SERVER_CONFIG_FILE_NAME; #define MAX_PUBLIC_PORT_NUM 128 -#define MEMBER_SELECTOR_TXT_FILENAME "@member_selector.config" +#define MEMBER_SELECTOR_TXT_FILENAME "$member_selector.config" #define MEMBER_SELECTOR_CONNECT_TIMEOUT 2000 #define MEMBER_SELECTOR_DATA_TIMEOUT 5000 diff --git a/src/Mayaqua/Cfg.c b/src/Mayaqua/Cfg.c index 4407ed04b..daa9ba666 100644 --- a/src/Mayaqua/Cfg.c +++ b/src/Mayaqua/Cfg.c @@ -33,12 +33,12 @@ void BackupCfgWEx(CFG_RW *rw, FOLDER *f, wchar_t *original, UINT revision_number } // Determine the directory name - UniFormat(dirname, sizeof(dirname), L"@backup.%s", original[0] == L'@' ? original + 1 : original); + UniFormat(dirname, sizeof(dirname), L"$backup.%s", original[0] == L'$' ? original + 1 : original); // Determine the file name LocalTime(&st); UniFormat(datestr, sizeof(datestr), L"%04u%02u%02u%02u_%s", - st.wYear, st.wMonth, st.wDay, st.wHour, original[0] == L'@' ? original + 1 : original); + st.wYear, st.wMonth, st.wDay, st.wHour, original[0] == L'$' ? original + 1 : original); if (revision_number == INFINITE) { @@ -47,7 +47,7 @@ void BackupCfgWEx(CFG_RW *rw, FOLDER *f, wchar_t *original, UINT revision_number else { UniFormat(filename, sizeof(filename), L"%08u_%s", - revision_number, original[0] == L'@' ? original + 1 : original); + revision_number, original[0] == L'$' ? original + 1 : original); } // Don't save if the date and time has not been changed diff --git a/src/Mayaqua/Cfg.h b/src/Mayaqua/Cfg.h index 339753d63..580cadbd1 100644 --- a/src/Mayaqua/Cfg.h +++ b/src/Mayaqua/Cfg.h @@ -11,7 +11,7 @@ // Macro //#define CHECK_CFG_NAME_EXISTS // Check duplication of the existing name -#define SAVE_BINARY_FILE_NAME_SWITCH L"@save_binary" +#define SAVE_BINARY_FILE_NAME_SWITCH L"$save_binary" // Constants #define TAG_DECLARE "declare" diff --git a/src/Mayaqua/FileIO.c b/src/Mayaqua/FileIO.c index 2868de18d..b642b5a63 100644 --- a/src/Mayaqua/FileIO.c +++ b/src/Mayaqua/FileIO.c @@ -1295,6 +1295,36 @@ void GetExeNameW(wchar_t *name, UINT size) UniStrCpy(name, size, exe_file_name_w); } +void GetLogDir(char *name, UINT size) +{ + Format(name, size, "%%SE_LOGDIR%%"); +} + +void GetLogDirW(wchar_t *name, UINT size) +{ + UniFormat(name, size, L"%%SE_LOGDIR%%"); +} + +void GetDbDir(char *name, UINT size) +{ + Format(name, size, "%%SE_DBDIR%%"); +} + +void GetDbDirW(wchar_t *name, UINT size) +{ + UniFormat(name, size, L"%%SE_DBDIR%%"); +} + +void GetPidDir(char *name, UINT size) +{ + Format(name, size, "%%SE_PIDDIR%%"); +} + +void GetPidDirW(wchar_t *name, UINT size) +{ + UniFormat(name, size, L"%%SE_PIDDIR%%"); +} + // Initialization of the acquisition of the EXE file name void InitGetExeName(char *arg) { @@ -2068,14 +2098,20 @@ void InnerFilePathW(wchar_t *dst, UINT size, wchar_t *src) return; } - if (src[0] != L'@') + if (src[0] != L'@' && src[0] != L'$') { NormalizePathW(dst, size, src); } + else if (src[0] == L'$') + { + wchar_t dir[MAX_SIZE]; + GetDbDirW(dir, sizeof(dir)); + ConbinePathW(dst, size, dir, &src[1]); + } else { wchar_t dir[MAX_SIZE]; - GetExeDirW(dir, sizeof(dir)); + GetLogDirW(dir, sizeof(dir)); ConbinePathW(dst, size, dir, &src[1]); } } diff --git a/src/Mayaqua/FileIO.h b/src/Mayaqua/FileIO.h index 436aabe7d..3233ce00b 100644 --- a/src/Mayaqua/FileIO.h +++ b/src/Mayaqua/FileIO.h @@ -228,6 +228,12 @@ void GetExeName(char *name, UINT size); void GetExeNameW(wchar_t *name, UINT size); void GetExeDir(char *name, UINT size); void GetExeDirW(wchar_t *name, UINT size); +void GetLogDir(char *name, UINT size); +void GetLogDirW(wchar_t *name, UINT size); +void GetDbDir(char *name, UINT size); +void GetDbDirW(wchar_t *name, UINT size); +void GetPidDir(char *name, UINT size); +void GetPidDirW(wchar_t *name, UINT size); void BuildHamcore(char *dst_filename, char *src_dir, bool unix_only); int CompareHamcore(void *p1, void *p2); void InitHamcore(); diff --git a/src/Mayaqua/Network.c b/src/Mayaqua/Network.c index 6e5bddafd..9649ff0cb 100644 --- a/src/Mayaqua/Network.c +++ b/src/Mayaqua/Network.c @@ -11697,7 +11697,7 @@ void AddChainSslCertOnDirectory(struct ssl_ctx_st *ctx) o = NewListFast(NULL); - GetExeDirW(exedir, sizeof(exedir)); + GetDbDirW(exedir, sizeof(exedir)); CombinePathW(dirname, sizeof(dirname), exedir, L"chain_certs"); diff --git a/src/Mayaqua/Network.h b/src/Mayaqua/Network.h index 44351d5cf..ef1d208d6 100644 --- a/src/Mayaqua/Network.h +++ b/src/Mayaqua/Network.h @@ -54,7 +54,7 @@ struct DYN_VALUE #define SSL_LOGGING_DIRNAME "@ssl_log" // Private IP list file -#define PRIVATE_IP_TXT_FILENAME "@private_ip.txt" +#define PRIVATE_IP_TXT_FILENAME "$private_ip.txt" // Start range of the random UDP port #define RAND_UDP_PORT_START 5000 diff --git a/src/Mayaqua/Table.h b/src/Mayaqua/Table.h index 17bf569f0..84cb8fe67 100644 --- a/src/Mayaqua/Table.h +++ b/src/Mayaqua/Table.h @@ -13,7 +13,7 @@ #define LANGLIST_FILENAME "|languages.txt" #define LANGLIST_FILENAME_WINE "|languages_wine.txt" -#define LANG_CONFIG_FILENAME L"@lang.config" +#define LANG_CONFIG_FILENAME L"$lang.config" #define LANG_CONFIG_TEMPLETE "|lang.config" // Language constant diff --git a/src/Mayaqua/Unix.c b/src/Mayaqua/Unix.c index ca766a23a..e4479f657 100755 --- a/src/Mayaqua/Unix.c +++ b/src/Mayaqua/Unix.c @@ -771,7 +771,7 @@ void *UnixNewSingleInstance(char *instance_name) StrCpy(tmp, sizeof(tmp), instance_name); } - GetExeDir(dir, sizeof(dir)); + GetPidDir(dir, sizeof(dir)); // File name generation Format(name, sizeof(name), "%s/.%s", dir, tmp); @@ -2185,7 +2185,7 @@ void UnixGenPidFileName(char *name, UINT size) return; } - GetExeDir(dir, sizeof(dir)); + GetPidDir(dir, sizeof(dir)); GetExeName(exe_name, sizeof(exe_name)); StrCat(exe_name, sizeof(exe_name), ":pid_hash"); @@ -2230,7 +2230,7 @@ void UnixGenCtlFileName(char *name, UINT size) return; } - GetExeDir(dir, sizeof(dir)); + GetPidDir(dir, sizeof(dir)); GetExeName(exe_name, sizeof(exe_name)); StrCat(exe_name, sizeof(exe_name), ":pid_hash");