6b13f685e
김민수
BSP 최초 추가
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
|
From b9420c3bfc2a8b9d35d0c8e5f6849007c2bc21fa Mon Sep 17 00:00:00 2001
From: Darik Horn <dajhorn@vanadac.com>
Date: Mon, 14 Apr 2014 13:22:24 -0400
Subject: [PATCH] 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.
Taken from Github at
https://github.com/dajhorn/SoftEtherVPN/commit/b9420c3bfc2a8b9d35d0c8e5f6849007c2bc21fa.
Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
autotools/softether.am | 1 +
src/Cedar/Admin.c | 2 +-
src/Cedar/Command.c | 6 +++++-
src/Cedar/Logging.c | 2 +-
src/Cedar/Server.c | 4 ++--
src/Mayaqua/Encrypt.c | 2 +-
src/Mayaqua/FileIO.c | 39 ++++++++++++++++++++++++++++++++++++---
src/Mayaqua/FileIO.h | 2 ++
src/Mayaqua/Mayaqua.c | 4 ++++
src/Mayaqua/Table.c | 6 +++++-
src/Mayaqua/Unix.c | 6 +++---
src/bin/hamcore/Makefile.am | 8 ++++++--
12 files changed, 67 insertions(+), 15 deletions(-)
Index: b/autotools/softether.am
===================================================================
--- a/autotools/softether.am
+++ b/autotools/softether.am
@@ -27,6 +27,7 @@
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/Mayaqua \
-I$(top_srcdir)/src/Cedar \
+ -DSTATE_DIR='"@localstatedir@/lib/softether"' \
-DUNIX \
-DUNIX_LINUX \
-D_REENTRANT \
Index: b/src/Cedar/Admin.c
===================================================================
--- a/src/Cedar/Admin.c
+++ b/src/Cedar/Admin.c
@@ -10334,7 +10334,7 @@
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);
// Read file
Index: b/src/Cedar/Command.c
===================================================================
--- a/src/Cedar/Command.c
+++ b/src/Cedar/Command.c
@@ -527,7 +527,7 @@
UINT i;
GetExeName(exe, sizeof(exe));
- GetExeDir(exe_dir, sizeof(exe_dir));
+ GetStateDir(exe_dir, sizeof(exe_dir));
ok = false;
dirs = EnumDir(exe_dir);
@@ -552,7 +552,11 @@
UCHAR *buf;
IO *io;
#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";
+#endif
#else // OS_WIN32
wchar_t filename[MAX_PATH];
CombinePathW(filename, sizeof(filename), MsGetMyTempDirW(), L"vpn_checker_tmp");
Index: b/src/Cedar/Logging.c
===================================================================
--- a/src/Cedar/Logging.c
+++ b/src/Cedar/Logging.c
@@ -508,7 +508,7 @@
e = ZeroMalloc(sizeof(ERASER));
- GetExeDir(dir, sizeof(dir));
+ GetStateDir(dir, sizeof(dir));
e->Log = log;
e->MinFreeSpace = min_size;
Index: b/src/Cedar/Server.c
===================================================================
--- a/src/Cedar/Server.c
+++ b/src/Cedar/Server.c
@@ -1060,7 +1060,7 @@
hubname = NULL;
}
- GetExeDir(exe_dir, sizeof(exe_dir));
+ GetStateDir(exe_dir, sizeof(exe_dir));
// Enumerate in the server_log
if (hubname == NULL)
@@ -1134,7 +1134,7 @@
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);
dir = EnumDir(dir_full_path);
Index: b/src/Mayaqua/Encrypt.c
===================================================================
--- a/src/Mayaqua/Encrypt.c
+++ b/src/Mayaqua/Encrypt.c
@@ -579,7 +579,7 @@
return false;
}
- GetExeDir(dirname, sizeof(dirname));
+ GetStateDir(dirname, sizeof(dirname));
// Search the CRL file
t = EnumDir(dirname);
Index: b/src/Mayaqua/FileIO.c
===================================================================
--- a/src/Mayaqua/FileIO.c
+++ b/src/Mayaqua/FileIO.c
@@ -122,8 +122,14 @@
#include <errno.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 wchar_t exe_file_name_w[MAX_SIZE] = L"/tmp/a.out";
+#endif
+
static LIST *hamcore = NULL;
static IO *hamcore_io = NULL;
@@ -1038,7 +1044,7 @@
}
// 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);
@@ -1154,7 +1160,7 @@
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(tmp2, sizeof(tmp2), L"%s/%S", exe_dir, HAMCORE_FILE_NAME_2);
@@ -1438,6 +1444,33 @@
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
void GetExeName(char *name, UINT size)
{
@@ -2389,7 +2422,7 @@
else
{
wchar_t dir[MAX_SIZE];
- GetExeDirW(dir, sizeof(dir));
+ GetStateDirW(dir, sizeof(dir));
ConbinePathW(dst, size, dir, &src[1]);
}
}
Index: b/src/Mayaqua/FileIO.h
===================================================================
--- a/src/Mayaqua/FileIO.h
+++ b/src/Mayaqua/FileIO.h
@@ -349,6 +349,8 @@
void GetExeNameW(wchar_t *name, UINT size);
void GetExeDir(char *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);
int CompareHamcore(void *p1, void *p2);
void InitHamcore();
Index: b/src/Mayaqua/Mayaqua.c
===================================================================
--- a/src/Mayaqua/Mayaqua.c
+++ b/src/Mayaqua/Mayaqua.c
@@ -611,7 +611,11 @@
_exit(0);
}
+#ifndef STATE_DIR
+ // This check causes hamcorebuilder to fail in an unprivileged
+ // environment, and is unnecessary for a managed installation.
CheckUnixTempDir();
+#endif
// Initialization of Probe
InitProbe();
Index: b/src/Mayaqua/Table.c
===================================================================
--- a/src/Mayaqua/Table.c
+++ b/src/Mayaqua/Table.c
@@ -1191,7 +1191,7 @@
return;
}
- GetExeDirW(exe, sizeof(exe));
+ GetStateDirW(exe, sizeof(exe));
UniStrCpy(hashtemp, sizeof(hashtemp), strfilename);
BinToStrW(tmp, sizeof(tmp), filehash, MD5_SIZE);
UniStrCat(hashtemp, sizeof(hashtemp), tmp);
@@ -1204,7 +1204,11 @@
UniStrLower(tmp);
#ifndef OS_WIN32
+#ifdef STATE_DIR
+ UniStrCpy(exe, sizeof(exe), L"" STATE_DIR L"");
+#else
UniStrCpy(exe, sizeof(exe), L"/tmp");
+#endif
#else // OS_WIN32
StrToUni(exe, sizeof(exe), MsGetTempDir());
#endif // OS_WIN32
Index: b/src/Mayaqua/Unix.c
===================================================================
--- a/src/Mayaqua/Unix.c
+++ b/src/Mayaqua/Unix.c
@@ -928,7 +928,7 @@
StrCpy(tmp, sizeof(tmp), instance_name);
}
- GetExeDir(dir, sizeof(dir));
+ GetStateDir(dir, sizeof(dir));
// File name generation
Format(name, sizeof(name), "%s/.%s", dir, tmp);
@@ -2260,7 +2260,7 @@
return;
}
- GetExeDir(dir, sizeof(dir));
+ GetStateDir(dir, sizeof(dir));
GetExeName(exe_name, sizeof(exe_name));
StrCat(exe_name, sizeof(exe_name), ":pid_hash");
@@ -2305,7 +2305,7 @@
return;
}
- GetExeDir(dir, sizeof(dir));
+ GetStateDir(dir, sizeof(dir));
GetExeName(exe_name, sizeof(exe_name));
StrCat(exe_name, sizeof(exe_name), ":pid_hash");
Index: b/src/bin/hamcore/Makefile.am
===================================================================
--- a/src/bin/hamcore/Makefile.am
+++ b/src/bin/hamcore/Makefile.am
@@ -18,12 +18,16 @@
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
EXEEXT =
+
HAMCOREBUILDER = $(top_builddir)/src/hamcorebuilder/hamcorebuilder
-sbin_PROGRAMS = hamcore.se2
+noinst_PROGRAMS = hamcore.se2
hamcore.se2$(EXEEXT): $(HAMCOREBUILDER)
$(HAMCOREBUILDER) $(top_srcdir)/src/bin/hamcore $@
+
+install-exec-local: hamcore.se2$(EXEEXT)
+ $(INSTALL_DATA) -D hamcore.se2$(EXEEXT) $(DESTDIR)$(localstatedir)/lib/softether/hamcore.se2
|