mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2024-11-25 10:59:53 +03:00
Use FHS installation directories.
Install to `/usr/sbin`, `/usr/lib`, and `/var/lib` according to the Linux filesystem hierarchy standard if SoftEther is built through autotools. In a managed installation, the FHS stipulates that the application must accomodate a read-only installation path. This requires a new `GetStateDir` function that substitues `GetExeDir` in some parts of the code.
This commit is contained in:
parent
75625af541
commit
b9420c3bfc
@ -27,6 +27,7 @@ AM_CFLAGS = \
|
|||||||
-I$(top_srcdir)/src \
|
-I$(top_srcdir)/src \
|
||||||
-I$(top_srcdir)/src/Mayaqua \
|
-I$(top_srcdir)/src/Mayaqua \
|
||||||
-I$(top_srcdir)/src/Cedar \
|
-I$(top_srcdir)/src/Cedar \
|
||||||
|
-DSTATE_DIR='"@localstatedir@/lib/softether"' \
|
||||||
-DUNIX \
|
-DUNIX \
|
||||||
-DUNIX_LINUX \
|
-DUNIX_LINUX \
|
||||||
-D_REENTRANT \
|
-D_REENTRANT \
|
||||||
|
@ -10338,7 +10338,7 @@ void SiReadLocalLogFile(SERVER *s, char *filepath, UINT offset, RPC_READ_LOG_FIL
|
|||||||
|
|
||||||
Zero(t, sizeof(RPC_READ_LOG_FILE));
|
Zero(t, sizeof(RPC_READ_LOG_FILE));
|
||||||
|
|
||||||
GetExeDir(exe_dir, sizeof(exe_dir));
|
GetStateDir(exe_dir, sizeof(exe_dir));
|
||||||
Format(full_path, sizeof(full_path), "%s/%s", exe_dir, filepath);
|
Format(full_path, sizeof(full_path), "%s/%s", exe_dir, filepath);
|
||||||
|
|
||||||
// Read file
|
// Read file
|
||||||
|
@ -527,7 +527,7 @@ bool CheckFileSystem()
|
|||||||
UINT i;
|
UINT i;
|
||||||
|
|
||||||
GetExeName(exe, sizeof(exe));
|
GetExeName(exe, sizeof(exe));
|
||||||
GetExeDir(exe_dir, sizeof(exe_dir));
|
GetStateDir(exe_dir, sizeof(exe_dir));
|
||||||
|
|
||||||
ok = false;
|
ok = false;
|
||||||
dirs = EnumDir(exe_dir);
|
dirs = EnumDir(exe_dir);
|
||||||
@ -552,7 +552,11 @@ bool CheckFileSystem()
|
|||||||
UCHAR *buf;
|
UCHAR *buf;
|
||||||
IO *io;
|
IO *io;
|
||||||
#ifndef OS_WIN32
|
#ifndef OS_WIN32
|
||||||
|
#ifdef STATE_DIR
|
||||||
|
wchar_t *filename = L"" STATE_DIR L"/vpn_checker_tmp";
|
||||||
|
#else
|
||||||
wchar_t *filename = L"/tmp/vpn_checker_tmp";
|
wchar_t *filename = L"/tmp/vpn_checker_tmp";
|
||||||
|
#endif
|
||||||
#else // OS_WIN32
|
#else // OS_WIN32
|
||||||
wchar_t filename[MAX_PATH];
|
wchar_t filename[MAX_PATH];
|
||||||
CombinePathW(filename, sizeof(filename), MsGetMyTempDirW(), L"vpn_checker_tmp");
|
CombinePathW(filename, sizeof(filename), MsGetMyTempDirW(), L"vpn_checker_tmp");
|
||||||
|
@ -538,7 +538,7 @@ ERASER *NewEraser(LOG *log, UINT64 min_size)
|
|||||||
|
|
||||||
e = ZeroMalloc(sizeof(ERASER));
|
e = ZeroMalloc(sizeof(ERASER));
|
||||||
|
|
||||||
GetExeDir(dir, sizeof(dir));
|
GetStateDir(dir, sizeof(dir));
|
||||||
|
|
||||||
e->Log = log;
|
e->Log = log;
|
||||||
e->MinFreeSpace = min_size;
|
e->MinFreeSpace = min_size;
|
||||||
|
@ -1087,7 +1087,7 @@ LIST *EnumLogFile(char *hubname)
|
|||||||
hubname = NULL;
|
hubname = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetExeDir(exe_dir, sizeof(exe_dir));
|
GetStateDir(exe_dir, sizeof(exe_dir));
|
||||||
|
|
||||||
// Enumerate in the server_log
|
// Enumerate in the server_log
|
||||||
if (hubname == NULL)
|
if (hubname == NULL)
|
||||||
@ -1161,7 +1161,7 @@ void EnumLogFileDir(LIST *o, char *dirname)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetExeDir(exe_dir, sizeof(exe_dir));
|
GetStateDir(exe_dir, sizeof(exe_dir));
|
||||||
Format(dir_full_path, sizeof(dir_full_path), "%s/%s", exe_dir, dirname);
|
Format(dir_full_path, sizeof(dir_full_path), "%s/%s", exe_dir, dirname);
|
||||||
|
|
||||||
dir = EnumDir(dir_full_path);
|
dir = EnumDir(dir_full_path);
|
||||||
|
@ -579,7 +579,7 @@ bool IsXRevoked(X *x)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetExeDir(dirname, sizeof(dirname));
|
GetStateDir(dirname, sizeof(dirname));
|
||||||
|
|
||||||
// Search the CRL file
|
// Search the CRL file
|
||||||
t = EnumDir(dirname);
|
t = EnumDir(dirname);
|
||||||
|
@ -122,8 +122,14 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <Mayaqua/Mayaqua.h>
|
#include <Mayaqua/Mayaqua.h>
|
||||||
|
|
||||||
|
#ifdef STATE_DIR
|
||||||
|
static char exe_file_name[MAX_SIZE] = STATE_DIR "/a.out";
|
||||||
|
static wchar_t exe_file_name_w[MAX_SIZE] = L"" STATE_DIR L"/a.out";
|
||||||
|
#else
|
||||||
static char exe_file_name[MAX_SIZE] = "/tmp/a.out";
|
static char exe_file_name[MAX_SIZE] = "/tmp/a.out";
|
||||||
static wchar_t exe_file_name_w[MAX_SIZE] = L"/tmp/a.out";
|
static wchar_t exe_file_name_w[MAX_SIZE] = L"/tmp/a.out";
|
||||||
|
#endif
|
||||||
|
|
||||||
static LIST *hamcore = NULL;
|
static LIST *hamcore = NULL;
|
||||||
static IO *hamcore_io = NULL;
|
static IO *hamcore_io = NULL;
|
||||||
|
|
||||||
@ -1038,7 +1044,7 @@ BUF *ReadHamcore(char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the file exist in hamcore/ directory on the local disk, read it
|
// If the file exist in hamcore/ directory on the local disk, read it
|
||||||
GetExeDirW(exe_dir, sizeof(exe_dir));
|
GetStateDirW(exe_dir, sizeof(exe_dir));
|
||||||
|
|
||||||
UniFormat(tmp, sizeof(tmp), L"%s/%S/%S", exe_dir, HAMCORE_DIR_NAME, filename);
|
UniFormat(tmp, sizeof(tmp), L"%s/%S/%S", exe_dir, HAMCORE_DIR_NAME, filename);
|
||||||
|
|
||||||
@ -1154,7 +1160,7 @@ void InitHamcore()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetExeDirW(exe_dir, sizeof(exe_dir));
|
GetStateDirW(exe_dir, sizeof(exe_dir));
|
||||||
UniFormat(tmp, sizeof(tmp), L"%s/%S", exe_dir, HAMCORE_FILE_NAME);
|
UniFormat(tmp, sizeof(tmp), L"%s/%S", exe_dir, HAMCORE_FILE_NAME);
|
||||||
|
|
||||||
UniFormat(tmp2, sizeof(tmp2), L"%s/%S", exe_dir, HAMCORE_FILE_NAME_2);
|
UniFormat(tmp2, sizeof(tmp2), L"%s/%S", exe_dir, HAMCORE_FILE_NAME_2);
|
||||||
@ -1438,6 +1444,33 @@ void GetExeDirW(wchar_t *name, UINT size)
|
|||||||
GetDirNameFromFilePathW(name, size, exe_file_name_w);
|
GetDirNameFromFilePathW(name, size, exe_file_name_w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GetStateDir(char *name, UINT size)
|
||||||
|
{
|
||||||
|
// Validate arguments
|
||||||
|
if (name == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#ifdef STATE_DIR
|
||||||
|
StrCpy(name, size, STATE_DIR);
|
||||||
|
#else
|
||||||
|
GetExeDir(name, size)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
void GetStateDirW(wchar_t *name, UINT size)
|
||||||
|
{
|
||||||
|
// Validate arguments
|
||||||
|
if (name == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#ifdef STATE_DIR
|
||||||
|
UniStrCpy(name, size, L"" STATE_DIR L"");
|
||||||
|
#else
|
||||||
|
GetExeDirW(name, size)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Get the EXE file name
|
// Get the EXE file name
|
||||||
void GetExeName(char *name, UINT size)
|
void GetExeName(char *name, UINT size)
|
||||||
{
|
{
|
||||||
@ -2389,7 +2422,7 @@ void InnerFilePathW(wchar_t *dst, UINT size, wchar_t *src)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
wchar_t dir[MAX_SIZE];
|
wchar_t dir[MAX_SIZE];
|
||||||
GetExeDirW(dir, sizeof(dir));
|
GetStateDirW(dir, sizeof(dir));
|
||||||
ConbinePathW(dst, size, dir, &src[1]);
|
ConbinePathW(dst, size, dir, &src[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,6 +349,8 @@ void GetExeName(char *name, UINT size);
|
|||||||
void GetExeNameW(wchar_t *name, UINT size);
|
void GetExeNameW(wchar_t *name, UINT size);
|
||||||
void GetExeDir(char *name, UINT size);
|
void GetExeDir(char *name, UINT size);
|
||||||
void GetExeDirW(wchar_t *name, UINT size);
|
void GetExeDirW(wchar_t *name, UINT size);
|
||||||
|
void GetStateDir(char *name, UINT size);
|
||||||
|
void GetStateDirW(wchar_t *name, UINT size);
|
||||||
void BuildHamcore(char *dst_filename, char *src_dir, bool unix_only);
|
void BuildHamcore(char *dst_filename, char *src_dir, bool unix_only);
|
||||||
int CompareHamcore(void *p1, void *p2);
|
int CompareHamcore(void *p1, void *p2);
|
||||||
void InitHamcore();
|
void InitHamcore();
|
||||||
|
@ -611,7 +611,11 @@ void InitMayaqua(bool memcheck, bool debug, int argc, char **argv)
|
|||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef STATE_DIR
|
||||||
|
// This check causes hamcorebuilder to fail in an unprivileged
|
||||||
|
// environment, and is unnecessary for a managed installation.
|
||||||
CheckUnixTempDir();
|
CheckUnixTempDir();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Initialization of Probe
|
// Initialization of Probe
|
||||||
InitProbe();
|
InitProbe();
|
||||||
|
@ -1191,7 +1191,7 @@ void GenerateUnicodeCacheFileName(wchar_t *name, UINT size, wchar_t *strfilename
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetExeDirW(exe, sizeof(exe));
|
GetStateDirW(exe, sizeof(exe));
|
||||||
UniStrCpy(hashtemp, sizeof(hashtemp), strfilename);
|
UniStrCpy(hashtemp, sizeof(hashtemp), strfilename);
|
||||||
BinToStrW(tmp, sizeof(tmp), filehash, MD5_SIZE);
|
BinToStrW(tmp, sizeof(tmp), filehash, MD5_SIZE);
|
||||||
UniStrCat(hashtemp, sizeof(hashtemp), tmp);
|
UniStrCat(hashtemp, sizeof(hashtemp), tmp);
|
||||||
@ -1204,7 +1204,11 @@ void GenerateUnicodeCacheFileName(wchar_t *name, UINT size, wchar_t *strfilename
|
|||||||
UniStrLower(tmp);
|
UniStrLower(tmp);
|
||||||
|
|
||||||
#ifndef OS_WIN32
|
#ifndef OS_WIN32
|
||||||
|
#ifdef STATE_DIR
|
||||||
|
UniStrCpy(exe, sizeof(exe), L"" STATE_DIR L"");
|
||||||
|
#else
|
||||||
UniStrCpy(exe, sizeof(exe), L"/tmp");
|
UniStrCpy(exe, sizeof(exe), L"/tmp");
|
||||||
|
#endif
|
||||||
#else // OS_WIN32
|
#else // OS_WIN32
|
||||||
StrToUni(exe, sizeof(exe), MsGetTempDir());
|
StrToUni(exe, sizeof(exe), MsGetTempDir());
|
||||||
#endif // OS_WIN32
|
#endif // OS_WIN32
|
||||||
|
@ -928,7 +928,7 @@ void *UnixNewSingleInstance(char *instance_name)
|
|||||||
StrCpy(tmp, sizeof(tmp), instance_name);
|
StrCpy(tmp, sizeof(tmp), instance_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetExeDir(dir, sizeof(dir));
|
GetStateDir(dir, sizeof(dir));
|
||||||
|
|
||||||
// File name generation
|
// File name generation
|
||||||
Format(name, sizeof(name), "%s/.%s", dir, tmp);
|
Format(name, sizeof(name), "%s/.%s", dir, tmp);
|
||||||
@ -2311,7 +2311,7 @@ void UnixGenPidFileName(char *name, UINT size)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetExeDir(dir, sizeof(dir));
|
GetStateDir(dir, sizeof(dir));
|
||||||
|
|
||||||
GetExeName(exe_name, sizeof(exe_name));
|
GetExeName(exe_name, sizeof(exe_name));
|
||||||
StrCat(exe_name, sizeof(exe_name), ":pid_hash");
|
StrCat(exe_name, sizeof(exe_name), ":pid_hash");
|
||||||
@ -2356,7 +2356,7 @@ void UnixGenCtlFileName(char *name, UINT size)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetExeDir(dir, sizeof(dir));
|
GetStateDir(dir, sizeof(dir));
|
||||||
|
|
||||||
GetExeName(exe_name, sizeof(exe_name));
|
GetExeName(exe_name, sizeof(exe_name));
|
||||||
StrCat(exe_name, sizeof(exe_name), ":pid_hash");
|
StrCat(exe_name, sizeof(exe_name), ":pid_hash");
|
||||||
|
@ -18,12 +18,16 @@
|
|||||||
|
|
||||||
include $(top_srcdir)/autotools/softether.am
|
include $(top_srcdir)/autotools/softether.am
|
||||||
|
|
||||||
# This is required to use a custom build rule with -Wall and -Werror enabled.
|
# An empty EXEEXT required for overrides with -Wall and -Werror enabled.
|
||||||
AUTOMAKE_OPTIONS = -Wno-override
|
AUTOMAKE_OPTIONS = -Wno-override
|
||||||
EXEEXT =
|
EXEEXT =
|
||||||
|
|
||||||
HAMCOREBUILDER = $(top_builddir)/src/hamcorebuilder/hamcorebuilder
|
HAMCOREBUILDER = $(top_builddir)/src/hamcorebuilder/hamcorebuilder
|
||||||
|
|
||||||
sbin_PROGRAMS = hamcore.se2
|
noinst_PROGRAMS = hamcore.se2
|
||||||
|
|
||||||
hamcore.se2$(EXEEXT): $(HAMCOREBUILDER)
|
hamcore.se2$(EXEEXT): $(HAMCOREBUILDER)
|
||||||
$(HAMCOREBUILDER) $(top_srcdir)/src/bin/hamcore $@
|
$(HAMCOREBUILDER) $(top_srcdir)/src/bin/hamcore $@
|
||||||
|
|
||||||
|
install-exec-local: hamcore.se2$(EXEEXT)
|
||||||
|
$(INSTALL_DATA) -D hamcore.se2$(EXEEXT) $(DESTDIR)$(localstatedir)/lib/softether/hamcore.se2
|
||||||
|
Loading…
Reference in New Issue
Block a user