-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchksetup.js
359 lines (336 loc) · 10.4 KB
/
chksetup.js
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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
// $Id: chksetup.js,v 1.17 2020/04/02 17:46:23 rswindell Exp $
// Sanity-check a Synchronet BBS installation
"use strict";
const REVISION = "$Revision: 1.17 $".split(' ')[1];
require("sbbsdefs.js", 'USER_DELETED');
function check_codes(desc, grp_list, sub_list)
{
var list = [];
var output = [];
for(var g in grp_list) {
for(var s in grp_list[g][sub_list]) {
var sub = grp_list[g][sub_list][s];
var code = sub.code.toUpperCase();
if(list.indexOf(code) >= 0)
output.push("Duplicate " + desc +" internal code in " + grp_list[g].name + ": " + code);
else {
if(file_getname(code) != code)
output.push("Invalid " + desc + " internal code in " + grp_list[g].name + ": " + code);
list.push(code);
}
}
}
return output;
}
var tests = {
check_sysop: function(options)
{
var output = [];
var usr = new User(1);
if(!usr.is_sysop)
output.push("User #1 is not a sysop");
if(usr.security.restrictions & UFLAG_G)
output.push("User #1 should not have the (G)uest restriction");
if(system.operator.toLowerCase() != usr.alias.toLowerCase()
&& system.operator.toLowerCase() != usr.name.toLowerCase())
output.push(format("User #%-4u name (%s) and alias (%s) does not match system operator (%s)"
,1, usr.name, usr.alias, system.operator));
return output;
},
check_guest: function(options)
{
var guests = 0;
var usr = new User;
var lastuser = system.lastuser;
for(var u = 1; u <= lastuser; u++) {
usr.number = u;
if(usr == null)
continue;
if(usr.settings & (USER_DELETED|USER_INACTIVE))
continue;
if(!(usr.security.restrictions & UFLAG_G))
continue;
guests++;
if(guests > 1 && options.verbose)
writeln(format("User %-4u (%s) is a (G)uest-restricted account"
,usr.number, usr.alias));
}
if(guests != 1)
return format("%u guest accounts found, recommended number: 1", guests);
},
check_user_names: function(options)
{
var output = [];
var usr = new User;
var lastuser = system.lastuser;
for(var u = 1; u <= lastuser; u++) {
usr.number = u;
if(usr == null)
continue;
if(usr.settings & (USER_DELETED|USER_INACTIVE))
continue;
if(!system.trashcan("name", usr.alias))
continue;
output.push(format("User #%-4u has a disallowed alias%s"
, usr.number
, options.verbose ? (': ' + usr.alias) : ''));
}
return output;
},
check_user_passwords: function(options)
{
var output = [];
var usr = new User;
var lastuser = system.lastuser;
var password_list = {};
for(var u = 1; u <= lastuser; u++) {
usr.number = u;
if(usr == null)
continue;
if(usr.settings & (USER_DELETED|USER_INACTIVE))
continue;
if(usr.security.password == '') {
if(!(usr.security.restrictions & UFLAG_G))
output.push(format("User #%-4u has no password", usr.number));
continue;
}
if(!password_list[usr.security.password])
password_list[usr.security.password] = [];
password_list[usr.security.password].push(u);
if(usr.security.password.length < system.min_password_length)
output.push(format("User #%-4u has a password length (%u) < the minimum: %u"
, usr.number
, usr.security.password.length
, system.min_password_length));
else if(system.max_password_length
&& usr.security.password.length > system.max_password_length)
output.push(format("User #%-4u has a password length (%u) > the maximum: %u"
, usr.number
, usr.security.password.length
, system.max_password_length));
if(!system.trashcan("password", usr.security.password))
continue;
output.push(format("User #%-4u has a disallowed password%s"
, usr.number
, options.verbose ? (': ' + usr.security.password) : ''));
}
for(var p in password_list) {
if(password_list[p].length > 2)
output.push("Password "
+ ( options.verbose ? (p + ' '): '')
+ "shared between " + password_list[p].length + " users: " + password_list[p]);
}
return output;
},
check_qnet_tags: function(options)
{
var output = [];
var long = 0;
var short = 0;
var dflt = 0;
const maxlen = 79 - " * Synchronet * ".length;
for(var s in msg_area.sub) {
var sub = msg_area.sub[s];
if(!(sub.settings & SUB_QNET))
continue;
if(sub.qwknet_tagline == "My Brand-New BBS")
dflt++;
var len = strip_ctrl(sub.qwknet_tagline).length;
if(js.global.console)
len = console.strlen(sub.qwknet_tagline);
if(len > maxlen) {
if(options.verbose)
alert(format("QWK-networked sub (%s) has a long tagline", s));
long++;
}
if(len < 1) {
if(options.verbose)
alert(format("QWK-networked sub (%s) has a short tagline", s));
short++;
}
}
if(long)
output.push(long
+ " msg sub-boards have QWKnet taglines exceeding "
+ maxlen + " printed characters");
if(short)
output.push(short
+ " msg sub-boards have QWKnet taglines with no content");
if(dflt)
output.push(dflt
+ " msg sub-boards have the default QWKnet tagline");
return output;
},
check_fido_origlines: function(options)
{
var output = [];
var long = 0;
var short = 0;
const maxlen = 79 - " * Origin: ".length;
for(var s in msg_area.sub) {
var sub = msg_area.sub[s];
if(!(sub.settings & SUB_FIDO))
continue;
var len = sub.fidonet_origin.length;
if(len > maxlen) {
if(options.verbose)
alert(format("Fido-networked sub (%s) has a long origin line", s));
long++;
}
if(len < 1) {
if(options.verbose)
alert(format("Fido-networked sub (%s) has a short origin line", s));
short++;
}
}
if(long)
output.push(long
+ " msg sub-boards have FidoNet origin lines exceeding "
+ maxlen + " printed characters");
if(short)
output.push(short
+ " msg sub-boards have FidoNet origin lines with no content");
return output;
},
check_bbs_list: function(options)
{
var lib = load({}, "sbbslist_lib.js");
var list = lib.read_list();
if(!lib.system_exists(list, system.name))
return system.name + " is not listed in " + lib.list_fname;
var finger_host = "vert.synchro.net";
var finger_query = "?bbs:" + system.name;
var finger_result = load({}, "finger_lib.js").request(finger_host, finger_query);
if(typeof finger_result == 'string')
return finger_result;
var finger_obj;
try {
finger_obj = JSON.parse(finger_result.join(''));
} catch(e) {
return 'finger ' + finger_query + '@' + finger_host + ' result: ' + e;
}
var bbs = list[lib.system_index(list, system.name)];
bbs.entry = undefined;
bbs.total = undefined;
bbs.preview = undefined;
bbs.imported = undefined;
finger_obj.entry = undefined;
finger_obj.total = undefined;
finger_obj.preview = undefined;
finger_obj.imported = undefined;
if(JSON.stringify(finger_obj) != JSON.stringify(bbs)) {
if(options.verbose) {
print(finger_host + ":");
print(JSON.stringify(finger_obj, null, 4));
print("local:");
print(JSON.stringify(bbs, null, 4));
}
return format("'%s' BBS entry on %s is different than local", system.name, finger_host);
}
},
check_syncdata: function(options)
{
if(!load({}, "syncdata.js").find())
return "SYNCDATA sub-board could not be found in message area configuration";
},
check_imsg_list: function(options)
{
var lib = load({}, "sbbsimsg_lib.js");
var list = lib.read_sys_list(/* include_self: */true);
if(!lib.find_name(list, system.name))
return system.name + " is not listed in " + lib.filename;
},
check_dove_net: function(options)
{
const TOTAL_DOVENET_CONFERENCES = 22;
var output = [];
var grp = msg_area.grp["DOVE-Net"];
if(!grp)
return;
if(grp.sub_list.length != TOTAL_DOVENET_CONFERENCES)
output.push(format("DOVE-Net: %u sub-boards configured (instead of the expected: %u)"
,grp.sub_list.length, TOTAL_DOVENET_CONFERENCES));
for(var s in grp.sub_list) {
var sub = grp.sub_list[s];
if(sub.settings & SUB_GATE)
output.push(format("DOVE-Net: %-16s is configured to Gate Between Net Types", sub.code));
if(sub.settings & SUB_NOVOTING)
output.push(format("DOVE-Net: %-16s is NOT configured to allow voting", sub.code));
if(!(sub.settings & SUB_QNET))
output.push(format("DOVE-Net: %-16s is NOT configured for QWK Networking", sub.code));
}
return output;
},
check_sub_cfgs: function(options)
{
var output = [];
for(var sub in msg_area.sub) {
var msgbase = new MsgBase(sub);
if(!msgbase.open()) {
if(options.verbose)
alert(format("Error (%s) opening sub: %s", msgbase.error, sub));
continue;
}
if(msgbase.max_crcs != msgbase.cfg.max_crcs)
output.push(format("MsgBase: %-16s max_crcs status (%d) does not match sub-board configuration: %d",
sub, msgbase.max_crcs, msgbase.cfg.max_crcs));
if(msgbase.max_msgs != msgbase.cfg.max_msgs)
output.push(format("MsgBase: %-16s max_msgs status (%d) does not match sub-board configuration: %d",
sub, msgbase.max_msgs, msgbase.cfg.max_msgs));
if(msgbase.max_age != msgbase.cfg.max_age)
output.push(format("MsgBase: %-16s max_age status (%d) does not match sub-board configuration: %d",
sub, msgbase.max_age, msgbase.cfg.max_age));
msgbase.close();
}
return output;
},
check_sub_codes: function(options)
{
return check_codes("msg sub-board", msg_area.grp_list, 'sub_list');
},
check_dir_codes: function(options)
{
return check_codes("file directory", file_area.lib_list, 'dir_list');
},
check_xtrn_codes: function(options)
{
return check_codes("external program (door)", xtrn_area.sec_list, 'prog_list');
},
check_sockopts_ini: function(options)
{
var output = [];
var file = new File(file_cfgname(system.ctrl_dir, "sockopts.ini"));
if(file.open("r")) {
if(file.iniGetValue(null, "SNDBUF"))
output.push(file.name + " has SNDBUF set");
if(file.iniGetValue(null, "RCVBUF"))
output.push(file.name + " has RCVBUF set");
if(file.iniGetValue("tcp", "SNDBUF"))
output.push(file.name + " has [tcp] SNDBUF set");
if(file.iniGetValue("tcp", "RCVBUF"))
output.push(file.name + " has [tcp] RCVBUF set");
file.close();
}
return output;
}
};
print('Synchronet Check Setup v' + REVISION);
var options = { verbose: argv.indexOf('-v') >= 0 || argv.indexOf('-V') >= 0};
var issues = 0;
for(var i in tests) {
print('Invoking: ' + i);
var result;
switch(typeof (result = tests[i](options))) {
case 'string':
alert(result), issues++;
break;
case 'object':
for(var i in result)
alert(result[i]), issues++;
break;
}
}
if(issues)
alert(issues + " issues discovered");
else
writeln("No issues discovered");