-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFILES.C
1298 lines (1215 loc) · 42.5 KB
/
FILES.C
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
/* System-dependent definitions of various files, spool directories, etc */
/* Mods by PA0GRI */
/* Modified to allow for configurable file names/locations - WG7J */
#include "global.h"
#include "netuser.h"
#include "files.h"
#include "mailbox.h"
#ifdef MD5AUTHENTICATE
#include "md5.h"
#ifndef MD5MINMATCH
#define MD5MINMATCH 16 /* # hex digits that must match; an EVEN # <= 32 */
#endif
#define MD5MINMATCHB (MD5MINMATCH/2) /* # bytes that must match */
#undef MD5DEBUG
#endif
#ifdef ENCRYPT /* kpk, encrypted password for ftpusers file */
#include <ctype.h> /* kpk, for isspace() in usercvt() */
#ifndef MD5AUTHENTICATE
#include "md5.h"
#endif
#undef ENCRYPT_DEBUG
#endif
/* kpk, added Accesswww authenication/user file for http to nos.cfg.
/etc/access.www, /etc/bootptab, /etc/bootplog, /etc/bootpdir and
/etc/bootpfile
*/
#ifdef MSDOS
char System[] = "MSDOS";
char *Startup = "/autoexec.nos"; /* Initialization file */
char *Userfile = "/ftpusers"; /* Authorized FTP users and passwords */
char *Hostfile = "/net.rc"; /* hosts and passwords */
char *Spoolqdir = "/spool"; /* Spool directory */
char *Maillog = "/spool/mail.log"; /* mail log */
char *Mailspool = "/spool/mail"; /* Incoming mail */
char *Mailqdir = "/spool/mqueue"; /* Outgoing mail spool */
char *LogsDir = "/spool/log"; /* Logs directory */
char *Mailqueue = "/spool/mqueue/*.wrk";/* Outgoing mail work files */
char *Routeqdir = "/spool/rqueue"; /* queue for router */
char *Alias = "/alias"; /* the alias file */
char *Dfile = "/domain.txt"; /* Domain cache */
char *Fdir = "/finger"; /* Finger info directory */
char *Fdbase = "/finger/dbase.dat"; /* Finger database */
char *Pdbase = "/spool/names.dat"; /* Personal names databases (IW5DHE) */
char *Arealist = "/spool/areas"; /* List of message areas */
char *Rewritefile = "/spool/rewrite"; /* TO-Address rewrite file */
#ifdef TRANSLATEFROM
char *Translatefile = "/spool/translat"; /* FROM-address rewrite file */
#endif
#ifdef SMTP_REFILE
char *Refilefile = "/spool/refile"; /* FROM|TO-address rewrite file */
#endif
#ifdef HOLD_LOCAL_MSGS
char *Holdlist = "/spool/holdlist"; /* List of areas in which locally-originated msgs are marked Held */
#endif
char *Ftpmotd = "/spool/ftpmotd.txt"; /* FTP message of the day */
char *CmdsHelpdir = "/help"; /* Console/Sysop commands help file directory */
#if defined(MAILBOX) || defined(CONVERS)
char *Helpdir = "/spool/help"; /* Mailbox help file directory */
#endif
#ifdef HTTP
char *Httpdir = "/www"; /* ABSOLUTE path to Root dir for finding www documents */
char *HttpStatsDir = "/www/stats"; /* Directory for page counters */
char *Accesswww = "/etc/access.www"; /* kpk, HTTP authenication/user file */
#ifdef HTTP_EXTLOG
char *HLogsDir = "/www/log"; /* Http log directory */
#endif
#endif /* HTTP */
#ifdef MAILBOX
char *Signature = "/spool/signatur"; /* Mail signature file directory */
char *Historyfile = "/spool/history"; /* Message ID history file */
char *Motdfile = "/spool/motd.txt"; /* Mailbox message of the day */
#ifdef USERLOG
char *UDefaults = "/spool/users.dat"; /* User preference file */
char *UDefbak = "/spool/users.bak";
char *Mregfile = "/spool/mreg.txt"; /* Mailbox registration message */
#endif
#endif /* MAILBOX */
#ifdef CONVERS
char *Cinfo = "/finger/dbase.dat"; /* Convers user info file */
#ifdef CNV_CHG_PERSONAL
char *Cinfobak = "/finger/dbase.bak"; /* Convers user info backup */
#endif
#ifdef CNV_CHAN_NAMES
char *Channelfile = "/spool/channel.dat"; /* Channel names */
#endif
char *ConvMotd = "/spool/convmotd.txt"; /* Convers Message of the Day */
#endif
#if (defined(POP2CLIENT) || defined(POP2SERVER) || defined(POP3CLIENT) || defined(POP3SERVER))
char *Popusers = "/popusers"; /* POP user and password file */
#endif
#if (defined(NNTP) || defined(NNTPS))
char *Newsdir = "/spool/news"; /* News messages and NNTP data */
char *History = "/spool/news/history"; /* NNTP article msgids and timestamps */
#endif
#if (defined(RLINE) || defined(MBFWD))
char *Forwardfile = "/spool/forward.bbs"; /* Mail forwarding file */
#endif
#ifdef NETROM
char *Netromfile = "/netrom.sav"; /* Netrom node save file */
#endif
char *Onexit = "/onexit.nos"; /* Commands to be executed on exiting */
#ifdef EXPIRY
char *Expirefile = "/spool/expire.dat"; /* Message expiration control file */
#endif
#ifdef NNTPS
char *Naccess = "/spool/news/access";
char *Active = "/spool/news/active"; /* */
char *Pointer = "/spool/news/pointer"; /* */
char *NInfo = "/spool/news/info"; /* */
char *Nhelp = "/spool/news/help"; /* */
char *Forward = "/spool/news/forward"; /* */
char *Poll = "/spool/news/poll"; /* */
char *Newstomail = "/spool/news/gateway";
#endif
#ifdef BOOTPSERVER
/* kpk, Bootpd Server files */
char *Bootptab = "/etc/bootptab";
char *Bootpdir = "/etc";
char *Bootplog = "/spool/log/bootplog";
char *Bootpfile = "/etc/default";
#endif
char Eol[] = "\r\n";
#define SEPARATOR "/"
#define ROOTDIR "/"
#endif /* MSDOS */
#ifdef UNIX
/*
* DOS compatible names now used. If you used the old names, use compat.cfg
* as a configuration file to get things working, then rename/symlink as needed
* --- the new names are the same as the old DOS ones, so it should be easy.
*
* We now use this more as a resource file than as merely a list of filenames
* (we can get away with it, where this costs precious memory in DOS). Some
* of the things found here are the default session managers for the Command
* and Trace sessions and color information (when implemented).
*/
char System[] = "UNIX";
char *Startup = "./autoexec.nos"; /* Initialization file */
char *Userfile = "./ftpusers";
char *Hostfile = "./net.rc"; /* hosts and passwords */
char *Spoolqdir = "./spool"; /* Spool directory */
char *Maillog = "./spool/mail.log"; /* mail log */
char *Mailspool = "./spool/mail";
char *Mailqdir = "./spool/mqueue";
char *LogsDir = "./logs"; /* Logs directory */
char *Mailqueue = "./spool/mqueue/*.wrk";
char *Routeqdir = "./spool/rqueue"; /* queue for router */
char *Alias = "./alias"; /* the alias file */
char *Dfile = "./domain.txt"; /* Domain cache */
char *Fdir = "./finger"; /* Finger info directory */
char *Fdbase = "./finger/dbase.dat"; /* Finger database */
char *Pdbase = "./spool/names.dat"; /* Personal names databases (IW5DHE) */
char *Arealist = "./spool/areas"; /* List of message areas */
char *Rewritefile = "./spool/rewrite"; /* TO-Address rewrite file */
#ifdef TRANSLATEFROM
char *Translatefile = "./spool/translat"; /* FROM-address rewrite file */
#endif
#ifdef SMTP_REFILE
char *Refilefile = "./spool/refile"; /* FROM|TO-address rewrite file */
#endif
#ifdef HOLD_LOCAL_MSGS
char *Holdlist = "./spool/holdlist"; /* List of areas in which locally-originated msgs are marked Held */
#endif
char *Ftpmotd = "./spool/ftpmotd.txt"; /* FTP message of the day */
char *CmdsHelpdir = "./help"; /* Console/Sysop commands help file directory */
#if defined(MAILBOX) || defined(CONVERS)
char *Helpdir = "./spool/help"; /* Mailbox help file directory */
#endif
#ifdef HTTP
char *Httpdir = "./wwwroot"; /* Root dir for finding www documents */
char *HttpStatsDir = "./wwwstats"; /* Directory for page counters */
#ifdef HTTP_EXTLOG
char *HLogsDir = "./wwwlogs"; /* Http log directory */
#endif
#endif /* HTTP */
#ifdef MAILBOX
char *Signature = "./spool/signatur"; /* Mail signature file directory */
char *Historyfile = "./spool/history"; /* Message ID history file */
char *Motdfile = "./spool/motd.txt"; /* Mailbox message of the day */
#ifdef USERLOG
char *UDefaults = "./spool/users.dat"; /* User preference file */
char *UDefbak = "./spool/users.bak";
char *Mregfile = "./spool/mreg.txt"; /* Mailbox registration message */
#endif
#endif /* MAILBOX */
#ifdef CONVERS
char *Cinfo = "./finger/dbase.dat"; /* Convers user info file */
#ifdef CNV_CHG_PERSONAL
char *Cinfobak = "./finger/dbase.bak"; /* Convers user info backup */
#endif
#ifdef CNV_CHAN_NAMES
char *Channelfile = "./spool/channel.dat"; /* Channel names */
#endif
char *ConvMotd = "./spool/convmotd.txt";
#endif
#if (defined(POP2CLIENT) || defined(POP2SERVER) || defined(POP3CLIENT) || defined(POP3SERVER))
char *Popusers = "./popusers"; /* POP user and password file */
#endif
#if (defined(NNTP) || defined(NNTPS))
char *Newsdir = "./spool/news"; /* News messages and NNTP data */
char *History = "./spool/news/history"; /* NNTP article msgids and timestamps */
#endif
#if (defined(RLINE) || defined(MBFWD))
char *Forwardfile = "./spool/forward.bbs"; /* Mail forwarding file */
#endif
#ifdef NETROM
char *Netromfile = "./netrom.sav"; /* Netrom node save file */
#endif
char *Onexit = "./onexit.nos"; /* Commands to be executed on exiting */
#ifdef EXPIRY
char *Expirefile = "./spool/expire.dat"; /* Message expiration control file */
#endif
#ifdef NNTPS
char *Naccess = "./spool/news/access";
char *Active = "./spool/news/active"; /* */
char *Pointer = "./spool/news/pointer"; /* */
char *NInfo = "./spool/news/info"; /* */
char *Nhelp = "./spool/news/help"; /* */
char *Forward = "./spool/news/forward"; /* */
char *Poll = "./spool/news/poll"; /* */
char *Newstomail = "./spool/news/gateway";
#endif /* NNTPS */
char Eol[] = "\n";
#define SEPARATOR "/"
#define ROOTDIR "."
/* default session managers */
char *Command_sessmgr = "";
char *Trace_sessmgr = "";
#endif /* UNIX */
#ifdef AMIGA
char System[] = "AMIGA";
char *Startup = "TCPIP:nos-startup";
char *Config = "TCPIP:config.nos"; /* Device configuration list */
char *Hostfile = "TCPIP:net.rc"; /* hosts and passwords */
char *Userfile = "TCPIP:ftpusers";
char *Mailspool = "TCPIP:spool/mail";
char *Maillog = "TCPIP:spool/mail.log";
char *Mailqdir = "TCPIP:spool/mqueue";
char *Mailqueue = "TCPIP:spool/mqueue/#?.wrk";
char *Routeqdir = "TCPIP:spool/rqueue"; /* queue for router */
char *Alias = "TCPIP:alias"; /* the alias file */
char *Dfile = "TCPIP:domain.txt"; /* Domain cache */
char *Fdir = "TCPIP:finger"; /* Finger info directory */
char *Fdbase = "TCPIP:finger/dbase.dat"; /* Finger database */
char *CmdsHelpdir = "TCPIP:help"; /* Console/Sysop commands help file directory */
char *Arealist = "TCPIP:spool/areas"; /* List of message areas */
char *Helpdir = "TCPIP:spool/help"; /* Mailbox help file directory */
char *Rewritefile = "TCPIP:spool/rewrite"; /* TO-Address rewrite file */
#ifdef TRANSLATEFROM
char *Translatefile = "TCPIP:spool/translat"; /* FROM-address rewrite file */
#endif
#ifdef SMTP_REFILE
char *Refilefile = "TCPIP:spool/refile"; /* FROM|TO-address rewrite file */
#endif
#ifdef HOLD_LOCAL_MSGS
char *Holdlist = "TCPIP:/spool/holdlist"; /* List of areas in which locally-originated msgs are marked Held */
#endif
#ifdef HTTP
char *Httpdir = "TCPIP:/wwwroot"; /* Root dir for finding www documents */
char *HttpStatsDir = "TCPIP:/wwwstats"; /* Directory for page counters */
#ifdef HTTP_EXTLOG
char *HLogsDir = "TCPIP:/wwwlogs"; /* Http log directory */
#endif
#endif /* HTTP */
char *Signature = "TCPIP:spool/signatur"; /* Mail signature file directory */
char *Popusers = "TCPIP:/popusers"; /* POP user and password file */
char *Newsdir = "TCPIP:spool/news"; /* News messages and NNTP data */
char *Forwardfile = "TCPIP:spool/forward.bbs"; /* Mail forwarding file */
char *Historyfile = "TCPIP:spool/history"; /* Message ID history file */
char *UDefaults = "TCPIP:spool/users.dat"; /* User preference file */
char *Netromfile = "TCPIP:netrom.sav"; /* Netrom node save file */
char *Onexit = "TCPIP:onexit.nos"; /* Commands to be executed on exiting */
char *Expirefile = "TCPIP:spool/expire.dat"; /* Message expiration control file */
#if (defined(NNTP) || defined(NNTPS))
char *History = "TCPIP:spool/news/history"; /* NNTP article msgids and timestamps */
#endif
#ifdef NNTPS
char *Active = "TCPIP:spool/news/active"; /* */
char *Pointer = "TCPIP:spool/news/pointer"; /* */
char *NInfo = "TCPIP:spool/news/info"; /* */
char *Nhelp = "TCPIP:spool/news/help"; /* */
char *Forward = "TCPIP:spool/news/forward"; /* */
char *Poll = "TCPIP:spool/news/poll"; /* */
char *Newstomail = "TCPIP:spool/news/gateway";
#endif
char Eol[] = "\r\n";
#define SEPARATOR "/"
#endif
#ifdef MAC
char System[] = "MACOS";
char *Startup = "Mikes Hard Disk:nos.start";
char *Config = "Mikes Hard Disk:config.nos"; /* Device configuration list */
char *Hostfile = "Mikes Hard Disk:net.rc"; /* hosts and passwords */
char *Userfile = "Mikes Hard Disk:ftpusers";
char *Mailspool = "Mikes Hard Disk:spool:mail:";
char *Maillog = "Mikes Hard Disk:spool:mail.log:";
char *Mailqdir = "Mikes Hard Disk:spool:mqueue:";
char *Mailqueue = "Mikes Hard Disk:spool:mqueue:*.wrk";
char *Routeqdir = "Mikes Hard Disk:spool/rqueue:"; /* queue for router */
char *Alias = "Mikes Hard Disk:alias"; /* the alias file */
char *Dfile = "Mikes Hard Disk:domain:txt"; /* Domain cache */
char *Fdir = "Mikes Hard Disk:finger"; /* Finger info directory */
char *Fdbase = "Mikes Hard Disk:finger/dbase.dat"; /* Finger database */
char *CmdsHelpdir = "Mikes Hard Disk:help"; /* Console/Sysop commands help file directory */
char *Arealist = "Mikes Hard Disk:spool/areas"; /* List of message areas */
char *Helpdir = "Mikes Hard Disk:spool/help"; /* Mailbox help file directory */
char *Rewritefile = "Mikes Hard Disk:spool/rewrite"; /* TO-Address rewrite file */
#ifdef TRANSLATEFROM
char *Translatefile = "Mikes Hard Disk:spool/translat"; /* FROM-address rewrite file */
#endif
#ifdef SMTP_REFILE
char *Refilefile = "Mikes Hard Disk:spool/refile"; /* FROM|TO-address rewrite file */
#endif
#ifdef HOLD_LOCAL_MSGS
char *Holdlist = "Mikes Hard Disk:spool/holdlist"; /* List of areas in which locally-originated msgs are marked Held */
#endif
#ifdef HTTP
char *Httpdir = "Mikes Hard Disk:/wwwroot"; /* Root dir for finding www documents */
char *HttpStatsDir = "Mikes Hard Disk:/wwwstats"; /* Directory for page counters */
#ifdef HTTP_EXTLOG
char *HLogsDir = "Mikes Hard Disk:/wwwlogs"; /* Http log directory */
#endif
#endif /* HTTP */
char *Signature = "Mikes Hard Disk:spool/signatur"; /* Mail signature file directory */
char *Popusers = "Mikes Hard Disk:/popusers"; /* POP user and password file */
char *Newsdir = "Mikes Hard Disk:spool/news"; /* News messages and NNTP data */
char *Forwardfile = "Mikes Hard Disk:spool/forward.bbs"; /* Mail forwarding file */
char *Historyfile = "Mikes Hard Disk:spool/history"; /* Message ID history file */
char *UDefaults = "Mikes Hard Disk:spool/users.dat"; /* User preference file */
char *Netromfile = "Mikes Hard Disk:netrom.sav"; /* Netrom node save file */
char *Onexit = "Mikes Hard Disk:onexit.nos"; /* Commands to be executed on exiting */
char *Expirefile = "Mikes Hard Disk:spool/expire.dat"; /* Message expiration control file */
#if (defined(NNTP) || defined(NNTPS))
char *History = "Mikes Hard Disk:spool/news/history";/* NNTP article msgids and timestamps */
#endif
#ifdef NNTPS
char *Naccess = "Mikes Hard Disk:spool/news/access";
char *Active = "Mikes Hard Disk:spool/news/active"; /* */
char *Pointer = "Mikes Hard Disk:spool/news/pointer"; /* */
char *NInfo = "Mikes Hard Disk:spool/news/info"; /* */
char *Nhelp = "Mikes Hard Disk:spool/news/help"; /* */
char *Forward = "Mikes Hard Disk:spool/news/forward"; /* */
char *Poll = "Mikes Hard Disk:spool/news/poll"; /* */
char *Newstomail = "Mikes Hard Disk:spool/news/gateway";
#endif
char Eol[] = "\r";
#define SEPARATOR ":"
#endif
static char *rootdir = ROOTDIR;
static int Assigned;
static int Initroot;
static void setname __ARGS((char *name,char *file));
static void tabs_to_spaces __ARGS((char *p));
void assign_filenames __ARGS((char *config));
extern void undosify __ARGS((char *s));
/* Establish a root directory other than the default. Can only be called
* once, at startup time
*/
void
initroot(root)
char *root;
{
if(Assigned) {
puts("-f option used, -d ignored !\n");
return;
}
#ifdef MSDOS
undosify(root);
#endif
#ifdef UNIX
/* ending '/' => chroot desired [but can find terminfo DB, etc?] */
if(root[strlen(root)-1] == '/') {
chroot(root);
root="/";
}
#endif
rootdir = strdup( root );
Startup = rootdircat(Startup);
Userfile = rootdircat(Userfile);
Hostfile = rootdircat(Hostfile);
Maillog = rootdircat(Maillog);
Spoolqdir = rootdircat(Spoolqdir);
Mailspool = rootdircat(Mailspool);
Mailqdir = rootdircat(Mailqdir);
LogsDir = rootdircat(LogsDir);
Mailqueue = rootdircat(Mailqueue);
Routeqdir = rootdircat(Routeqdir);
Alias = rootdircat(Alias);
Dfile = rootdircat(Dfile);
Fdir = rootdircat(Fdir);
Fdbase = rootdircat(Fdbase);
Pdbase = rootdircat(Pdbase);
#ifdef MAILCMDS
Arealist = rootdircat(Arealist);
#endif
Rewritefile = rootdircat(Rewritefile);
#ifdef TRANSLATEFROM
Translatefile = rootdircat(Translatefile);
#endif
#ifdef SMTP_REFILE
Refilefile = rootdircat(Refilefile);
#endif
#ifdef HOLD_LOCAL_MSGS
Holdlist = rootdircat(Holdlist);
#endif
Ftpmotd = rootdircat(Ftpmotd);
CmdsHelpdir = rootdircat(CmdsHelpdir);
#if defined(MAILBOX) || defined(CONVERS)
Helpdir = rootdircat(Helpdir);
#endif
#ifdef HTTP
/* HttpDir = rootdircat(HttpDir); would break lots of paths embedded in html docs?? */
HttpStatsDir = rootdircat(HttpStatsDir);
Accesswww = rootdircat(Accesswww); /* kpk */
#ifdef HTTP_EXTLOG
HLogsDir = rootdircat(HLogsDir);
#endif
#endif /* HTTP */
#ifdef MAILBOX
Signature = rootdircat(Signature);
Historyfile = rootdircat(Historyfile);
Motdfile = rootdircat(Motdfile);
#ifdef USERLOG
UDefaults = rootdircat(UDefaults);
UDefbak = rootdircat(UDefbak);
Mregfile = rootdircat(Mregfile);
#endif
#endif
#ifdef CONVERS
Cinfo = rootdircat(Cinfo);
#ifdef CNV_CHG_PERSONAL
Cinfobak = rootdircat(Cinfobak);
#endif
#ifdef CNV_CHAN_NAMES
Channelfile = rootdircat(Channelfile);
#endif
ConvMotd = rootdircat(ConvMotd);
#endif
#if (defined(POP) || defined(POP2CLIENT) || defined(POP2SERVER) || defined(POP3CLIENT) || defined(POP3SERVER))
Popusers = rootdircat(Popusers);
#endif
#if (defined(NNTP) || defined(NNTPS))
Newsdir = rootdircat(Newsdir);
History = rootdircat(History);
#endif
#if (defined(MBFWD) || defined(RLINE))
Forwardfile = rootdircat(Forwardfile);
#endif
#ifdef NETROM
Netromfile = rootdircat(Netromfile);
#endif
Onexit = rootdircat(Onexit);
#ifdef EXPIRY
Expirefile = rootdircat(Expirefile);
#endif
#ifdef NNTPS
Naccess = rootdircat(Naccess);
Active = rootdircat(Active);
Pointer = rootdircat(Pointer);
NInfo = rootdircat(NInfo);
Nhelp = rootdircat(Nhelp);
Forward = rootdircat(Forward);
Poll = rootdircat(Poll);
Newstomail = rootdircat(Newstomail);
#endif
#ifdef BOOTPSERVER
/* kpk, Bootpd Server files */
Bootptab = rootdircat(Bootptab);
Bootpdir = rootdircat(Bootpdir);
Bootplog = rootdircat(Bootplog);
Bootpfile = rootdircat(Bootpfile);
#endif
Initroot = 1;
}
/* Concatenate root, separator and arg strings into a malloc'ed output
* buffer, then remove repeated occurrences of the separator char
*/
char *
rootdircat(filename)
char *filename;
{
char *out = filename;
if(strlen(rootdir) > 0){
char *separator = SEPARATOR;
out = mallocw(strlen(rootdir)
+ strlen(separator)
+ strlen(filename) +1);
strcpy(out,rootdir);
strcat(out,separator);
strcat(out,filename);
if(*separator != '\0'){
char *p1, *p2;
/* Remove any repeated occurrences */
p1 = p2 = out;
while(*p2 != '\0'){
*p1++ = *p2++;
#ifdef UNIX
while(p2[-1] == *separator && p2[0] == '.' && p2[1] == *separator)
p2 += 2; /* replace "/./" by "/" */
#endif
while(p2[0] == p2[-1] && p2[0] == *separator)
p2++;
}
*p1 = '\0';
}
}
return out;
}
#ifdef PPP
#ifdef notdef
/* Read through FTPUSERS looking for user record
* Returns line which matches username, or NULLCHAR when no match.
* Each of the other variables must be copied before freeing the line.
*/
char *
userlookup(username,password,directory,permission,ip_address)
char *username;
char **password;
char **directory;
long *permission;
int32 *ip_address;
{
FILE *fp;
char *buf;
char *cp;
if((fp = fopen(Userfile,READ_TEXT)) == NULLFILE)
/* Userfile doesn't exist */
return NULLCHAR;
buf = mallocw(128);
while ( fgets(buf,128,fp) != NULLCHAR ){
if(*buf == '#')
continue; /* Comment */
if((cp = strchr(buf,' ')) == NULLCHAR)
/* Bogus entry */
continue;
*cp++ = '\0'; /* Now points to password */
if( stricmp(username,buf) == 0 )
break; /* Found user */
}
if(feof(fp)){
/* username not found in file */
fclose(fp);
free(buf);
return NULLCHAR;
}
fclose(fp);
if ( password != NULL )
*password = cp;
/* Look for space after password field in file */
if((cp = strchr(cp,' ')) == NULLCHAR) {
/* Invalid file entry */
free(buf);
return NULLCHAR;
}
*cp++ = '\0'; /* Now points to directory field */
if ( directory != NULL )
*directory = cp;
if((cp = strchr(cp,' ')) == NULLCHAR) {
/* Permission field missing */
free(buf);
return NULLCHAR;
}
*cp++ = '\0'; /* now points to permission field */
if (permission != NULL )
*permission = strtol( cp, NULLCHARP, 0 );
if((cp = strchr(cp,' ')) == NULLCHAR) {
/* IP address missing */
if ( ip_address != NULL )
*ip_address = 0L;
} else {
*cp++ = '\0'; /* now points at IP address field */
if ( ip_address != NULL )
*ip_address = resolve( cp );
}
return buf;
}
#endif
/* Read through FTPUSERS looking for user record
* Returns line which matches username, or NULLCHAR when no match.
* Each of the other variables must be copied before freeing the line.
*/
char *
userlookup(username,password,directory,permission,ip_address)
char *username;
char **password;
char **directory;
long *permission;
int32 *ip_address;
{
FILE *fp;
char *buf;
char *cp;
char *universal = NULLCHAR;
char *defalt = NULLCHAR;
static char fdelims[] = " \t\n";
if((fp = fopen(Userfile,READ_TEXT)) == NULLFILE)
/* Userfile doesn't exist */
return NULLCHAR;
buf = mallocw(128);
while ( fgets(buf,128,fp) != NULLCHAR ){
if(*buf == '#')
continue; /* Comment */
if((cp = strpbrk(buf," \t")) == NULLCHAR)
/* Bogus entry */
continue;
*cp++ = '\0'; /* Now points to password */
if( stricmp(username,buf) == 0 )
break; /* Found user */
if(stricmp("univperm",buf) == 0)
universal = strdup(cp); /* remember their anon entry */
if(stricmp("pppperm",buf) == 0)
defalt = strdup(cp); /* remember their ppp default entry */
}
if(feof(fp)) { /* no explicit match */
if((universal == NULLCHAR) && (defalt == NULLCHAR)){
/* User name not found in file, nor was pppperm nor univperm */
fclose(fp);
free(buf);
return NULLCHAR;
}
*buf='\0'; /* null username => pppperm or univperm entry used */
if(defalt != NULLCHAR) /* restore pppperm entry to the buffer */
strcpy(cp = buf+1, defalt);
else
strcpy(cp = buf+1, universal);
}
free(universal); /* OK if NULL */
free(defalt);
fclose(fp);
cp = strtok(cp,fdelims);
if ( password != NULL )
*password = cp;
/* Look for space or tab after password field in file */
if((cp = strtok(NULL,fdelims)) == NULLCHAR) {
/* Invalid file entry */
free(buf);
return NULLCHAR;
}
if ( directory != NULL )
*directory = cp;
if((cp = strtok(NULL,fdelims)) == NULLCHAR) {
/* Permission field missing */
free(buf);
return NULLCHAR;
}
if ( permission != NULL ) {
if(!strnicmp(cp,"0x",2))
*permission = htol(cp);
else
*permission = atol(cp);
}
if((cp = strtok(NULL,fdelims)) == NULLCHAR) {
/* IP address missing */
if ( ip_address != NULL )
*ip_address = 0L;
} else {
if ( ip_address != NULL )
*ip_address = resolve( cp );
}
return buf;
}
#endif /* PPP */
/* Subroutine for logging in the user whose name is <name> and password is <pass>.
The buffer <path> should be long enough to keep a line from the userfile.
If <pwdignore> is true, the password check will be overridden.
<defname> is the string to be used prior to "univperm" for assigning
default permissions.
The return value is the permissions field or -1 if the login failed.
<path> is set to point at the path field, and <pwdignore> will be true if no
particular password was needed for this user.
The format of a line in the ftpusers file is:
# this is a comment line
name password rootdirlist1 perm1 rootdirlist2 perm2 ...
where rootdirlist is a semicolon-separated list of directories. We don't
verify this here, though, and we return the FIRST permissions value found.
MD5 extensions: the challenge that was issued, an int32, is passed in the
first 4 bytes of <path>. If <pass> doesn't match as a plain-text passwd,
we compute a MD5 sum of (challenge+opt+true_password) and compare to <pass>,
interpreted as hex digits. Only the first MD5MINMATCH hex digits must
match. "opt" is only used when we were asked to validate an ftp access
(<defname>=="ftpperm"), and is replaced by a "-". If the ftp user is found
to have used a leading "-" in the passwd, we set bit 2^7 in the returned
integer <pwdignore>. -- n5knx
*/
long
userlogin(name,pass,path,len,pwdignore,defname)
char *name;
char *pass;
char **path;
int len; /* Length of buffer pointed at by *path */
int *pwdignore;
char *defname;
{
char *cp;
FILE *fp;
char *universal = NULLCHAR;
char *defalt = NULLCHAR;
static char FTPPERM[] = "ftpperm";
long perm;
char *line,*user,*password,*privs,*directory;
#ifdef ENCRYPT
char hashpass[16];
int s;
#ifndef MD5AUTHENTICATE
MD5_CTX md;
#endif
#endif
#ifdef MD5AUTHENTICATE
int32 challenge;
MD5_CTX md;
int i,j;
memcpy((char *)&challenge, *path, sizeof(challenge));
#endif /* MD5AUTHENTICATE */
/* Check environment variables first - WG7J (incompatible with MD5) */
if((user=getenv("NOSSYSOP")) != NULL) {
if(strcmp(user,name) == 0) {
/* the right user name, now check password */
if((password=getenv("NOSPASSWD")) != NULL) {
if(*pwdignore || strcmp(password,pass) == 0) {
*pwdignore = 0;
if((directory=getenv("NOSPATH")) != NULL)
strcpy(*path,directory);
if((privs=getenv("NOSPRIVS")) != NULL) {
if(strnicmp(privs,"0x",2) == 0)
return htol(privs);
else
return atol(privs);
} else
return (FTP_READ + \
FTP_CREATE + \
FTP_WRITE + \
AX25_CMD + \
TELNET_CMD + \
NETROM_CMD + \
SYSOP_CMD + \
IS_EXPERT);
}
}
}
}
if((fp = fopen(Userfile,READ_TEXT)) == NULLFILE) {
/* Userfile doesn't exist */
*pwdignore = 0;
return -1;
}
while(fgets(*path,len,fp),!feof(fp)){
line = skipwhite(*path);
if(*line == '#')
continue; /* Comment */
if((password = strpbrk(line," \t")) == NULLCHAR)
/* Bogus entry */
continue;
rip(line);
*password++ = '\0';
/* Now points to spaces or tabs before password */
password = skipwhite(password);
/* Now points to password */
if(stricmp(name,line) == 0)
break; /* Found user name */
if(stricmp("univperm",line) == 0)
universal = strdup(password); /* remember their anon entry */
if(stricmp(defname,line) == 0)
defalt = strdup(password); /* remember their default entry */
}
if(feof(fp)) { /* no explicit match */
if((universal == NULLCHAR) && (defalt == NULLCHAR)){
/* User name not found in file, nor was default nor univperm */
fclose(fp);
/* No need to free universal/default ( == NULLCHAR ) remember !!! */
return -1;
}
else if(defalt != NULLCHAR){
/* restore defname to the buffer */
strcpy(password = *path, defalt);
}
else {
/* restore anonymous to the buffer */
strcpy(password = *path, universal);
}
}
free(universal); /* OK if NULLCHAR ... free() just returns */
free(defalt);
#ifdef MSDOS
if(feof(fp)) {
/* n5knx: When default or universal entry is used, we must disallow
login if userid was > 8 chars long, since otherwise MSDOS will truncate
it to 8 when used as a mailbox name, and we may then access another's
mailbox! A long userid is OK for ftp purposes, though.
*/
if (strlen(name) > 8 && strcmp(defname,FTPPERM)) {
fclose(fp);
return -1;
}
}
#endif /* MSDOS */
fclose(fp);
/* Look for space or tab after password field in file */
if((directory = strpbrk(password," \t")) == NULLCHAR)
/* Invalid file entry */
return -1;
*directory++ = '\0'; /* Terminate password */
/* Find start of path */
directory = skipwhite(directory);
if(strlen(directory) + 1 > len )
/* not enough room for path */
return -1;
if(strcmp(password,"*") == 0)
*pwdignore = 1; /* User ID is password-free */
/* Password required, see if it's encryted */
#ifdef ENCRYPT /* kpk, sof encrypt */
if(!(*pwdignore) && (strcmp(password, "*") != 0) && (strlen(password) >= 32)) {
if(readhex(hashpass,password,sizeof(hashpass)) != sizeof(hashpass)){
/* Invalid hashed password in file, log it and return */
log(-1,"Readhex: Password failure: %s\n", password);
return -1;
}
#ifdef ENCRYPT_DEBUG
printf("\nEncrypted_Password: %s\n", password);
printf("\HashPassword: %s\n", hashpass);
printf("\Password: %s\n", pass);
#endif
/* replace hashed passwd with plaintext passwd to remain compatible with jnos */
if((hashpass != NULLCHAR) && (strlen(hashpass) <= 16)) {
password = hashpass;
} else {
log(-1,"Readhex: Hash Password failure: %s\n", hashpass);
return -1;
}
}
#endif
/*kpk eof encrypt*/
/* now return to md5 authenication, for jnos systems challenge */
if(!(*pwdignore) && strcmp(password,pass) != 0) {
#ifdef MD5AUTHENTICATE
/* See if it is the response to a challenge */
if(strlen(pass) >= MD5MINMATCH) { /* kpk, pass -> password */
MD5Init(&md);
MD5Update(&md,(unsigned char *)&challenge,sizeof(challenge));
MD5Update(&md,(unsigned char *)password,strlen(password));
MD5Final(&md);
/* #endif
#ifdef MD5AUTHENTICATE
*/
#ifdef MD5DEBUG
printf("auth: challenge %lx, passwd %s\nMD5 sum is ", challenge, password);
for(i=0; i<16; i++)
printf("%02x",md.digest[i]);
printf("\n");
#endif
for(cp=pass,i=0; i<MD5MINMATCHB; cp+=2,i++) {
sscanf(cp,"%2x",&j);
if (md.digest[i] != (unsigned char)j)
return -1; /* give up at first miscompare */
}
/* MD5(challenge+passwd_from_ftpusers) matches! */
}
else return -1;
#else
return -1;
#endif /* MD5AUTHENTICATE */
}
/* Find permission field */
if((privs = strpbrk(directory," \t")) == NULLCHAR)
/* Permission field missing */
return -1;
/* Find start of permissions */
privs = skipwhite(privs);
if(!strnicmp(privs,"0x",2))
perm = htol(privs);
else
perm = atol(privs);
/* Now copy the compound path, with possibly multiple paths and permissions */
for (cp = directory; *cp; cp++) /* allow '=' prefix to flag ftp homedir ... Selcuk */
if (*cp == '\t') *cp = ' '; /* by changing existing tabs to spaces */
else if (*cp == '=') *cp = '\t'; /* and change '=' to the only tab */
strcpy(*path,directory);
dirformat(*path);
/* Finally return the permission bits */
return perm;
}
#ifdef MD5AUTHENTICATE
char *
md5sum(long challenge, char *s)
{
int i;
MD5_CTX md;
static char hexsig[33];
char *cp;
MD5Init(&md);
MD5Update(&md,(unsigned char *)&challenge,sizeof(challenge));
MD5Update(&md,(unsigned char *)s,strlen(s));
MD5Final(&md);
for(i=0, cp=hexsig; i<MD5MINMATCHB; i++, cp+=2)
sprintf(cp,"%02x",md.digest[i]);
#ifdef MD5DEBUG
printf("md5sum: %lx + %s :> %s\n", challenge, s, hexsig);
#endif
return hexsig;
}
#endif
struct Nosfiles {
char *name;
char **path;
};
static struct Nosfiles DFAR Nfiles[] = {
"Startup",&Startup,
"Userfile",&Userfile,
"Hostfile",&Hostfile,
"Spoolqdir",&Spoolqdir,
"Maillog",&Maillog,
"Mailspool",&Mailspool,
"Mailqdir",&Mailqdir,
"LogsDir",&LogsDir,
"Mailqueue",&Mailqueue,
"Routeqdir",&Routeqdir,
"Alias",&Alias,
"Dfile",&Dfile,
"Fdir",&Fdir,
"Fdbase",&Fdbase,
"Pdbase",&Pdbase,
"Rewritefile",&Rewritefile,
#ifdef TRANSLATEFROM
"Translatefile",&Translatefile,
#endif
#ifdef SMTP_REFILE
"Refilefile",&Refilefile,
#endif
#ifdef HOLD_LOCAL_MSGS
"Holdlist",&Holdlist,
#endif
"Onexit",&Onexit,
"Ftpmotd",&Ftpmotd,
"CmdsHelpdir",&CmdsHelpdir,
#if defined(MAILBOX) || defined(CONVERS)
"Helpdir",&Helpdir,
#endif
#ifdef HTTP
"HttpDir",&Httpdir,