-
Notifications
You must be signed in to change notification settings - Fork 0
/
0001-Revert-Remove-innbbsd.patch
13931 lines (13861 loc) · 367 KB
/
0001-Revert-Remove-innbbsd.patch
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
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From 1f1aee9f024c0ba869efe8f84522ad0b137bff35 Mon Sep 17 00:00:00 2001
From: holishing <holishingtest@gmail.com>
Date: Thu, 14 Dec 2017 21:40:31 +0800
Subject: [PATCH] Revert "Remove innbbsd."
This reverts:
commit ed71cbf390ea9b314e9506ba647c0104ef77a465
commit 6ad941c731961c475192adc30795b512e5e14ad3 (part)
commit eb576132e737761848959e40e185dcd25c79c053
commit 9e78c68152159e3324679f8fd92a1a5e2a05bc7f
commit 93418d2464237b6cfc56ae3f293a1129d18b603f
commit 524cced5b2afc20ef9af7570067887fc93a9cd23
try if innbbsd still works. XD
---
Makefile | 6 +-
README | 1 +
include/common.h | 2 +-
include/proto.h | 4 +-
include/pttstruct.h | 4 +-
innbbsd/COPYRIGHT.nocem | 11 +
innbbsd/Makefile | 78 ++
innbbsd/antisplam.h | 25 +
innbbsd/bbslib.c | 747 +++++++++++++++
innbbsd/bbslib.h | 62 ++
innbbsd/bbslink.c | 1812 +++++++++++++++++++++++++++++++++++
innbbsd/bbsnnrp.c | 1248 ++++++++++++++++++++++++
innbbsd/clibrary.h | 142 +++
innbbsd/closeonexec.c | 39 +
innbbsd/connectsock.c | 428 +++++++++
innbbsd/ctlinnbbsd.c | 170 ++++
innbbsd/daemon.c | 162 ++++
innbbsd/daemon.h | 54 ++
innbbsd/dbz.c | 1885 +++++++++++++++++++++++++++++++++++++
innbbsd/dbz.h | 37 +
innbbsd/dbztool.c | 61 ++
innbbsd/echobbslib.c | 746 +++++++++++++++
innbbsd/externs.h | 79 ++
innbbsd/file.c | 17 +
innbbsd/his.c | 409 ++++++++
innbbsd/his.h | 45 +
innbbsd/innbbsconf.h | 177 ++++
innbbsd/innbbsd.c | 790 ++++++++++++++++
innbbsd/innbbsd.h | 9 +
innbbsd/inncheck.pl | 46 +
innbbsd/inndchannel.c | 683 ++++++++++++++
innbbsd/inntobbs.c | 343 +++++++
innbbsd/inntobbs.h | 39 +
innbbsd/mkhistory.c | 17 +
innbbsd/nntp.h | 141 +++
innbbsd/nocem.c | 638 +++++++++++++
innbbsd/nocem.h | 57 ++
innbbsd/pmain.c | 65 ++
innbbsd/port.c | 35 +
innbbsd/receive_article.c | 1138 ++++++++++++++++++++++
innbbsd/rfc931.c | 147 +++
mbbsd/admin.c | 12 +-
mbbsd/announce.c | 4 +-
mbbsd/bbs.c | 70 +-
mbbsd/board.c | 15 +-
mbbsd/edit.c | 40 +-
mbbsd/mail.c | 12 +-
mbbsd/var.c | 5 +-
sample/Makefile | 2 +-
sample/crontab | 10 +
sample/innd/Makefile | 11 +
sample/innd/bbsname.bbs | 1 +
sample/innd/ncmperm.bbs | 0
sample/innd/newsfeeds.bbs | 3 +
sample/innd/nodelist.bbs | 4 +
sample/innd/ntu.active | 1 +
sample/pttbbs.sh | 4 +
sample/rc.local | 1 +
util/Makefile | 2 +-
util/account.c | 1 +
util/dailybackup.pl | 2 +-
util/initbbs.c | 20 +-
util/inndBM.c | 201 ++++
util/shmctl.c | 4 +-
64 files changed, 12976 insertions(+), 48 deletions(-)
create mode 100644 innbbsd/COPYRIGHT.nocem
create mode 100644 innbbsd/Makefile
create mode 100644 innbbsd/antisplam.h
create mode 100644 innbbsd/bbslib.c
create mode 100644 innbbsd/bbslib.h
create mode 100644 innbbsd/bbslink.c
create mode 100644 innbbsd/bbsnnrp.c
create mode 100644 innbbsd/clibrary.h
create mode 100644 innbbsd/closeonexec.c
create mode 100644 innbbsd/connectsock.c
create mode 100644 innbbsd/ctlinnbbsd.c
create mode 100644 innbbsd/daemon.c
create mode 100644 innbbsd/daemon.h
create mode 100644 innbbsd/dbz.c
create mode 100644 innbbsd/dbz.h
create mode 100644 innbbsd/dbztool.c
create mode 100644 innbbsd/echobbslib.c
create mode 100644 innbbsd/externs.h
create mode 100644 innbbsd/file.c
create mode 100644 innbbsd/his.c
create mode 100644 innbbsd/his.h
create mode 100644 innbbsd/innbbsconf.h
create mode 100644 innbbsd/innbbsd.c
create mode 100644 innbbsd/innbbsd.h
create mode 100644 innbbsd/inncheck.pl
create mode 100644 innbbsd/inndchannel.c
create mode 100644 innbbsd/inntobbs.c
create mode 100644 innbbsd/inntobbs.h
create mode 100644 innbbsd/mkhistory.c
create mode 100644 innbbsd/nntp.h
create mode 100644 innbbsd/nocem.c
create mode 100644 innbbsd/nocem.h
create mode 100644 innbbsd/pmain.c
create mode 100644 innbbsd/port.c
create mode 100644 innbbsd/receive_article.c
create mode 100644 innbbsd/rfc931.c
create mode 100644 sample/innd/Makefile
create mode 100644 sample/innd/bbsname.bbs
create mode 100644 sample/innd/ncmperm.bbs
create mode 100644 sample/innd/newsfeeds.bbs
create mode 100644 sample/innd/nodelist.bbs
create mode 100644 sample/innd/ntu.active
create mode 100644 util/inndBM.c
diff --git a/Makefile b/Makefile
index 70daa74f..5cf6e4aa 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,10 @@
-SUBDIR= common mbbsd util
+SUBDIR= common mbbsd util innbbsd
.include <bsd.subdir.mk>
.ORDER: all-common all-mbbsd
.ORDER: all-common all-util
+.ORDER: all-common all-innbbsd
+
+# XXX innbbsd depends on util
+.ORDER: all-util all-innbbsd
diff --git a/README b/README
index 1f359054..e864801e 100644
--- a/README
+++ b/README
@@ -23,6 +23,7 @@
proto/ mbbsd/ 裡面各個檔案的說明,詳見該目錄的 README
z6ibbs.[12].txt in2 隨筆
+ innbbsd/ 轉信
sample/ 範例
crontab 提供 bbs執行時須透過 crontab 定時跑的設定
diff --git a/include/common.h b/include/common.h
index 36447c7a..26dd7215 100644
--- a/include/common.h
+++ b/include/common.h
@@ -249,7 +249,7 @@
#define EDITFLAG_KIND_SENDMAIL (0x00000040)
#define EDITFLAG_KIND_MAILLIST (0x00000080)
#define EDITFLAG_WARN_NOSELFDEL (0x00000100)
-// #define EDITFLAG_ALLOW_LOCAL (0x00000200)
+#define EDITFLAG_ALLOW_LOCAL (0x00000200)
#define EDIT_ABORTED -1
/* ----------------------------------------------------- */
diff --git a/include/proto.h b/include/proto.h
index 0e97445b..d7d1dd0b 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -216,8 +216,8 @@ int main_dark(int fd,userinfo_t *uin);
int dice_main(void);
/* edit */
-int vedit(const char *fpath, int saveheader, char save_title[STRLEN]);
-int vedit2(const char *fpath, int saveheader, char save_title[STRLEN], int flags);
+int vedit(const char *fpath, int saveheader, int *islocal, char save_title[STRLEN]);
+int vedit2(const char *fpath, int saveheader, int *islocal, char save_title[STRLEN], int flags);
int veditfile(const char *fpath);
void write_header(FILE *fp, const char *mytitle);
void addsignature(FILE *fp, int ifuseanony);
diff --git a/include/pttstruct.h b/include/pttstruct.h
index 377a6001..cfbfb469 100644
--- a/include/pttstruct.h
+++ b/include/pttstruct.h
@@ -205,7 +205,7 @@ typedef struct boardheader_t { /* 256 bytes */
// TODO BRD 快爆了,怎麼辦? 準備從 pad3 偷一個來當 attr2 吧...
// #define BRD_NOZAP 0x00000001 /* 不可 ZAP */
#define BRD_NOCOUNT 0x00000002 /* 不列入統計 */
-//#define BRD_NOTRAN 0x00000004 /* 不轉信 */
+#define BRD_NOTRAN 0x00000004 /* 不轉信 */
#define BRD_GROUPBOARD 0x00000008 /* 群組板 */
#define BRD_HIDE 0x00000010 /* 隱藏板 (看板好友才可看) */
#define BRD_POSTMASK 0x00000020 /* 限制發表或閱讀 */
@@ -220,7 +220,7 @@ typedef struct boardheader_t { /* 256 bytes */
#define BRD_BMCOUNT 0x00004000 /* 板主設定列入記錄 */
#define BRD_SYMBOLIC 0x00008000 /* symbolic link to board */
#define BRD_NOBOO 0x00010000 /* 不可噓 */
-//#define BRD_LOCALSAVE 0x00020000 /* 預設 Local Save */
+#define BRD_LOCALSAVE 0x00020000 /* 預設 Local Save */
#define BRD_RESTRICTEDPOST 0x00040000 /* 板友才能發文 */
#define BRD_GUESTPOST 0x00080000 /* guest能 post */
#define BRD_COOLDOWN 0x00100000 /* 冷靜 */
diff --git a/innbbsd/COPYRIGHT.nocem b/innbbsd/COPYRIGHT.nocem
new file mode 100644
index 00000000..fdd43b20
--- /dev/null
+++ b/innbbsd/COPYRIGHT.nocem
@@ -0,0 +1,11 @@
+# Author: Yen-Ming Lee <leeym@cae.ce.ntu.edu.tw>
+# Start Date: Thu Feb 25 1999 +0800
+# Project: INNBBSD - NoCeM
+# File: nocem.c nocem.h
+#
+# Copyright: Copyright (c) 2000 by Yen-Ming Lee
+#
+# Permission to use, copy, modify, and distribute this
+# software for any purpose with or without fee is hereby
+# granted, provided that the above copyright notice and this
+# permission notice appear in all copies.
diff --git a/innbbsd/Makefile b/innbbsd/Makefile
new file mode 100644
index 00000000..756bbbe0
--- /dev/null
+++ b/innbbsd/Makefile
@@ -0,0 +1,78 @@
+# $Id$
+SRCROOT= ..
+.include "${SRCROOT}/pttbbs.mk"
+
+VERSION= 0.50-pttpatch
+ADMINUSER?= root@your.domain.name
+
+.if $(OSTYPE) == "FreeBSD"
+# FreeBSD為了 innbbsd額外需加的參數
+inn_CFLAGS= -DMMAP -DGETRUSAGE
+inn_LDFLAGS= -L/usr/local/lib
+.else
+# Linux為了 innbbsd額外需加的參數
+inn_CFLAGS= -DGETRUSAGE
+inn_LDFLAGS=
+.endif
+
+CFLAGS+= -DVERSION=\"${VERSION}\" \
+ -DADMINUSER=\"${ADMINUSER}\" \
+ -DMapleBBS -DDBZDEBUG -I. \
+ ${inn_CFLAGS} -DHMM_USE_ANTI_SPAM
+
+LDFLAGS+= ${inn_LDFLAGS}
+
+PROGS= bbslink bbsnnrp ctlinnbbsd \
+ innbbsd mkhistory
+
+all: ${PROGS}
+
+# bbs util
+UTIL_DIR= $(SRCROOT)/util
+UTIL_OBJS= util_var.o
+
+.for fn in ${UTIL_OBJS}
+LINK_UTIL_OBJS+= ${UTIL_DIR}/${fn}
+
+${UTIL_DIR}/${fn}: # FIXME: dependency
+ cd ${UTIL_DIR}; make ${fn}
+.endfor
+
+LDLIBS:=$(SRCROOT)/common/bbs/libcmbbs.a \
+ $(SRCROOT)/common/sys/libcmsys.a \
+ $(SRCROOT)/common/osdep/libosdep.a \
+ $(LDLIBS)
+
+echobbslib.o: echobbslib.c
+ ${CC} ${CFLAGS} -DWITH_ECHOMAIL -c echobbslib.c
+
+innbbsd: inndchannel.o innbbsd.o connectsock.o rfc931.o daemon.o \
+ file.o pmain.o his.o dbz.o closeonexec.o dbztool.o \
+ inntobbs.o receive_article.o echobbslib.o nocem.o
+ ${CC} -o $@ ${LDFLAGS} $> ${LINK_UTIL_OBJS} $(LDLIBS)
+
+bbslink: bbslink.o pmain.o inntobbs.o echobbslib.o connectsock.o \
+ file.o port.o
+ ${CC} -o $@ ${LDFLAGS} $> ${LINK_UTIL_OBJS} $(LDLIBS)
+
+bbsnnrp: bbsnnrp.o pmain.o bbslib.o connectsock.o file.o
+ ${CC} -o $@ ${LDFLAGS} $> ${LINK_UTIL_OBJS} $(LDLIBS)
+
+ctlinnbbsd: ctlinnbbsd.o pmain.o bbslib.o connectsock.o file.o
+ ${CC} -o $@ ${LDFLAGS} $> ${LINK_UTIL_OBJS} $(LDLIBS)
+
+mkhistory: mkhistory.o bbslib.o file.o his.o dbz.o port.o closeonexec.o
+ ${CC} -o $@ ${LDFLAGS} $> ${LINK_UTIL_OBJS} $(LDLIBS)
+
+install: ${PROGS}
+ install -d ${BBSHOME}/innd/
+ install -c -m 755 ${PROGS} ${BBSHOME}/innd/
+
+clean:
+ rm -f *.o ${PROGS} core *.core
+
+reset:
+ cd $(SRCROOT)/util/; ${MAKE} clean shmctl
+ ${MAKE} clean ; ${MAKE} ; ${MAKE} install
+ killall innbbsd
+ cd ~; nohup innd/innbbsd 7777 &
diff --git a/innbbsd/antisplam.h b/innbbsd/antisplam.h
new file mode 100644
index 00000000..0832533f
--- /dev/null
+++ b/innbbsd/antisplam.h
@@ -0,0 +1,25 @@
+#include "bbs.h"
+#define char_lower(c) ((c >= 'A' && c <= 'Z') ? c|32 : c)
+
+#if 0 /* string.h , libc */
+int
+strcasestr(str, tag)
+ char *str, *tag; /* tag : lower-case string */
+{
+ char buf[256];
+
+ str_lower(buf, str);
+ return (int)strstr(buf, tag);
+}
+#endif
+
+int
+bad_subject(char *subject)
+{
+ char *badkey[] = {"無碼", "avcd", "mp3", NULL};
+ int i;
+ for (i = 0; badkey[i]; i++)
+ if (strcasestr(subject, badkey[i]))
+ return 1;
+ return 0;
+}
diff --git a/innbbsd/bbslib.c b/innbbsd/bbslib.c
new file mode 100644
index 00000000..7d45734b
--- /dev/null
+++ b/innbbsd/bbslib.c
@@ -0,0 +1,747 @@
+#include "bbs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include "config.h"
+#include "externs.h"
+#include "innbbsconf.h"
+#include "bbslib.h"
+
+char INNBBSCONF[MAXPATHLEN];
+char INNDHOME[MAXPATHLEN];
+char HISTORY[MAXPATHLEN];
+char LOGFILE[MAXPATHLEN];
+char MYBBSID[MAXPATHLEN];
+char ECHOMAIL[MAXPATHLEN];
+char BBSFEEDS[MAXPATHLEN];
+char LOCALDAEMON[MAXPATHLEN];
+
+int His_Maint_Min = HIS_MAINT_MIN;
+int His_Maint_Hour = HIS_MAINT_HOUR;
+int Expiredays = EXPIREDAYS;
+
+nodelist_t *NODELIST = NULL, **NODELIST_BYNODE = NULL;
+newsfeeds_t *NEWSFEEDS = NULL, **NEWSFEEDS_BYBOARD = NULL;
+static char *NODELIST_BUF, *NEWSFEEDS_BUF;
+int NFCOUNT, NLCOUNT;
+int LOCALNODELIST = 0, NONENEWSFEEDS = 0;
+
+#ifndef _PATH_BBSHOME
+#define _PATH_BBSHOME "/u/staff/bbsroot/csie_util/bntpd/home"
+#endif
+
+static FILE *bbslogfp;
+
+static int
+ verboseFlag = 0;
+
+static char *
+ verboseFilename = NULL;
+static char verbosename[MAXPATHLEN];
+
+void
+verboseon(char *filename)
+{
+ verboseFlag = 1;
+ if (filename != NULL) {
+ if (strchr(filename, '/') == NULL) {
+ sprintf(verbosename, "%s/innd/%s", BBSHOME, filename);
+ filename = verbosename;
+ }
+ }
+ verboseFilename = filename;
+}
+
+void
+verboseoff()
+{
+ verboseFlag = 0;
+}
+
+void
+setverboseon()
+{
+ verboseFlag = 1;
+}
+
+int
+isverboselog()
+{
+ return verboseFlag;
+}
+
+void
+setverboseoff()
+{
+ verboseoff();
+ if (bbslogfp != NULL) {
+ fclose(bbslogfp);
+ bbslogfp = NULL;
+ }
+}
+
+void
+verboselog(char *fmt, ...)
+{
+ va_list ap;
+ char datebuf[40];
+ time_t now;
+
+ if (verboseFlag == 0)
+ return;
+
+ va_start(ap, fmt);
+
+ time(&now);
+ strftime(datebuf, sizeof(datebuf), "%b %d %X ", localtime(&now));
+
+ if (bbslogfp == NULL) {
+ if (verboseFilename != NULL)
+ bbslogfp = fopen(verboseFilename, "a");
+ else
+ bbslogfp = fdopen(1, "a");
+ }
+ if (bbslogfp == NULL) {
+ va_end(ap);
+ return;
+ }
+ fprintf(bbslogfp, "%s[%d] ", datebuf, getpid());
+ vfprintf(bbslogfp, fmt, ap);
+ fflush(bbslogfp);
+ va_end(ap);
+}
+
+void
+#ifdef PalmBBS
+xbbslog(char *fmt, ...)
+#else
+bbslog(char *fmt, ...)
+#endif
+{
+ va_list ap;
+ char datebuf[40];
+ time_t now;
+
+ va_start(ap, fmt);
+
+ time(&now);
+ strftime(datebuf, sizeof(datebuf), "%b %d %X ", localtime(&now));
+
+ if (bbslogfp == NULL) {
+ bbslogfp = fopen(LOGFILE, "a");
+ }
+ if (bbslogfp == NULL) {
+ va_end(ap);
+ return;
+ }
+ fprintf(bbslogfp, "%s[%d] ", datebuf, getpid());
+ vfprintf(bbslogfp, fmt, ap);
+ fflush(bbslogfp);
+ va_end(ap);
+}
+
+int
+initial_bbs(char *outgoing)
+{
+#ifdef WITH_ECHOMAIL
+ FILE *FN;
+ char *bbsnameptr = NULL;
+#endif
+
+ /* reopen bbslog */
+ if (bbslogfp != NULL) {
+ fclose(bbslogfp);
+ bbslogfp = NULL;
+ }
+#ifdef WITH_ECHOMAIL
+ init_echomailfp();
+ init_bbsfeedsfp();
+#endif
+
+ LOCALNODELIST = 0, NONENEWSFEEDS = 0;
+ sprintf(INNDHOME, "%s/innd", BBSHOME);
+ sprintf(HISTORY, "%s/history", INNDHOME);
+ sprintf(LOGFILE, "%s/bbslog", INNDHOME);
+ sprintf(ECHOMAIL, "%s/echomail.log", BBSHOME);
+ sprintf(LOCALDAEMON, "%s/.innbbsd", INNDHOME);
+ sprintf(INNBBSCONF, "%s/innbbs.conf", INNDHOME);
+ sprintf(BBSFEEDS, "%s/bbsfeeds.log", INNDHOME);
+
+ if (dashf(INNBBSCONF)) {
+ FILE *conf;
+ char buffer[MAXPATHLEN];
+ conf = fopen(INNBBSCONF, "r");
+ if (conf != NULL) {
+ while (fgets(buffer, sizeof buffer, conf) != NULL) {
+ char *ptr, *front = NULL, *value = NULL, *value2 = NULL,
+ *value3 = NULL;
+ if (buffer[0] == '#' || buffer[0] == '\n')
+ continue;
+ for (front = buffer; *front && isspace(*front); front++);
+ for (ptr = front; *ptr && !isspace(*ptr); ptr++);
+ if (*ptr == '\0')
+ continue;
+ *ptr++ = '\0';
+ for (; *ptr && isspace(*ptr); ptr++);
+ if (*ptr == '\0')
+ continue;
+ value = ptr++;
+ for (; *ptr && !isspace(*ptr); ptr++);
+ if (*ptr) {
+ *ptr++ = '\0';
+ for (; *ptr && isspace(*ptr); ptr++);
+ value2 = ptr++;
+ for (; *ptr && !isspace(*ptr); ptr++);
+ if (*ptr) {
+ *ptr++ = '\0';
+ for (; *ptr && isspace(*ptr); ptr++);
+ value3 = ptr++;
+ for (; *ptr && !isspace(*ptr); ptr++);
+ if (*ptr) {
+ *ptr++ = '\0';
+ }
+ }
+ }
+ if (strcasecmp(front, "expiredays") == 0) {
+ Expiredays = atoi(value);
+ if (Expiredays < 0) {
+ Expiredays = EXPIREDAYS;
+ }
+ } else if (strcasecmp(front, "expiretime") == 0) {
+ ptr = strchr(value, ':');
+ if (ptr == NULL) {
+ fprintf(stderr, "Syntax error in innbbs.conf\n");
+ } else {
+ *ptr++ = '\0';
+ His_Maint_Hour = atoi(value);
+ His_Maint_Min = atoi(ptr);
+ if (His_Maint_Hour < 0)
+ His_Maint_Hour = HIS_MAINT_HOUR;
+ if (His_Maint_Min < 0)
+ His_Maint_Min = HIS_MAINT_MIN;
+ }
+ } else if (strcasecmp(front, "newsfeeds") == 0) {
+ if (strcmp(value, "none") == 0)
+ NONENEWSFEEDS = 1;
+ } else if (strcasecmp(front, "nodelist") == 0) {
+ if (strcmp(value, "local") == 0)
+ LOCALNODELIST = 1;
+ } /* else if ( strcasecmp(front,"newsfeeds") ==
+ * 0) { printf("newsfeeds %s\n", value); }
+ * else if ( strcasecmp(front,"nodelist") ==
+ * 0) { printf("nodelist %s\n", value); }
+ * else if ( strcasecmp(front,"bbsname") ==
+ * 0) { printf("bbsname %s\n", value); } */
+ }
+ fclose(conf);
+ }
+ }
+#ifdef WITH_ECHOMAIL
+ bbsnameptr = (char *)fileglue("%s/bbsname.bbs", INNDHOME);
+ if ((FN = fopen(bbsnameptr, "r")) == NULL) {
+ fprintf(stderr, "can't open file %s\n", bbsnameptr);
+ return 0;
+ }
+ while (fscanf(FN, "%s", MYBBSID) != EOF);
+ fclose(FN);
+ if (!dashd(fileglue("%s/out.going", BBSHOME))) {
+ mkdir((char *)fileglue("%s/out.going", BBSHOME), 0755);
+ }
+ if (NONENEWSFEEDS == 0)
+ readnffile(INNDHOME);
+ readNCMfile(INNDHOME);
+ if (LOCALNODELIST == 0) {
+ if (readnlfile(INNDHOME, outgoing) != 0)
+ return 0;
+ }
+#endif
+ return 1;
+}
+
+static int
+nf_byboardcmp(const void *a, const void *b)
+{
+ /*
+ * if (!a || !*a || !(*a)->board) return -1; if (!b || !*b ||
+ * !(*b)->board) return 1;
+ */
+ return strcasecmp((*((const newsfeeds_t **)a))->board, (*((const newsfeeds_t **)b))->board);
+}
+
+static int
+nfcmp(const void *a, const void *b)
+{
+ /*
+ * if (!a || !a->newsgroups) return -1; if (!b || !b->newsgroups) return
+ * 1;
+ */
+ return strcasecmp(((const newsfeeds_t *)a)->newsgroups, ((const newsfeeds_t *)b)->newsgroups);
+}
+
+static int
+nlcmp(const void *a, const void *b)
+{
+ /*
+ * if (!a || !a->host) return -1; if (!b || !b->host) return 1;
+ */
+ return strcasecmp(((const nodelist_t *)a)->host, ((const nodelist_t *)b)->host);
+}
+
+static int
+nl_bynodecmp(const void *a, const void *b)
+{
+ /*
+ * if (!a || !*a || !(*a)->node) return -1; if (!b || !*b || !(*b)->node)
+ * return 1;
+ */
+ return strcasecmp((*((const nodelist_t **)a))->node, (*((const nodelist_t **)b))->node);
+}
+
+/* read in newsfeeds.bbs and nodelist.bbs */
+int
+readnlfile(char *inndhome, char *outgoing)
+{
+ FILE *fp;
+ char buff[1024];
+ struct stat st;
+ int i, count;
+ char *ptr, *nodelistptr;
+ static int lastcount = 0;
+
+ sprintf(buff, "%s/nodelist.bbs", inndhome);
+ fp = fopen(buff, "r");
+ if (fp == NULL) {
+ fprintf(stderr, "open fail %s", buff);
+ return -1;
+ }
+ if (fstat(fileno(fp), &st) != 0) {
+ fprintf(stderr, "stat fail %s", buff);
+ return -1;
+ }
+ if (NODELIST_BUF == NULL) {
+ NODELIST_BUF = (char *)mymalloc(st.st_size + 1);
+ } else {
+ NODELIST_BUF = (char *)myrealloc(NODELIST_BUF, st.st_size + 1);
+ }
+ i = 0, count = 0;
+ while (fgets(buff, sizeof buff, fp) != NULL) {
+ if (buff[0] == '#')
+ continue;
+ if (buff[0] == '\n')
+ continue;
+ strcpy(NODELIST_BUF + i, buff);
+ i += strlen(buff);
+ count++;
+ }
+ fclose(fp);
+ if (NODELIST == NULL) {
+ NODELIST = (nodelist_t *) mymalloc(sizeof(nodelist_t) * (count + 1));
+ NODELIST_BYNODE = (nodelist_t **) mymalloc(sizeof(nodelist_t *) * (count + 1));
+ } else {
+ NODELIST = (nodelist_t *) myrealloc(NODELIST, sizeof(nodelist_t) * (count + 1));
+ NODELIST_BYNODE = (nodelist_t **) myrealloc(NODELIST_BYNODE, sizeof(nodelist_t *) * (count + 1));
+ }
+ for (i = lastcount; i < count; i++) {
+ NODELIST[i].feedfp = NULL;
+ }
+ lastcount = count;
+ NLCOUNT = 0;
+ for (ptr = NODELIST_BUF; (nodelistptr = (char *)strchr(ptr, '\n')) != NULL; ptr = nodelistptr + 1, NLCOUNT++) {
+ char *nptr, *tptr;
+ *nodelistptr = '\0';
+ NODELIST[NLCOUNT].host = "";
+ NODELIST[NLCOUNT].exclusion = "";
+ NODELIST[NLCOUNT].node = "";
+ NODELIST[NLCOUNT].protocol = "IHAVE(119)";
+ NODELIST[NLCOUNT].comments = "";
+ NODELIST_BYNODE[NLCOUNT] = NODELIST + NLCOUNT;
+ for (nptr = ptr; *nptr && isspace(*nptr);)
+ nptr++;
+ if (*nptr == '\0') {
+ bbslog("nodelist.bbs %d entry read error\n", NLCOUNT);
+ return -1;
+ }
+ /* NODELIST[NLCOUNT].id = nptr; */
+ NODELIST[NLCOUNT].node = nptr;
+ for (nptr++; *nptr && !isspace(*nptr);)
+ nptr++;
+ if (*nptr == '\0') {
+ bbslog("nodelist.bbs node %d entry read error\n", NLCOUNT);
+ return -1;
+ }
+ *nptr = '\0';
+ if ((tptr = strchr(NODELIST[NLCOUNT].node, '/'))) {
+ *tptr = '\0';
+ NODELIST[NLCOUNT].exclusion = tptr + 1;
+ } else {
+ NODELIST[NLCOUNT].exclusion = "";
+ }
+ for (nptr++; *nptr && isspace(*nptr);)
+ nptr++;
+ if (*nptr == '\0')
+ continue;
+ if (*nptr == '+' || *nptr == '-') {
+ NODELIST[NLCOUNT].feedtype = *nptr;
+ if (NODELIST[NLCOUNT].feedfp != NULL) {
+ fclose(NODELIST[NLCOUNT].feedfp);
+ }
+ if (NODELIST[NLCOUNT].feedtype == '+')
+ if (outgoing != NULL) {
+ NODELIST[NLCOUNT].feedfp = fopen((char *)fileglue("%s/out.going/%s.%s", BBSHOME, NODELIST[NLCOUNT].node, outgoing), "a");
+ }
+ nptr++;
+ } else {
+ NODELIST[NLCOUNT].feedtype = ' ';
+ }
+ NODELIST[NLCOUNT].host = nptr;
+ for (nptr++; *nptr && !isspace(*nptr);)
+ nptr++;
+ if (*nptr == '\0') {
+ continue;
+ }
+ *nptr = '\0';
+ for (nptr++; *nptr && isspace(*nptr);)
+ nptr++;
+ if (*nptr == '\0')
+ continue;
+ NODELIST[NLCOUNT].protocol = nptr;
+ for (nptr++; *nptr && !isspace(*nptr);)
+ nptr++;
+ if (*nptr == '\0')
+ continue;
+ *nptr = '\0';
+ for (nptr++; *nptr && strchr(" \t\r\n", *nptr);)
+ nptr++;
+ if (*nptr == '\0')
+ continue;
+ NODELIST[NLCOUNT].comments = nptr;
+ }
+ qsort(NODELIST, NLCOUNT, sizeof(nodelist_t), nlcmp);
+ qsort(NODELIST_BYNODE, NLCOUNT, sizeof(nodelist_t *), nl_bynodecmp);
+ return 0;
+}
+
+int
+readnffile(char *inndhome)
+{
+ FILE *fp;
+ char buff[1024];
+ struct stat st;
+ int i, count;
+ char *ptr, *newsfeedsptr;
+
+ sprintf(buff, "%s/newsfeeds.bbs", inndhome);
+ fp = fopen(buff, "r");
+ if (fp == NULL) {
+ fprintf(stderr, "open fail %s", buff);
+ return -1;
+ }
+ if (fstat(fileno(fp), &st) != 0) {
+ fprintf(stderr, "stat fail %s", buff);
+ return -1;
+ }
+ if (NEWSFEEDS_BUF == NULL) {
+ NEWSFEEDS_BUF = (char *)mymalloc(st.st_size + 1);
+ } else {
+ NEWSFEEDS_BUF = (char *)myrealloc(NEWSFEEDS_BUF, st.st_size + 1);
+ }
+ i = 0, count = 0;
+ while (fgets(buff, sizeof buff, fp) != NULL) {
+ if (buff[0] == '#')
+ continue;
+ if (buff[0] == '\n')
+ continue;
+ strcpy(NEWSFEEDS_BUF + i, buff);
+ i += strlen(buff);
+ count++;
+ }
+ fclose(fp);
+ if (NEWSFEEDS == NULL) {
+ NEWSFEEDS = (newsfeeds_t *) mymalloc(sizeof(newsfeeds_t) * (count + 1));
+ NEWSFEEDS_BYBOARD = (newsfeeds_t **) mymalloc(sizeof(newsfeeds_t *) * (count + 1));
+ } else {
+ NEWSFEEDS = (newsfeeds_t *) myrealloc(NEWSFEEDS, sizeof(newsfeeds_t) * (count + 1));
+ NEWSFEEDS_BYBOARD = (newsfeeds_t **) myrealloc(NEWSFEEDS_BYBOARD, sizeof(newsfeeds_t *) * (count + 1));
+ }
+ NFCOUNT = 0;
+ for (ptr = NEWSFEEDS_BUF; (newsfeedsptr = (char *)strchr(ptr, '\n')) != NULL; ptr = newsfeedsptr + 1, NFCOUNT++) {
+ char *nptr;
+ *newsfeedsptr = '\0';
+ NEWSFEEDS[NFCOUNT].newsgroups = "";
+ NEWSFEEDS[NFCOUNT].board = "";
+ NEWSFEEDS[NFCOUNT].path = NULL;
+ NEWSFEEDS_BYBOARD[NFCOUNT] = NEWSFEEDS + NFCOUNT;
+ for (nptr = ptr; *nptr && isspace(*nptr);)
+ nptr++;
+ if (*nptr == '\0')
+ continue;
+ NEWSFEEDS[NFCOUNT].newsgroups = nptr;
+ for (nptr++; *nptr && !isspace(*nptr);)
+ nptr++;
+ if (*nptr == '\0')
+ continue;
+ *nptr = '\0';
+ for (nptr++; *nptr && isspace(*nptr);)
+ nptr++;
+ if (*nptr == '\0')
+ continue;
+ NEWSFEEDS[NFCOUNT].board = nptr;
+ for (nptr++; *nptr && !isspace(*nptr);)
+ nptr++;
+ if (*nptr == '\0')
+ continue;
+ *nptr = '\0';
+ for (nptr++; *nptr && isspace(*nptr);)
+ nptr++;
+ if (*nptr == '\0')
+ continue;
+ NEWSFEEDS[NFCOUNT].path = nptr;
+ for (nptr++; *nptr && !strchr("\r\n", *nptr);)
+ nptr++;
+ *nptr = '\0';
+ }
+ qsort(NEWSFEEDS, NFCOUNT, sizeof(newsfeeds_t), nfcmp);
+ qsort(NEWSFEEDS_BYBOARD, NFCOUNT, sizeof(newsfeeds_t *), nf_byboardcmp);
+ return 0;
+}
+
+newsfeeds_t *
+search_board(char *board)
+{
+ newsfeeds_t nft, *nftptr, **find;
+ if (NONENEWSFEEDS)
+ return NULL;
+ nft.board = board;
+ nftptr = &nft;
+ find = (newsfeeds_t **) bsearch((char *)&nftptr, NEWSFEEDS_BYBOARD, NFCOUNT, sizeof(newsfeeds_t *), nf_byboardcmp);
+ if (find != NULL)
+ return *find;
+ return NULL;
+}
+
+nodelist_t *
+search_nodelist_bynode(char *node)
+{
+ nodelist_t nlt, *nltptr, **find;
+ if (LOCALNODELIST)
+ return NULL;
+ nlt.node = node;
+ nltptr = ≮
+ find = (nodelist_t **) bsearch((char *)&nltptr, NODELIST_BYNODE, NLCOUNT, sizeof(nodelist_t *), nl_bynodecmp);
+ if (find != NULL)
+ return *find;
+ return NULL;
+}
+
+
+nodelist_t *
+search_nodelist(char *site, char *identuser)
+{
+ nodelist_t nlt, *find;
+ char buffer[1024];
+ if (LOCALNODELIST)
+ return NULL;
+ nlt.host = site;
+ find = (nodelist_t *) bsearch((char *)&nlt, NODELIST, NLCOUNT, sizeof(nodelist_t), nlcmp);
+ if (find == NULL && identuser != NULL) {
+ sprintf(buffer, "%s@%s", identuser, site);
+ nlt.host = buffer;
+ find = (nodelist_t *) bsearch((char *)&nlt, NODELIST, NLCOUNT, sizeof(nodelist_t), nlcmp);
+ }
+ return find;
+}
+
+newsfeeds_t *
+search_group(char *newsgroup)
+{
+ newsfeeds_t nft, *find;
+ if (NONENEWSFEEDS)
+ return NULL;
+ nft.newsgroups = newsgroup;
+ find = (newsfeeds_t *) bsearch((char *)&nft, NEWSFEEDS, NFCOUNT, sizeof(newsfeeds_t), nfcmp);
+ return find;
+}
+
+char *
+ascii_date(time_t now)
+{
+ static char datebuf[40];
+ /*
+ * time_t now; time(&now);
+ */
+ strftime(datebuf, sizeof(datebuf), "%d %b %Y %X " INNTIMEZONE, gmtime(&now));
+ return datebuf;
+}
+
+char *
+restrdup(char *ptr, char *string)
+{
+ int len;
+ if (string == NULL) {
+ if (ptr != NULL)
+ *ptr = '\0';
+ return ptr;
+ }
+ len = strlen(string) + 1;
+ if (ptr != NULL) {
+ ptr = (char *)myrealloc(ptr, len);
+ } else
+ ptr = (char *)mymalloc(len);
+ strcpy(ptr, string);
+ return ptr;
+}
+
+void *
+mymalloc(int size)
+{
+ void *ptr = malloc(size);
+ if (ptr == NULL) {
+ fprintf(stderr, "cant allocate memory\n");
+ syslog(LOG_ERR, "cant allocate memory %m");
+ exit(1);
+ }
+ return ptr;
+}
+
+void *
+myrealloc(void *optr, int size)
+{
+ void *ptr = realloc(optr, size);
+ if (ptr == NULL) {
+ fprintf(stderr, "cant allocate memory\n");
+ syslog(LOG_ERR, "cant allocate memory %m");
+ exit(1);
+ }
+ return ptr;
+}
+
+void
+testandmkdir(char *dir)
+{
+ if (!dashd(dir)) {
+ char path[MAXPATHLEN + 12];
+ sprintf(path, "mkdir -p %s", dir);
+ system(path);
+ }
+}
+
+static char splitbuf[2048];
+static char joinbuf[1024];
+#define MAXTOK 50
+static char *Splitptr[MAXTOK];
+
+char **
+split(char *line, char *pat)
+{
+ char *p;
+ int i;
+
+ for (i = 0; i < MAXTOK; ++i)
+ Splitptr[i] = NULL;
+ strncpy(splitbuf, line, sizeof splitbuf - 1);
+ /* printf("%d %d\n",strlen(line),strlen(splitbuf)); */
+ splitbuf[sizeof splitbuf - 1] = '\0';
+ for (i = 0, p = splitbuf; *p && i < MAXTOK - 1;) {
+ for (Splitptr[i++] = p; *p && !strchr(pat, *p); p++);
+ if (*p == '\0')
+ break;
+ for (*p++ = '\0'; *p && strchr(pat, *p); p++);
+ }
+ return Splitptr;
+}
+
+char **
+BNGsplit(char *line)
+{
+ char **ptr = split(line, ",");
+ newsfeeds_t *nf1, *nf2;
+ char *n11, *n12, *n21, *n22;
+ int i, j;
+ for (i = 0; ptr[i] != NULL; i++) {
+ nf1 = (newsfeeds_t *) search_group(ptr[i]);