home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume19 / cnews2 / part14 < prev    next >
Encoding:
Internet Message Format  |  1989-06-29  |  48.4 KB

  1. Subject:  v19i091:  Cnews production release, Part14/19
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: utzoo!henry
  7. Posting-number: Volume 19, Issue 91
  8. Archive-name: cnews2/part14
  9.  
  10. : ---CUT HERE---
  11. echo 'nntpdiffs/cdiff.1.5.5':
  12. sed 's/^X//' >'nntpdiffs/cdiff.1.5.5' <<'!'
  13. XOnly in .: Cnews.diff
  14. XCommon subdirectories: ../nntp.1.5.5/common and ./common
  15. XCommon subdirectories: ../nntp.1.5.5/doc and ./doc
  16. XCommon subdirectories: ../nntp.1.5.5/inews and ./inews
  17. XCommon subdirectories: ../nntp.1.5.5/rrnpatches and ./rrnpatches
  18. XCommon subdirectories: ../nntp.1.5.5/server and ./server
  19. XCommon subdirectories: ../nntp.1.5.5/support and ./support
  20. XCommon subdirectories: ../nntp.1.5.5/xfer and ./xfer
  21. XCommon subdirectories: ../nntp.1.5.5/xmit and ./xmit
  22. Xdiff -c -r ../nntp.1.5.5/server/Makefile ./server/Makefile
  23. X*** ../nntp.1.5.5/server/Makefile    Tue Jun  6 22:46:14 1989
  24. X--- ./server/Makefile    Tue Jun  6 23:33:45 1989
  25. X***************
  26. X*** 3,8 ****
  27. X--- 3,9 ----
  28. X  #
  29. X  
  30. X  SRVROBJ = main.o serve.o access.o access_inet.o access_dnet.o active.o \
  31. X+     batch.o \
  32. X      ahbs.o globals.o group.o help.o ihave.o list.o misc.o netaux.o \
  33. X      newgroups.o newnews.o nextlast.o ngmatch.o post.o parsit.o scandir.o \
  34. X      slave.o spawn.o strcasecmp.o subnet.o time.o xhdr.o fakesyslog.o \
  35. X***************
  36. X*** 9,14 ****
  37. X--- 10,16 ----
  38. X      ../common/version.o
  39. X  
  40. X  SRVRSRC = main.c serve.c access.c access_inet.c access_dnet.c active.c \
  41. X+     batch.c \
  42. X      ahbs.c globals.c group.c help.c ihave.c list.c misc.c netaux.c \
  43. X      newgroups.c newnews.c nextlast.c ngmatch.c post.c parsit.c scandir.c \
  44. X      slave.c spawn.c strcasecmp.c subnet.c time.c xhdr.c fakesyslog.c \
  45. X***************
  46. X*** 19,25 ****
  47. X  SRCS    = ${SRVRSRC}
  48. X  
  49. X  # -ldbm here if you've #define'ed DBM in ../common/conf.h
  50. X! LIBS    =
  51. X  
  52. X  CFLAGS    = -O
  53. X  
  54. X--- 21,27 ----
  55. X  SRCS    = ${SRVRSRC}
  56. X  
  57. X  # -ldbm here if you've #define'ed DBM in ../common/conf.h
  58. X! LIBS    = -ldbm
  59. X  
  60. X  CFLAGS    = -O
  61. X  
  62. XOnly in ./server: batch.c
  63. Xdiff -c -r ../nntp.1.5.5/server/ihave.c ./server/ihave.c
  64. X*** ../nntp.1.5.5/server/ihave.c    Tue Jun  6 22:46:12 1989
  65. X--- ./server/ihave.c    Tue Jun  6 23:47:02 1989
  66. X***************
  67. X*** 52,59 ****
  68. X          (void) strcat(errbuf, " NNTP server out of space. Try later.");
  69. X  
  70. X          retcode = 0;        /* indicates that an error occurred */
  71. X!     } else retcode =
  72. X!         spawn(rnews, "rnews", (char *) 0, CONT_XFER, ERR_XFERFAIL, errbuf);
  73. X  
  74. X      if (retcode <= 0)
  75. X          printf("%d %s\r\n", ERR_XFERFAIL, errbuf);
  76. X--- 52,65 ----
  77. X          (void) strcat(errbuf, " NNTP server out of space. Try later.");
  78. X  
  79. X          retcode = 0;        /* indicates that an error occurred */
  80. X!     } else 
  81. X! #ifdef UNBATCHED_INPUT
  82. X!         retcode = spawn(rnews, "rnews", (char *) 0, CONT_XFER,
  83. X!                 ERR_XFERFAIL, errbuf);
  84. X! #else
  85. X!         /* C news input hook */
  86. X!         retcode = batch_input_article(CONT_XFER, ERR_XFERFAIL, errbuf);
  87. X! #endif
  88. X  
  89. X      if (retcode <= 0)
  90. X          printf("%d %s\r\n", ERR_XFERFAIL, errbuf);
  91. Xdiff -c -r ../nntp.1.5.5/server/misc.c ./server/misc.c
  92. X*** ../nntp.1.5.5/server/misc.c    Tue Jun  6 22:46:12 1989
  93. X--- ./server/misc.c    Tue Jun  6 23:33:46 1989
  94. X***************
  95. X*** 80,86 ****
  96. X   *
  97. X   *    Side effects:    opens dbm database
  98. X   *            (only once, keeps it open after that).
  99. X-  *            Converts "msg_id" to lower case.
  100. X   */
  101. X  
  102. X  #ifndef NDBM
  103. X--- 80,85 ----
  104. X***************
  105. X*** 113,122 ****
  106. X      datum         key, content;
  107. X  #endif USGHIST
  108. X      static FILE    *hfp = NULL;    /* history file, text version */
  109. X- 
  110. X-     for (cp = msg_id; *cp != '\0'; ++cp)
  111. X-         if (isupper(*cp))
  112. X-             *cp = tolower(*cp);
  113. X  
  114. X  #ifdef USGHIST
  115. X      hfp = fopen(histfile(msg_id), "r");
  116. X--- 112,117 ----
  117. Xdiff -c -r ../nntp.1.5.5/server/newnews.c ./server/newnews.c
  118. X*** ../nntp.1.5.5/server/newnews.c    Tue Jun  6 22:48:36 1989
  119. X--- ./server/newnews.c    Tue Jun  6 23:33:46 1989
  120. X***************
  121. X*** 249,257 ****
  122. X   *    Side effects:    Seeks in history file, modifies line.
  123. X   */
  124. X  
  125. X! seekuntil(fp, key, line, linesize)
  126. X      FILE        *fp;
  127. X!     char        *key;
  128. X      char        *line;
  129. X      int        linesize;
  130. X  {
  131. X--- 249,257 ----
  132. X   *    Side effects:    Seeks in history file, modifies line.
  133. X   */
  134. X  
  135. X! seekuntil(fp, akey, line, linesize)
  136. X      FILE        *fp;
  137. X!     char        *akey;
  138. X      char        *line;
  139. X      int        linesize;
  140. X  {
  141. X***************
  142. X*** 258,264 ****
  143. X--- 258,267 ----
  144. X      char        datetime[32];
  145. X      register int    c;
  146. X      register long    top, bot, mid;
  147. X+     extern long dtol();
  148. X+     char key[30];
  149. X  
  150. X+     (void) sprintf(key, "%ld", dtol(akey));    /* akey -> time_t in ascii */
  151. X      bot = 0;
  152. X      (void) fseek(fp, 0L, 2);
  153. X      top = ftell(fp);
  154. X***************
  155. X*** 321,326 ****
  156. X--- 324,332 ----
  157. X  }
  158. X  
  159. X  
  160. X+ /*
  161. X+  * C news version of getword.
  162. X+  */
  163. X  getword(fp, w, line, linesize)
  164. X      FILE        *fp;
  165. X      register char    *w;
  166. X***************
  167. X*** 328,363 ****
  168. X      int        linesize;
  169. X  {
  170. X      register char    *cp;
  171. X  
  172. X      if (fgets(line, linesize, fp) == NULL)
  173. X          return (0);
  174. X!     if (cp = index(line, '\t')) {
  175. X! /*
  176. X!  * The following gross hack is present because the history file date
  177. X!  * format is braindamaged.  They like "mm/dd/yy hh:mm", which is useless
  178. X!  * for relative comparisons of dates using something like atoi() or
  179. X!  * strcmp.  So, this changes their format into yymmddhhmm.  Sigh.
  180. X!  *
  181. X!  * 12345678901234    ("x" for cp[x])
  182. X!  * mm/dd/yy hh:mm     (their lousy representation)
  183. X!  * yymmddhhmm        (our good one)
  184. X!  * 0123456789        ("x" for w[x])
  185. X!  */
  186. X!         *cp = '\0';
  187. X!         (void) strncpy(w, cp+1, 15);
  188. X!         w[0] = cp[7];        /* Years */
  189. X!         w[1] = cp[8];
  190. X!         w[2] = cp[1];        /* Months */
  191. X!         w[3] = cp[2];
  192. X!         w[4] = cp[4];        /* Days */
  193. X!         w[5] = cp[5];
  194. X!         w[6] = cp[10];        /* Hours */
  195. X!         w[7] = cp[11];
  196. X!         w[8] = cp[13];        /* Minutes */
  197. X!         w[9] = cp[14];
  198. X!         w[10] = '\0';
  199. X!     } else
  200. X!         w[0] = '\0';
  201. X      return (1);
  202. X  }
  203. X  
  204. X--- 334,356 ----
  205. X      int        linesize;
  206. X  {
  207. X      register char    *cp;
  208. X+     extern char *index();
  209. X  
  210. X      if (fgets(line, linesize, fp) == NULL)
  211. X          return (0);
  212. X!     w[0] = '\0';                /* in case of bad format */
  213. X!     if (cp = index(line, '\t')) {        /* find 2nd field */
  214. X!         register char *endp;
  215. X! 
  216. X!         *cp++ = '\0';
  217. X!         endp = index(cp, '~');        /* end of date-received */
  218. X!         if (endp == NULL)
  219. X!             endp = index(cp, '\t');    /* end of expiry */
  220. X!         if (endp != NULL) {
  221. X!             (void) strncpy(w, cp, endp - cp);
  222. X!             w[endp - cp] = '\0';
  223. X!         }
  224. X!     }
  225. X      return (1);
  226. X  }
  227. X  
  228. Xdiff -c -r ../nntp.1.5.5/server/serve.c ./server/serve.c
  229. X*** ../nntp.1.5.5/server/serve.c    Tue Jun  6 22:48:36 1989
  230. X--- ./server/serve.c    Tue Jun  6 23:41:46 1989
  231. X***************
  232. X*** 263,268 ****
  233. X--- 263,279 ----
  234. X  
  235. X      (void) fflush(stdout);
  236. X  
  237. X+       (void) fflush(stdout);
  238. X+ 
  239. X+ #ifndef UNBATCHED_INPUT
  240. X+     {
  241. X+         char errbuf[2 * NNTP_STRLEN];
  242. X+   
  243. X+         enqpartbatch(CONT_XFER, ERR_XFERFAIL, errbuf);
  244. X+     }
  245. X+ #endif
  246. X+ 
  247. X+ 
  248. X  #ifdef LOG
  249. X      if (ferror(stdout))
  250. X          syslog(LOG_ERR, "%s disconnect: %m", hostname);
  251. X***************
  252. X*** 311,317 ****
  253. X  #ifdef PROFILE
  254. X      profile();
  255. X  #endif
  256. X- 
  257. X      exit(0);
  258. X  }
  259. X  
  260. X--- 322,327 ----
  261. !
  262. echo 'relay/regress/out/active':
  263. sed 's/^X//' >'relay/regress/out/active' <<'!'
  264. Xcontrol 0000000001 00000 y
  265. Xjunk 0000000000 00000 y
  266. Xfoo 0000000000 00000 y
  267. Xbar 0000000000 00000 y
  268. Xtest.a 0000000002 00000 y
  269. Xtest.b 0000000002 00000 y
  270. Xtest.c 0000000001 00000 y
  271. Xbaz 0000000000 00000 y
  272. !
  273. echo 'relay/regress/out/art1':
  274. sed 's/^X//' >'relay/regress/out/art1' <<'!'
  275. XPath: host!user
  276. XFrom: user@host
  277. XMessage-ID: <#1@host>
  278. XNewsgroups: test.a
  279. X
  280. X## This should appear in test/a/1
  281. !
  282. echo 'relay/regress/out/art2':
  283. sed 's/^X//' >'relay/regress/out/art2' <<'!'
  284. XPath: host!user
  285. XFrom: user@host
  286. XMessage-ID: <#2@host>
  287. XNewsgroups: test.b
  288. X
  289. X## This should appear in test/b/1
  290. !
  291. echo 'relay/regress/out/art3':
  292. sed 's/^X//' >'relay/regress/out/art3' <<'!'
  293. XPath: host!user
  294. XFrom: user@host
  295. XMessage-ID: <#3@host>
  296. XNewsgroups: test.a,test.b
  297. X
  298. X## This should appear in test/a/2
  299. X## This should appear in test/b/2
  300. !
  301. echo 'relay/regress/out/art4':
  302. sed 's/^X//' >'relay/regress/out/art4' <<'!'
  303. XPath: host!user
  304. XFrom: user@host
  305. XMessage-ID: <#4@host>
  306. XNewsgroups: test.c
  307. X
  308. XThis should get cancelled.
  309. !
  310. echo 'relay/regress/out/art5':
  311. sed 's/^X//' >'relay/regress/out/art5' <<'!'
  312. XPath: host!user
  313. XFrom: user@host
  314. XMessage-ID: <#5@host>
  315. XNewsgroups: test.c
  316. XControl: cancel <#4@host>
  317. X
  318. X## This should appear in test/c/2
  319. !
  320. echo 'relay/regress/out/batch':
  321. sed 's/^X//' >'relay/regress/out/batch' <<'!'
  322. X#! rnews 108
  323. XPath: host!user
  324. XFrom: user@host
  325. XMessage-ID: <#1@host>
  326. XNewsgroups: test.a
  327. X
  328. X## This should appear in test/a/1
  329. X#! rnews 108
  330. XPath: host!user
  331. XFrom: user@host
  332. XMessage-ID: <#2@host>
  333. XNewsgroups: test.b
  334. X
  335. X## This should appear in test/b/1
  336. X#! rnews 149
  337. XPath: host!user
  338. XFrom: user@host
  339. XMessage-ID: <#3@host>
  340. XNewsgroups: test.a,test.b
  341. X
  342. X## This should appear in test/a/2
  343. X## This should appear in test/b/2
  344. X#! rnews 101
  345. XPath: host!user
  346. XFrom: user@host
  347. XMessage-ID: <#4@host>
  348. XNewsgroups: test.c
  349. X
  350. XThis should get cancelled.
  351. X#! rnews 134
  352. XPath: host!user
  353. XFrom: user@host
  354. XMessage-ID: <#5@host>
  355. XNewsgroups: test.c
  356. XControl: cancel <#4@host>
  357. X
  358. X## This should appear in test/c/2
  359. !
  360. echo 'relay/regress/out/errlog':
  361. sed 's/^X//' >'relay/regress/out/errlog' <<'!'
  362. !
  363. echo 'relay/regress/out/history':
  364. sed 's/^X//' >'relay/regress/out/history' <<'!'
  365. X<#1@host>    TIME~-    test.a/1
  366. X<#2@host>    TIME~-    test.b/1
  367. X<#3@host>    TIME~-    test.a/2 test.b/2
  368. X<#4@host>    TIME~-    test.c/1
  369. X<#5@host>    TIME~-    control/1
  370. !
  371. echo 'relay/regress/out/log':
  372. sed 's/^X//' >'relay/regress/out/log' <<'!'
  373. XTIME host + <#1@host> foo
  374. XTIME host + <#2@host> foo
  375. XTIME host + <#3@host> foo
  376. XTIME host + <#4@host> foo
  377. XTIME host + <#5@host> foo
  378. !
  379. echo 'relay/regress/out/run':
  380. sed 's/^X//' >'relay/regress/out/run' <<'!'
  381. X#! /bin/sh
  382. X# run relaynews test
  383. Xhere=`pwd`
  384. XNEWSARTS=$here
  385. XNEWSBIN=$here
  386. XNEWSCTL=$here
  387. Xexport NEWSARTS NEWSBIN NEWSCTL
  388. X
  389. X./relaynews -r <batch >stdout 2>stderr
  390. Xecho $? >status
  391. !
  392. echo 'relay/regress/out/sys':
  393. sed 's/^X//' >'relay/regress/out/sys' <<'!'
  394. XME:all
  395. Xfoo:all:f:/dev/null
  396. !
  397. echo 'relay/regress/out/whoami':
  398. sed 's/^X//' >'relay/regress/out/whoami' <<'!'
  399. Xhostb
  400. !
  401. echo 'relay/regress/out/stdout':
  402. sed 's/^X//' >'relay/regress/out/stdout' <<'!'
  403. !
  404. echo 'relay/regress/out/stderr':
  405. sed 's/^X//' >'relay/regress/out/stderr' <<'!'
  406. !
  407. echo 'relay/regress/out/test/a/1':
  408. sed 's/^X//' >'relay/regress/out/test/a/1' <<'!'
  409. XPath: hostb!host!user
  410. XFrom: user@host
  411. XMessage-ID: <#1@host>
  412. XNewsgroups: test.a
  413. X
  414. X## This should appear in test/a/1
  415. !
  416. echo 'relay/regress/out/test/a/2':
  417. sed 's/^X//' >'relay/regress/out/test/a/2' <<'!'
  418. XXref: hostb test.a:2 test.b:2
  419. XPath: hostb!host!user
  420. XFrom: user@host
  421. XMessage-ID: <#3@host>
  422. XNewsgroups: test.a,test.b
  423. X
  424. X## This should appear in test/a/2
  425. X## This should appear in test/b/2
  426. !
  427. echo 'relay/regress/out/test/b/1':
  428. sed 's/^X//' >'relay/regress/out/test/b/1' <<'!'
  429. XPath: hostb!host!user
  430. XFrom: user@host
  431. XMessage-ID: <#2@host>
  432. XNewsgroups: test.b
  433. X
  434. X## This should appear in test/b/1
  435. !
  436. echo 'relay/regress/out/test/b/2':
  437. sed 's/^X//' >'relay/regress/out/test/b/2' <<'!'
  438. XXref: hostb test.a:2 test.b:2
  439. XPath: hostb!host!user
  440. XFrom: user@host
  441. XMessage-ID: <#3@host>
  442. XNewsgroups: test.a,test.b
  443. X
  444. X## This should appear in test/a/2
  445. X## This should appear in test/b/2
  446. !
  447. echo 'relay/regress/out/control/1':
  448. sed 's/^X//' >'relay/regress/out/control/1' <<'!'
  449. XPath: hostb!host!user
  450. XFrom: user@host
  451. XMessage-ID: <#5@host>
  452. XNewsgroups: test.c
  453. XControl: cancel <#4@host>
  454. X
  455. X## This should appear in test/c/2
  456. !
  457. echo 'relay/regress/out/status':
  458. sed 's/^X//' >'relay/regress/out/status' <<'!'
  459. X0
  460. !
  461. echo 'relay/regress/regress':
  462. sed 's/^X//' >'relay/regress/regress' <<'!'
  463. X#! /bin/sh
  464. XPATH=".:$PATH"
  465. Xecho removing old dregs...
  466. Xrm -rf tmp
  467. Xecho making new working subtree...
  468. Xmkdir tmp 2>/dev/null
  469. Xchmod +x master/run
  470. Xcp ../relaynews master/* tmp
  471. Xcd tmp
  472. Xchmod u+w *
  473. Xecho running relaynews...
  474. X./run
  475. Xecho comparing output...
  476. Xsed 's/^... .. ..:..:..\..../TIME/' log >.log && mv .log log
  477. Xsed 's/    [0-9][0-9]*~/    TIME~/' history >.history && mv .history history
  478. Xrm -f gmon.out history.* relaynews
  479. X# diff -r ../out .
  480. Xfor f in `find . -type f -print`
  481. Xdo
  482. X    cmp $f ../out/$f
  483. Xdone
  484. !
  485. echo 'relay/regress/master/active':
  486. sed 's/^X//' >'relay/regress/master/active' <<'!'
  487. Xcontrol 0000000000 00000 y
  488. Xjunk 0000000000 00000 y
  489. Xfoo 0000000000 00000 y
  490. Xbar 0000000000 00000 y
  491. Xtest.a 0000000000 00000 y
  492. Xtest.b 0000000000 00000 y
  493. Xtest.c 0000000000 00000 y
  494. Xbaz 0000000000 00000 y
  495. !
  496. echo 'relay/regress/master/art1':
  497. sed 's/^X//' >'relay/regress/master/art1' <<'!'
  498. XPath: host!user
  499. XFrom: user@host
  500. XMessage-ID: <#1@host>
  501. XNewsgroups: test.a
  502. X
  503. X## This should appear in test/a/1
  504. !
  505. echo 'relay/regress/master/art2':
  506. sed 's/^X//' >'relay/regress/master/art2' <<'!'
  507. XPath: host!user
  508. XFrom: user@host
  509. XMessage-ID: <#2@host>
  510. XNewsgroups: test.b
  511. X
  512. X## This should appear in test/b/1
  513. !
  514. echo 'relay/regress/master/art3':
  515. sed 's/^X//' >'relay/regress/master/art3' <<'!'
  516. XPath: host!user
  517. XFrom: user@host
  518. XMessage-ID: <#3@host>
  519. XNewsgroups: test.a,test.b
  520. X
  521. X## This should appear in test/a/2
  522. X## This should appear in test/b/2
  523. !
  524. echo 'relay/regress/master/art4':
  525. sed 's/^X//' >'relay/regress/master/art4' <<'!'
  526. XPath: host!user
  527. XFrom: user@host
  528. XMessage-ID: <#4@host>
  529. XNewsgroups: test.c
  530. X
  531. XThis should get cancelled.
  532. !
  533. echo 'relay/regress/master/art5':
  534. sed 's/^X//' >'relay/regress/master/art5' <<'!'
  535. XPath: host!user
  536. XFrom: user@host
  537. XMessage-ID: <#5@host>
  538. XNewsgroups: test.c
  539. XControl: cancel <#4@host>
  540. X
  541. X## This should appear in test/c/2
  542. !
  543. echo 'relay/regress/master/batch':
  544. sed 's/^X//' >'relay/regress/master/batch' <<'!'
  545. X#! rnews 108
  546. XPath: host!user
  547. XFrom: user@host
  548. XMessage-ID: <#1@host>
  549. XNewsgroups: test.a
  550. X
  551. X## This should appear in test/a/1
  552. X#! rnews 108
  553. XPath: host!user
  554. XFrom: user@host
  555. XMessage-ID: <#2@host>
  556. XNewsgroups: test.b
  557. X
  558. X## This should appear in test/b/1
  559. X#! rnews 149
  560. XPath: host!user
  561. XFrom: user@host
  562. XMessage-ID: <#3@host>
  563. XNewsgroups: test.a,test.b
  564. X
  565. X## This should appear in test/a/2
  566. X## This should appear in test/b/2
  567. X#! rnews 101
  568. XPath: host!user
  569. XFrom: user@host
  570. XMessage-ID: <#4@host>
  571. XNewsgroups: test.c
  572. X
  573. XThis should get cancelled.
  574. X#! rnews 134
  575. XPath: host!user
  576. XFrom: user@host
  577. XMessage-ID: <#5@host>
  578. XNewsgroups: test.c
  579. XControl: cancel <#4@host>
  580. X
  581. X## This should appear in test/c/2
  582. !
  583. echo 'relay/regress/master/errlog':
  584. sed 's/^X//' >'relay/regress/master/errlog' <<'!'
  585. !
  586. echo 'relay/regress/master/history':
  587. sed 's/^X//' >'relay/regress/master/history' <<'!'
  588. !
  589. echo 'relay/regress/master/history.dir':
  590. sed 's/^X//' >'relay/regress/master/history.dir' <<'!'
  591. !
  592. echo 'relay/regress/master/history.pag':
  593. sed 's/^X//' >'relay/regress/master/history.pag' <<'!'
  594. !
  595. echo 'relay/regress/master/log':
  596. sed 's/^X//' >'relay/regress/master/log' <<'!'
  597. !
  598. echo 'relay/regress/master/run':
  599. sed 's/^X//' >'relay/regress/master/run' <<'!'
  600. X#! /bin/sh
  601. X# run relaynews test
  602. Xhere=`pwd`
  603. XNEWSARTS=$here
  604. XNEWSBIN=$here
  605. XNEWSCTL=$here
  606. Xexport NEWSARTS NEWSBIN NEWSCTL
  607. X
  608. X./relaynews -r <batch >stdout 2>stderr
  609. Xecho $? >status
  610. !
  611. echo 'relay/regress/master/sys':
  612. sed 's/^X//' >'relay/regress/master/sys' <<'!'
  613. XME:all
  614. Xfoo:all:f:/dev/null
  615. !
  616. echo 'relay/regress/master/whoami':
  617. sed 's/^X//' >'relay/regress/master/whoami' <<'!'
  618. Xhostb
  619. !
  620. echo 'relay/README':
  621. sed 's/^X//' >'relay/README' <<'!'
  622. XThis is relaynews, the heart of C News:  article filing.
  623. X
  624. XIf you're starting here, you are in the wrong place:  go to ../conf and
  625. Xrun "build".
  626. X
  627. XSubdirectories are:
  628. X
  629. Xads    some silliness
  630. Xanews    stuff for conversion to and from the old A News format
  631. Xaux    auxiliary programs of various kinds
  632. Xctl    control-message shell files
  633. Xaltctl    alternative, not recommended, versions of rmgroup and sendgroups
  634. Xsh    shell files, including inews and postnews and their flunkies
  635. Xregress    regression-test facilities for relaynews
  636. X
  637. Xihave.not.c is an alternate version of ihave.c for sites that specifically
  638. Xwish to disable ihave/sendme (typically because of foolishness like
  639. Xproprietary newsgroups).
  640. X
  641. XTo run a regression test, "make r".
  642. !
  643. echo 'relay/active.c':
  644. sed 's/^X//' >'relay/active.c' <<'!'
  645. X/*
  646. X * active file access functions
  647. X */
  648. X
  649. X#include <stdio.h>
  650. X#include <ctype.h>
  651. X#include <sys/types.h>
  652. X#include <sys/stat.h>
  653. X#include "libc.h"
  654. X#include "news.h"
  655. X#include "config.h"
  656. X#include "active.h"
  657. X
  658. X/* ordinal numbers of fields */
  659. X#define CURRFIELD 2        /* current article # */
  660. X#define FLAGFIELD 4        /* y/n/m/x/= flag */
  661. X
  662. X/* flag field values */
  663. X#define FLAGOKAY 'y'        /* ordinary unmoderated group */
  664. X#define FLAGBAD 'n'        /* unmoderated but locally-restricted group */
  665. X#define FLAGMOD 'm'        /* moderated group */
  666. X#define FLAGNEVER 'x'        /* unwanted group: don't file in this one */
  667. X#define FLAGGOTO '='        /* see another group (following) instead */
  668. X
  669. X/* imports */
  670. Xextern char *actfind();
  671. Xextern statust actfload(), actfsync(), actfwrnum();
  672. X
  673. X/* forwards */
  674. Xextern char *findflag();
  675. XFORWARD char *fieldfind();
  676. X
  677. X/* exports */
  678. Xchar actrelnm[] = "active";
  679. X
  680. Xstatic FILE *actfp = NULL;
  681. Xstatic struct lastngcache {
  682. X    char *lnc_ng;            /* newsgroup name */
  683. X    char *lnc_line;            /* matching active file line */
  684. X} lnc = { NULL, NULL };
  685. X
  686. X/*
  687. X * return a pointer to the active file entry for ng
  688. X * (or a pointed-to group (by ``=group'')), or 0 if no entry exists.
  689. X * since actlook is called repeatedly for the same newsgroup,
  690. X * actlook caches the last newsgroup looked-up and the result.
  691. X */
  692. XSTATIC char *
  693. Xactlook(ang)
  694. Xregister char *ang;
  695. X{
  696. X    register char *ngline, *ng, *flag;
  697. X    register int loopbreak = 100;
  698. X
  699. X    if (lnc.lnc_ng != NULL && STREQ(lnc.lnc_ng, ang))
  700. X        return lnc.lnc_line;
  701. X
  702. X    if (actload() != ST_OKAY)
  703. X        return NULL;
  704. X    ng = strsave(ang);
  705. X    while ((ngline = actfind(actfp, ng, strlen(ng))) != NULL &&
  706. X        (flag = findflag(ngline)) != NULL && *flag == FLAGGOTO &&
  707. X        --loopbreak > 0) {
  708. X        free(ng);
  709. X            ng = strsvto(flag+1, '\n');    /* follow "=ng" pointer */
  710. X    }
  711. X    if (loopbreak <= 0)            /* "infinite" loop broken */
  712. X        ngline = NULL;
  713. X
  714. X    nnfree(&lnc.lnc_ng);
  715. X    lnc.lnc_ng = ng;
  716. X    lnc.lnc_line = ngline;
  717. X    return ngline;
  718. X}
  719. X
  720. X/*
  721. X * Find the active entry for ng (or a pointed-to group (by ``=group''))
  722. X * and add inc to its 2nd field (highest number).
  723. X * Return the resultant number.
  724. X */
  725. Xlong
  726. Xincartnum(ng, inc)
  727. Xchar *ng;
  728. Xint inc;
  729. X{
  730. X    char testnum[40];
  731. X    register char *line = actlook(ng);
  732. X    register long nextart = -1;
  733. X
  734. X    if (line != NULL) {
  735. X        register char *artnum, *pastartnum;
  736. X
  737. X        pastartnum = artnum = fieldfind(line, CURRFIELD);
  738. X        if (artnum == NULL)
  739. X            return nextart;
  740. X        while (isascii(*pastartnum) && isdigit(*pastartnum))
  741. X            ++pastartnum;
  742. X        nextart = atol(artnum) + inc;
  743. X
  744. X        /* update active file article # in place, from nextart */
  745. X        if (pastartnum-artnum > sizeof testnum ||
  746. X            !ltozan(testnum, nextart, pastartnum-artnum) ||
  747. X            !ltozan(artnum, nextart, pastartnum-artnum)) {
  748. X            (void) fprintf(stderr,
  749. X"%s: article number (%ld) too big for group `%s' active field of %d digits\n",
  750. X                progname, nextart, ng, pastartnum-artnum);
  751. X            return -1;
  752. X        }
  753. X
  754. X        /* give the implementation a chance to write line to disk */
  755. X        if (actfwrnum(actfp, line) != ST_OKAY) {
  756. X            warning("can't update active file", "");
  757. X            nextart = -1;
  758. X        }
  759. X    }
  760. X    return nextart;
  761. X}
  762. X
  763. X/*
  764. X * Reload the active file cache.
  765. X */
  766. Xstatust
  767. Xactload()
  768. X{
  769. X    register statust status = ST_OKAY;
  770. X
  771. X    if (actfp == NULL &&
  772. X        (actfp = fopenwclex(ctlfile(actrelnm), "r+")) == NULL)
  773. X        status |= ST_DROPPED;
  774. X    status |= actfload(actfp);
  775. X    return status;
  776. X}
  777. X
  778. X/*
  779. X * Write back to disk the active file cache, if any, and flush the
  780. X * last-newsgroup-cache, since it refers to the (now invalid) active file cache.
  781. X */
  782. Xstatust
  783. Xactsync()
  784. X{
  785. X    register statust status = ST_OKAY;
  786. X
  787. X    if (actfp != NULL) {
  788. X        lnc.lnc_ng = lnc.lnc_line = NULL;
  789. X        status |= actfsync(actfp);
  790. X        if (nfclose(actfp) == EOF || status != ST_OKAY) {
  791. X            warning("error writing `%s'", ctlfile(actrelnm));
  792. X            status |= ST_DROPPED;
  793. X        }
  794. X    }
  795. X    actfp = NULL;
  796. X    return status;
  797. X}
  798. X
  799. X/*
  800. X * Return YES iff any group in ngs (or a pointed-to group (by ``=group''))
  801. X * matches thisflag.
  802. X */
  803. Xboolean
  804. Xisflag(ngs, thisflag)
  805. Xregister char *ngs;
  806. Xint thisflag;
  807. X{
  808. X    register char *newng, *flag, *ng;
  809. X    register boolean result = NO;
  810. X
  811. X    for (ng = ngs; !result && ng != NULL; ng = newng) {
  812. X        newng = index(ng, NGSEP);
  813. X        if (newng != NULL)
  814. X            *newng = '\0';        /* restored below */
  815. X
  816. X        flag = findflag(actlook(ng));
  817. X        if (flag != NULL && *flag == thisflag)
  818. X            result = YES;
  819. X
  820. X        if (newng != NULL)
  821. X            *newng++ = NGSEP;    /* point at next group */
  822. X    }
  823. X    return result;
  824. X}
  825. X
  826. XSTATIC char *
  827. Xfieldfind(ngline, fieldno)    /* return address of field "fieldno" in ngline */
  828. Xregister char *ngline;
  829. Xregister int fieldno;
  830. X{
  831. X    register int field;
  832. X
  833. X    for (field = 1; ngline != NULL && field < fieldno; ++field) {
  834. X        ngline = index(ngline, ' ');
  835. X        if (ngline != NULL)
  836. X            ngline++;        /* point at next field */
  837. X    }
  838. X    return ngline;
  839. X}
  840. X
  841. Xchar *
  842. Xfindflag(ngline)        /* return address of flag field in ngline */
  843. Xregister char *ngline;
  844. X{
  845. X    return fieldfind(ngline, FLAGFIELD);
  846. X}
  847. X
  848. X/*
  849. X * Are any groups in ngs moderated?
  850. X */
  851. Xboolean
  852. Xmoderated(ngs)
  853. Xregister char *ngs;
  854. X{
  855. X    return isflag(ngs, FLAGMOD);
  856. X}
  857. X
  858. X/*
  859. X * Are any groups in ngs unwanted?
  860. X */
  861. Xboolean
  862. Xunwanted(ngs)
  863. Xregister char *ngs;
  864. X{
  865. X    return isflag(ngs, FLAGNEVER);
  866. X}
  867. X
  868. X/*
  869. X * Return 0 or a malloced newsgroup name corresponding to "ong",
  870. X * but without an "=" flag in its active file entry.
  871. X * This is done by tracing the chain of "=ng" pointers (in actlook()), if any.
  872. X */
  873. Xchar *
  874. Xrealngname(ong)
  875. Xchar *ong;
  876. X{
  877. X    register char *ngline = actlook(ong);
  878. X
  879. X    if (ngline == NULL)
  880. X        return NULL;            /* no such ong */
  881. X    return strsvto(ngline, ' ');
  882. X}
  883. !
  884. echo 'relay/active.h':
  885. sed 's/^X//' >'relay/active.h' <<'!'
  886. X/* imports from active.c */
  887. Xextern statust actload(), actsync();
  888. Xextern long incartnum();
  889. Xextern char *realngname();
  890. Xextern boolean isflag(), unwanted(), moderated();
  891. X
  892. X#define nxtartnum(ng) incartnum(ng, 1)
  893. X#define prevartnum(ng) incartnum(ng, -1)
  894. !
  895. echo 'relay/ads/1':
  896. sed 's/^X//' >'relay/ads/1' <<'!'
  897. XINEWS. We have
  898. Xthe technology
  899. Xtoday to bring 'em
  900. Xback tomorrow.
  901. X
  902. X    By the 1990s, fighter pilots will need an inte-
  903. Xgrated electronic warfare suite that fuses the
  904. Xcapabilities of multiple warning and response sys-
  905. Xtems. Advanced technology that provides complete
  906. Xprotection with greater reliability. That system is the
  907. XIntegrated Electronic Warfare System - INEWS.
  908. X    The TRW/Westinghouse Joint Venture is the
  909. Xonly team that offers such a powerful combination
  910. Xof advanced technologies and specific, long-term
  911. Xexperience for INEWS.
  912. X    Our Phase I and II VHSIC contracts, together
  913. Xwith our VHSIC 1750A program, will increase pro-
  914. Xcessing speed and memory and reduce space and
  915. Xpower demands. Our wideband microwave trans-
  916. Xmitters and receivers can make functional integra-
  917. Xtion a cost-effective, operational reality. Our detector
  918. Xtechnologies ensure instant warning of all fore-
  919. Xseeable threats. And our expendables technology
  920. Xprovides a wide range of threat-response options.
  921. X    TRW and Westinghouse with
  922. XHoneywell, Perkin-Elmer, and Tracor.
  923. XThe team with the technology today
  924. Xto bring 'em back tomorrow.
  925. X
  926. X  TRW
  927. !
  928. echo 'relay/ads/2':
  929. sed 's/^X//' >'relay/ads/2' <<'!'
  930. XINEWS. Technology on a totally different plane.
  931. X
  932. X    The Raytheon-Northrop joint
  933. Xventure team brings state-of-the-art
  934. Xtechnology to the competition for
  935. Xthe Integrated Electronic Warfare
  936. XSystem. INEWS will go aboard the
  937. Xnext generation of tactical aircraft.
  938. X    The combination of Raytheon
  939. Xand Northrop unites their comple-
  940. Xmentary capabilities in the design,
  941. Xdevelopment and production of
  942. Xinnovative EW systems.
  943. X    Team members AT&T Tech-
  944. Xnology Systems (Bell Labs), GTE,
  945. XMagnavox and Tracor provide
  946. Xadditional experience which is
  947. Xkey to successful integration of
  948. Xadvanced technologies.
  949. X    No other EW team provides
  950. Xthis same level of expertise in
  951. Xradar systems, surface-to-air mis-
  952. Xsiles and advanced tactical and
  953. Xstrategic aircraft. Strengths that
  954. Xare essential to INEWS develop-
  955. Xment and support.
  956. X    The Raytheon and Northrop
  957. Xjoint venture team. Expertise on a
  958. Xtotally different plane.
  959. X
  960. XRaytheon NORTHROP
  961. XJoint venture program office
  962. X6380 Hollister Avenue
  963. XGoleta, CA 93117
  964. !
  965. echo 'relay/ads/3':
  966. sed 's/^X//' >'relay/ads/3' <<'!'
  967. XINEWS.
  968. XTheir future
  969. Xdepends on it.
  970. X
  971. XIn the 1990's and beyond, our pilots' survival and
  972. Xtheir mission success will rely on an effective
  973. XIntegrated Electronic Warfare Systems (INEWS).
  974. XGuaranteeing the best INEWS for tomorrow
  975. Xmeans selecting the right team to build it today.
  976. X     With Honeywell, Perkin-Elmer, and Tracor,
  977. Xthe TRW/Westinghouse team brings an un-
  978. Xrivaled program and technology baseline to
  979. XINEWS. Together we are concentrating on
  980. Xsystem level development...providing risk
  981. Xreduction where it counts: system software
  982. Xand system integration.
  983. X     Our team offers Ada on VHSIC, complete
  984. XINEWS system simulation, expert system devel-
  985. Xopment for full situation awareness and response
  986. Xmanagement, and reliability and maintainability
  987. Xrisk reduction to reduce operation and support
  988. Xcosts while increasing system availability. The
  989. XTRW/Westinghouse INEWS--reliable perform-
  990. Xance to beat the threat, sustainable in conflict,
  991. Xaffordable for a lifetime.
  992. X    INEWS: The System for Their Future--
  993. Xfrom TRW and Westinghouse.
  994. X
  995. X    TRW
  996. !
  997. echo 'relay/ads/README':
  998. sed 's/^X//' >'relay/ads/README' <<'!'
  999. XThese are reproduced verbatim from Aviation Week.
  1000. !
  1001. echo 'relay/anews/a.samp':
  1002. sed 's/^X//' >'relay/anews/a.samp' <<'!'
  1003. XA123@utcs.fun
  1004. Xnet.rec.drugs.crack
  1005. Xucbvax!ucbarpa!foo
  1006. XApr  1 00:00:00 1986
  1007. XWhee!
  1008. XBoy I like this stuff!
  1009. !
  1010. echo 'relay/anews/a.samp.to.b':
  1011. sed 's/^X//' >'relay/anews/a.samp.to.b' <<'!'
  1012. XMessage-ID: 123@utcs.fun
  1013. XNewsgroups: net.rec.drugs.crack
  1014. XPath: ucbvax!ucbarpa!foo
  1015. XFrom: ucbvax!ucbarpa!foo
  1016. XDate: Apr  1 00:00:00 1986
  1017. XSubject: Whee!
  1018. X
  1019. XBoy I like this stuff!
  1020. !
  1021. echo 'relay/anews/a.to.b':
  1022. sed 's/^X//' >'relay/anews/a.to.b' <<'!'
  1023. X#! /bin/sh
  1024. X# a.to.b: A-format news to B-format converter (thanks, Norman)
  1025. XPATH=/bin:/usr/bin:/usr/ucb; export PATH
  1026. X
  1027. Xsed '
  1028. X1s/^A/Message-ID: /
  1029. X2s/^/Newsgroups: /
  1030. X3{
  1031. Xs/^/Path: /p
  1032. Xs/Path/From/
  1033. X}
  1034. X4s/^/Date: /
  1035. X5{
  1036. Xs/^/Subject: /p
  1037. Xs/.*//
  1038. X}
  1039. X'
  1040. !
  1041. echo 'relay/anews/b.samp':
  1042. sed 's/^X//' >'relay/anews/b.samp' <<'!'
  1043. XPath: ucbvax!ucbarpa!foo
  1044. XFrom: ucbvax!ucbarpa!foo
  1045. XSubject: Whee!
  1046. XNewsgroups: net.rec.drugs.crack
  1047. XMessage-ID: 123@utcs.fun
  1048. XDate: Apr  1 00:00:00 1986
  1049. XHideous-Name: #@$%ucbarpa^edu&*foo
  1050. X
  1051. XBoy I like this stuff!
  1052. !
  1053. echo 'relay/anews/b.samp.to.a':
  1054. sed 's/^X//' >'relay/anews/b.samp.to.a' <<'!'
  1055. XA123@utcs.fun
  1056. Xnet.rec.drugs.crack
  1057. Xucbvax!ucbarpa!foo
  1058. XApr 1 00:00:00 1986
  1059. XWhee!
  1060. XBoy I like this stuff!
  1061. !
  1062. echo 'relay/anews/b.to.a':
  1063. sed 's/^X//' >'relay/anews/b.to.a' <<'!'
  1064. X#! /bin/sh
  1065. X# bnewstoa: B-format news to A-format converter (why, oh, why?) (thanks, Norman)
  1066. XPATH=/bin:/usr/bin:/usr/ucb; export PATH
  1067. X
  1068. Xawk '
  1069. XNR==1,/^$/    {        # headers: save A headers only
  1070. X    if ($0 ~ /^Message-ID: /)
  1071. X        msgid=$2
  1072. X    else if ($0 ~ /^Newsgroups: /)
  1073. X        ngs=$2
  1074. X    else if ($0 ~ /^Path: /)
  1075. X        path=$2
  1076. X    else if ($0 ~ /^Date: /) {
  1077. X        date = $2    # skip "Date:"
  1078. X        for (i = 3; i <= NF; i++)
  1079. X            date = date " " $i    # append remaining fields
  1080. X    } else if ($0 ~ /^Subject: /)
  1081. X        subj=$2
  1082. X    else if ($0 ~ /^$/) {    # end of headers: spew out A-format equivalent
  1083. X        print "A" msgid
  1084. X        print ngs
  1085. X        print path
  1086. X        print date
  1087. X        print subj
  1088. X        inbody = "yes"
  1089. X        noblanksyet = "yes"
  1090. X    }
  1091. X}
  1092. Xinbody=="yes"    {    # copy body except first blank line, if present
  1093. X    if ($0 ~ /^$/ && noblanksyet == "yes")
  1094. X        noblanksyet = "no"
  1095. X    else
  1096. X        print
  1097. X}
  1098. X'
  1099. !
  1100. echo 'relay/anews/README':
  1101. sed 's/^X//' >'relay/anews/README' <<'!'
  1102. XThese are some ill-documented utilities for converting between A News and
  1103. XB News formats.  Probably not of any interest to anyone any more, but we
  1104. Xinclude them just in case.
  1105. !
  1106. echo 'relay/article.c':
  1107. sed 's/^X//' >'relay/article.c' <<'!'
  1108. X/*
  1109. X * article creation and destruction
  1110. X */
  1111. X#include <stdio.h>
  1112. X#include <sys/types.h>
  1113. X#include "libc.h"
  1114. X#include "news.h"
  1115. X#include "headers.h"
  1116. X#include "article.h"
  1117. X
  1118. Xvoid
  1119. Xartinit(art)
  1120. Xregister struct article *art;
  1121. X{
  1122. X    art->a_status = ST_OKAY;
  1123. X    hdrinit(&art->h);
  1124. X    art->a_haccum = NULL;
  1125. X    art->a_hnext = NULL;
  1126. X    art->a_hpalloced = 0;
  1127. X    art->a_hpused = 0;
  1128. X    art->a_hptrs = NULL;
  1129. X    art->a_hbytesleft = 0;
  1130. X    art->a_files = NULL;
  1131. X    art->a_tmpf = NULL;
  1132. X    art->a_artf = NULL;
  1133. X    art->a_unlink = NO;
  1134. X    art->a_filed = NO;
  1135. X    art->a_xref = NO;
  1136. X    art->a_blvmax = NO;
  1137. X    art->a_charswritten = 0;
  1138. X    art->a_unread = 0;
  1139. X}
  1140. X
  1141. Xvoid
  1142. Xartfree(art)
  1143. Xregister struct article *art;
  1144. X{
  1145. X    freeheaders(&art->h);
  1146. X    /* a_haccum is currently not malloced */
  1147. X    art->a_hptrs = NULL;        /* don't free a_hptrs; see hdrsave() */
  1148. X    nnfree(&art->a_files);
  1149. X    nnfree(&art->a_tmpf);
  1150. X    if (art->a_artf != NULL) {
  1151. X        (void) fprintf(stderr, "%s: a_artf still open in artfree()\n",
  1152. X            progname);
  1153. X        if (nfclose(art->a_artf) == EOF) {
  1154. X            art->a_status |= ST_DROPPED;
  1155. X            warning("error closing %s", art->a_tmpf);
  1156. X        }
  1157. X        art->a_artf = NULL;
  1158. X    }
  1159. X}
  1160. !
  1161. echo 'relay/article.h':
  1162. sed 's/^X//' >'relay/article.h' <<'!'
  1163. X/*
  1164. X * All the information needed to describe an article as it is processed.
  1165. X */
  1166. X
  1167. X#define MINSHPTRS 30        /* initial value for sh_alloced */
  1168. X
  1169. Xstruct article {
  1170. X    statust a_status;    /* article status bits */
  1171. X    struct headers h;    /* strictly from headers in input: */
  1172. X    char *a_haccum;        /* accumulated output headers, if any */
  1173. X    char *a_hnext;        /* -> first free byte in a_haccum */
  1174. X    short a_hpalloced;    /* indices in a_hptrs */
  1175. X    short a_hpused;        /* indices currently in use */
  1176. X    char **a_hptrs;        /* -> array of ptrs to lines in a_haccum */
  1177. X    unsigned a_hbytesleft;    /* in a_haccum */
  1178. X    char *a_files;        /* filenames for history, added in filing, from h.h_ngs */
  1179. X    char *a_tmpf;        /* temp link name or first spool dir link */
  1180. X    FILE *a_artf;        /* stream corresponding to a_tmpf */
  1181. X    boolean a_unlink;    /* true iff a_tmpf should be unlinked when done */
  1182. X    boolean a_filed;    /* true iff article has been filed */
  1183. X    boolean a_xref;        /* true iff Xref: header generated yet */
  1184. X    boolean a_blvmax;    /* true iff a_unread is to be believed */
  1185. X    long a_charswritten;    /* into spool directory, for batcher */
  1186. X    long a_unread;        /* bytes of article input yet unread */
  1187. X};
  1188. X
  1189. X/* return name of at least one link, for printing in error messages, etc. */
  1190. X#define spoolnm(art) ((art)->a_unlink? (art)->a_tmpf: (art)->a_files)
  1191. X
  1192. X/* imports from article.c */
  1193. Xextern void artinit(), artfree();
  1194. !
  1195. echo 'relay/caches.c':
  1196. sed 's/^X//' >'relay/caches.c' <<'!'
  1197. X/*
  1198. X * cache control
  1199. X */
  1200. X
  1201. X#include <stdio.h>
  1202. X#include <sys/types.h>
  1203. X#include "news.h"
  1204. X#include "active.h"
  1205. X#include "caches.h"
  1206. X#include "transmit.h"
  1207. X
  1208. Xstatust
  1209. Xloadcaches()                /* reload in-core caches from disk */
  1210. X{
  1211. X    return actload();
  1212. X}
  1213. X
  1214. Xstatust
  1215. Xsynccaches()                /* force in-core caches to disk */
  1216. X{
  1217. X    return actsync() | trclose();
  1218. X}
  1219. !
  1220. echo 'relay/caches.h':
  1221. sed 's/^X//' >'relay/caches.h' <<'!'
  1222. X/* imports from caches.c */
  1223. Xextern statust loadcaches(), synccaches();
  1224. !
  1225. echo 'relay/control.c':
  1226. sed 's/^X//' >'relay/control.c' <<'!'
  1227. X/*
  1228. X * Implement the Usenet control messages, as per RFC 1036 (nee 850).
  1229. X * These are fairly infrequent and can afford to be done by
  1230. X * separate programs.  They are:
  1231. X *
  1232. X * cancel message-ID    restricted to Sender: else From: or root, in theory
  1233. X * ihave message-ID-list remotesys    generate a sendme from message-ID-list
  1234. X * sendme message-ID-list remotesys    send articles named to remotesys
  1235. X * (ihave/sendme is semi-documented in the RFCs, kludgey and broken in B2.10.)
  1236. X *
  1237. X * newgroup groupname    must be Approved:
  1238. X * rmgroup groupname    must be Approved:; allow some local control over this
  1239. X * sendsys        mail to Reply-To: else From:
  1240. X * senduuname        ditto
  1241. X * version        ditto
  1242. X */
  1243. X
  1244. X#include <stdio.h>
  1245. X#include <ctype.h>
  1246. X#include <sys/types.h>
  1247. X
  1248. X#include "libc.h"
  1249. X#include "news.h"
  1250. X#include "config.h"
  1251. X#include "headers.h"
  1252. X#include "article.h"
  1253. X#include "caches.h"
  1254. X#include "history.h"
  1255. X
  1256. X#define NO_FILES ""
  1257. X#define SUBDIR binfile("ctl")        /* holds shell scripts */
  1258. X
  1259. X/*
  1260. X * These are shell meta-characters, except for /, which is included
  1261. X * since it allows people to escape from the control directory.
  1262. X */
  1263. X#define SHELLMETAS "<>|&;({$=*?[`'\"/"
  1264. X
  1265. X/* imports from news */
  1266. Xextern statust snufffiles(); 
  1267. Xextern void ihave(), sendme();
  1268. X
  1269. X/* forwards */
  1270. XFORWARD statust cancelart();
  1271. XFORWARD void runctlmsg(), bombctlmsg();
  1272. X
  1273. X/*
  1274. X * Implement control message specified in "art".
  1275. X * Because newgroup and rmgroup may modify the active file, for example,
  1276. X * we must flush in-core caches to disk first and reload them afterward.
  1277. X * We handle cancels in this process for speed and dbm access.
  1278. X * We handle ihave & sendme in this process for dbm access and
  1279. X * to work around syntax restrictions (<>).
  1280. X *
  1281. X * In future, one could pass header values to scripts as arguments or
  1282. X * in environment, as NEWS* variables, to save time in the scripts.
  1283. X */
  1284. Xvoid
  1285. Xctlmsg(art)
  1286. Xstruct article *art;
  1287. X{
  1288. X    int pid, deadpid;
  1289. X    int wstatus;
  1290. X    char *inname = art->a_tmpf, *ctlcmd = art->h.h_ctlcmd;
  1291. X    static char nmcancel[] = "cancel ";
  1292. X    static char nmihave[] = "ihave ";
  1293. X    static char nmsendme[] = "sendme ";
  1294. X
  1295. X    if (STREQN(ctlcmd, nmcancel, STRLEN(nmcancel))) {
  1296. X        art->a_status |= cancelart(ctlcmd + STRLEN(nmcancel));
  1297. X        return;
  1298. X    }
  1299. X    if (STREQN(ctlcmd, nmihave, STRLEN(nmihave))) {
  1300. X        ihave(ctlcmd + STRLEN(nmihave), art);
  1301. X        return;
  1302. X    }
  1303. X    if (STREQN(ctlcmd, nmsendme, STRLEN(nmsendme))) {
  1304. X        sendme(ctlcmd + STRLEN(nmsendme), art);
  1305. X        return;
  1306. X    }
  1307. X
  1308. X    art->a_status |= synccaches();
  1309. X    (void) fflush(stdout);
  1310. X    (void) fflush(stderr);
  1311. X
  1312. X    pid = fork();
  1313. X    if (pid == 0)                /* child? */
  1314. X        runctlmsg(ctlcmd, inname);
  1315. X    else if (pid == -1)
  1316. X        warning("fork failed", "");
  1317. X
  1318. X    /* lint complains about &wstatus on 4.2+BSD; too bad, lint's wrong. */
  1319. X    while ((deadpid = wait(&wstatus)) != pid && deadpid != -1)
  1320. X        ;
  1321. X
  1322. X    /* wrong kid returned, fork failed or child screwed up? */
  1323. X    if (deadpid == -1 || pid == -1 || wstatus != 0)
  1324. X        art->a_status |= ST_DROPPED;    /* admin got err.msg. by mail */
  1325. X    art->a_status |= loadcaches();
  1326. X}
  1327. X
  1328. XSTATIC boolean
  1329. Xsafecmd(cmd)            /* true if it's safe to system(3) cmd */
  1330. Xchar *cmd;
  1331. X{
  1332. X    register char *s;
  1333. X
  1334. X    for (s = cmd; *s != '\0'; s++)
  1335. X        if (STREQN(s, "..", STRLEN("..")))
  1336. X            return NO;
  1337. X    for (s = SHELLMETAS; *s != '\0'; s++)
  1338. X        if (index(cmd, *s) != NULL)
  1339. X            return NO;
  1340. X    return YES;
  1341. X}
  1342. X
  1343. X/*
  1344. X * In theory (RFC 1036 nee 850), we should verify that the user issuing
  1345. X * the cancel (the Sender: of this article or From: if no Sender) is the
  1346. X * Sender: or From: of the original article or the local super-user.
  1347. X *
  1348. X * In practice, this is a lot of work and since anyone can forge news
  1349. X * (and thus cancel anything), not worth the effort.
  1350. X *
  1351. X * Ignore ST_ACCESS while cancelling an already-seen article since the
  1352. X * article may have been cancelled before or may have a fake history entry
  1353. X * because the cancel arrived before the article.
  1354. X *
  1355. X * If the article being cancelled has not been seen yet, generate a history
  1356. X * file entry for the cancelled article in case it arrives after the cancel
  1357. X * control.  The history file entry will cause the cancelled article to be
  1358. X * rejected as a duplicate.
  1359. X */
  1360. XSTATIC statust
  1361. Xcancelart(msgidstr)
  1362. Xchar *msgidstr;
  1363. X{
  1364. X    register char *wsp;
  1365. X    register char *msgid = strsave(msgidstr);
  1366. X    register int idbytes;
  1367. X    register char *wholemsgid = msgid;
  1368. X    register statust status = ST_OKAY;
  1369. X
  1370. X    /* skip leading whitespace in msgid */
  1371. X    while (*msgid != '\0' && isascii(*msgid) && isspace(*msgid))
  1372. X        ++msgid;
  1373. X    /* replace trailing whitespace with NULs; `wsp >= msgid' is not safe */
  1374. X    idbytes = strlen(msgid);
  1375. X    for (wsp = msgid + idbytes - 1; idbytes-- > 0 &&
  1376. X        isascii(*wsp) && isspace(*wsp); --wsp)
  1377. X        *wsp = '\0';
  1378. X
  1379. X    if (alreadyseen(msgid)) {
  1380. X        register char *histent, *filelist;
  1381. X
  1382. X        histent = gethistory(msgid);
  1383. X        if (histent != NULL && (filelist = findfiles(histent)) != NULL)
  1384. X            status |= snufffiles(filelist) & ~ST_ACCESS;
  1385. X    } else {
  1386. X        status |= fakehist(msgid, DEFEXP, NO_FILES);    /* start log */
  1387. X        (void) putchar('\n');        /* end log line */
  1388. X    }
  1389. X    free(wholemsgid);
  1390. X    return status;
  1391. X}
  1392. X
  1393. X/*
  1394. X * Execute a non-builtin control message by searching $NEWSCTL/bin and
  1395. X * $NEWSBIN/ctl for the command named by the control message.
  1396. X * runctlmsg is called from a child of relaynews, so it must always
  1397. X * call _exit() rather than exit() to avoid flushing stdio buffers.
  1398. X *
  1399. X * Enforce at least minimal security: the environment was standardised at
  1400. X * startup, including PATH and IFS; close non-standard file descriptors;
  1401. X * reject shell metacharacters in ctlcmd.
  1402. X */
  1403. XSTATIC void
  1404. Xrunctlmsg(ctlcmd, inname)            /* child process */
  1405. Xregister char *ctlcmd, *inname;
  1406. X{
  1407. X    register char *cmd;
  1408. X    register int cmdstat;
  1409. X
  1410. X    closeall(1);
  1411. X    if (!safecmd(ctlcmd)) {
  1412. X        (void) fprintf(stderr,
  1413. X            "%s: control `%s' looks unsafe to execute\n", progname, ctlcmd);
  1414. X        _exit(1);
  1415. X    }
  1416. X    cmd = malloc((unsigned) STRLEN("PATH=") + strlen(ctlfile("bin")) +
  1417. X        STRLEN(":") + strlen(SUBDIR) + STRLEN(";") + strlen(ctlcmd) +
  1418. X        STRLEN(" <") + strlen(inname) + 1);
  1419. X    if (cmd == NULL) {
  1420. X        warning("can't allocate memory in runctlmsg", "");
  1421. X        _exit(1);
  1422. X    }
  1423. X    (void) strcpy(cmd, "PATH=");
  1424. X    (void) strcat(cmd, ctlfile("bin"));
  1425. X    (void) strcat(cmd, ":");
  1426. X    (void) strcat(cmd, SUBDIR);
  1427. X    (void) strcat(cmd, ";");
  1428. X    (void) strcat(cmd, ctlcmd);
  1429. X    (void) strcat(cmd, " <");
  1430. X    (void) strcat(cmd, inname);
  1431. X
  1432. X    cmdstat = system(cmd);
  1433. X    if (cmdstat != 0)
  1434. X        bombctlmsg(cmd, cmdstat);
  1435. X    free(cmd);
  1436. X    _exit(0);
  1437. X}
  1438. X
  1439. X/*
  1440. X * Notify the local news administrator by mail that "cmd" failed
  1441. X * with "cmdstat" status, and _exit with bad status (again avoid stdio
  1442. X * buffer flushing in the child).
  1443. X */
  1444. XSTATIC void
  1445. Xbombctlmsg(cmd, cmdstat)
  1446. Xchar *cmd;
  1447. Xint cmdstat;
  1448. X{
  1449. X    register char *mailcmd;
  1450. X    register FILE *mailf;
  1451. X    
  1452. X    mailcmd = malloc((unsigned)STRLEN("PATH=") + strlen(newspath()) +
  1453. X        STRLEN(" mail ") + strlen(newsmaster()) + 1);
  1454. X    if (mailcmd == NULL) {
  1455. X        warning("can't allocate memory in bombctlmsg", "");
  1456. X        _exit(1);
  1457. X    }
  1458. X    (void) sprintf(mailcmd, "PATH=%s mail %s", newspath(), newsmaster());
  1459. X    mailf = popen(mailcmd, "w");
  1460. X    if (mailf == NULL)
  1461. X        mailf = stderr;
  1462. X    (void) fprintf(mailf,
  1463. X        "%s: control message `%s' exited with status 0%o\n",
  1464. X        progname, cmd, cmdstat);
  1465. X    if (mailf != stderr)
  1466. X        (void) pclose(mailf);
  1467. X    free(mailcmd);
  1468. X    _exit(1);
  1469. X}
  1470. !
  1471. echo 'relay/control.h':
  1472. sed 's/^X//' >'relay/control.h' <<'!'
  1473. X/* imports from control.c */
  1474. Xextern void ctlmsg();
  1475. !
  1476. echo 'relay/cpu.h':
  1477. sed 's/^X//' >'relay/cpu.h' <<'!'
  1478. X/*
  1479. X * CPU-specific definitions
  1480. X */
  1481. X
  1482. X#ifndef MAXLONG
  1483. X#define MAXLONG ((long)(~(unsigned long)0 >> 1))
  1484. X#endif
  1485. !
  1486. echo 'relay/ctl/checkgroups':
  1487. sed 's/^X//' >'relay/ctl/checkgroups' <<'!'
  1488. X#! /bin/sh
  1489. X# checkgroups - check active file for missing or extra newsgroups.
  1490. X#    stdin must a checkgroups news article, sends mail to $NEWSMASTER
  1491. X#    after updating $nl/newsgroups from $nl/localgroups
  1492. X# based on v1.4 of 9/4/84
  1493. X
  1494. X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  1495. X. ${NEWSCONFIG-/usr/lib/news/bin/config}
  1496. Xexport NEWSCTL NEWSBIN NEWSARTS
  1497. XPATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH ; export PATH
  1498. Xumask $NEWSUMASK
  1499. X
  1500. X# generate newsgroups from localgroups & beheaded stdin (checkgroups article).
  1501. X# appending to newsgroups instead of overwriting is a hack,
  1502. X# but is about the best we can do until checkgroups is defined.
  1503. X(cat $NEWSCTL/localgroups; sed '1,/^$/d') >>$NEWSCTL/newsgroups
  1504. X# backup newsgroups, then strip duplicates
  1505. Xcp $NEWSCTL/newsgroups $NEWSCTL/newsgroups.bac || exit 1
  1506. Xsort -u -o $NEWSCTL/newsgroups $NEWSCTL/newsgroups.bac
  1507. X
  1508. X# generate list of approved newsgroups from $nl/newsgroups
  1509. X# [^.]*\. in next two egreps was net.|mod.|fa., which is inadequate - geoff
  1510. X(echo junk; echo control; sed 's/[ \    ].*//' $NEWSCTL/newsgroups |
  1511. X    egrep "^([^.]*\.|general)") | sort -u >/tmp/$$a
  1512. X
  1513. X# generate list of locally-present newsgroups from $nl/active
  1514. Xegrep "^([^.]*\.|general|junk|control)" $NEWSCTL/active | sed 's/ .*//' |
  1515. X    sort -u >/tmp/$$b
  1516. X
  1517. X# compare 'em & note differences
  1518. Xcomm -13 /tmp/$$a /tmp/$$b >/tmp/$$remove
  1519. Xcomm -23 /tmp/$$a /tmp/$$b >/tmp/$$add
  1520. X
  1521. Xif test -s /tmp/$$remove; then
  1522. X    echo "The following newsgroups are not valid and should be removed."
  1523. X    sed "s/^/    /" /tmp/$$remove
  1524. X    echo ""
  1525. X    echo "You can do this by executing the commands:"
  1526. X    sed "s;.*;     $NEWSBIN/maint/delgroup &;" /tmp/$$remove
  1527. X    echo ""
  1528. Xfi 2>&1 >/tmp/$$out
  1529. X
  1530. Xif test -s /tmp/$$add; then
  1531. X    echo "The following newsgroups were missing." # "and were added."
  1532. X    sed "s/^/    /" /tmp/$$add
  1533. X    echo ""
  1534. X
  1535. X#    for i in `cat /tmp/$$add`
  1536. X#    do
  1537. X# *** "Subject: cmsg " is a hideous botch of a kludge-hack; avoid it!
  1538. X#        inews -h <<!
  1539. X#Control: newgroup $i
  1540. X#Newsgroups: control
  1541. X#Subject: newgroup $i
  1542. X#Distribution: general
  1543. X#
  1544. X#Create $i locally.
  1545. X#!
  1546. X#    done
  1547. X
  1548. Xfi 2>&1 >>/tmp/$$out
  1549. X
  1550. Xif test -s /tmp/$$out; then
  1551. X    (echo "Subject: Problems with your active file"; echo "";
  1552. X     cat /tmp/$$out) | mail $NEWSMASTER
  1553. Xfi
  1554. X
  1555. Xrm -f /tmp/$$*        # clean up temporaries
  1556. !
  1557. echo 'relay/ctl/newgroup':
  1558. sed 's/^X//' >'relay/ctl/newgroup' <<'!'
  1559. X#! /bin/sh
  1560. X# newgroup group flag - create group (4-field version: B-2.10.3+ compatible)
  1561. X#    subject to our sys file group pattern
  1562. X
  1563. X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  1564. X. ${NEWSCONFIG-/usr/lib/news/bin/config}
  1565. Xexport NEWSCTL NEWSBIN NEWSARTS
  1566. XPATH=$NEWSCTL/bin:$NEWSBIN/relay:$NEWSBIN:$NEWSPATH ; export PATH # include mkpdir
  1567. Xumask $NEWSUMASK
  1568. X
  1569. XF=/tmp/nc$$
  1570. X
  1571. Xtrap "rm -f $F; exit 0" 0
  1572. Xcat >$F
  1573. X
  1574. X# unapproved ctl msg? then quit
  1575. Xgrep -s '^Approved:' $F >/dev/null || { rm -f $F; exit 0; }
  1576. X
  1577. XSENDER="`grep '^Sender:' $F | sed 's/^[^:]*: *//'`"
  1578. Xcase "$SENDER" in
  1579. X"")    SENDER="`grep '^From:' $F | sed 's/^[^:]*: *//' `" ;;
  1580. Xesac
  1581. X
  1582. Xgreppat="^`echo $1 | sed 's/\./\\\\./g' ` "
  1583. Xif grep -s "$greppat" $NEWSCTL/active >/dev/null; then    # group exists?
  1584. X    export SENDER
  1585. X    chamod "$1" "$2"         # change moderated flag if needed
  1586. X    exit
  1587. Xfi
  1588. X
  1589. Xme="`newshostname`"
  1590. Xgngppat=`awk -f $NEWSBIN/relay/canonsys.awk $NEWSCTL/sys |
  1591. X    egrep "^($me|ME):" |
  1592. X    awk -F: '
  1593. X{
  1594. X    fields = split($2, field2, "/")    # split ngs/dists
  1595. X    print field2[1]            # print only ngs
  1596. X    exit
  1597. X}' `
  1598. X
  1599. Xif gngp -a "$gngppat" >/dev/null <<!
  1600. X$1
  1601. X!
  1602. Xthen            # no group in active, but sys file likes it: make it
  1603. X    case "$2" in
  1604. X    moderated)    flag=m ;;
  1605. X    *)        flag=y ;;
  1606. X    esac
  1607. X    echo "$1 0000000000 00000 $flag" >>$NEWSCTL/active
  1608. X    (echo "$1 `getdate now` $SENDER" >>$NEWSCTL/active.times)  # rn hook
  1609. X    # make the directory since rn will bitch if it's missing
  1610. X    mkpdir $NEWSARTS/`echo $1 | tr . / `
  1611. X    echo "newsgroup $1 was created by $SENDER." | mail $NEWSMASTER
  1612. Xfi
  1613. !
  1614. echo 'relay/ctl/rmgroup':
  1615. sed 's/^X//' >'relay/ctl/rmgroup' <<'!'
  1616. X#! /bin/sh
  1617. X# rmgroup group - snuff group
  1618. X
  1619. X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  1620. X. ${NEWSCONFIG-/usr/lib/news/bin/config}
  1621. Xexport NEWSCTL NEWSBIN NEWSARTS
  1622. XPATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH ; export PATH
  1623. Xumask $NEWSUMASK
  1624. X
  1625. XF=/tmp/nc$$
  1626. X
  1627. Xcat >$F
  1628. X
  1629. X# unapproved ctl msg? then quit
  1630. Xegrep '^Approved:' $F >/dev/null || { rm -f $F; exit 0; }
  1631. X
  1632. X# quit if no active entry
  1633. Xegrep "^`echo $1 | sed 's/\./\\\\./g'` " $NEWSCTL/active >/dev/null ||
  1634. X    { rm -f $F; exit 0; }
  1635. X
  1636. XSENDER="`grep '^Sender:' $F | sed 's/^[^:]*: *//'`"
  1637. Xcase "$SENDER" in
  1638. X"")
  1639. X    SENDER="`grep '^From:' $F | sed 's/^[^:]*: *//'`"
  1640. X    ;;
  1641. Xesac
  1642. X
  1643. X# tell the local usenet administrator to do it by hand
  1644. Xecho "rmgroup $1 says $SENDER" | mail $NEWSMASTER
  1645. X
  1646. Xrm -f $F*
  1647. !
  1648. echo 'relay/ctl/sendsys':
  1649. sed 's/^X//' >'relay/ctl/sendsys' <<'!'
  1650. X#! /bin/sh
  1651. X# sendsys - mail sys file to sender identified in stdin's headers
  1652. X
  1653. X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  1654. X. ${NEWSCONFIG-/usr/lib/news/bin/config}
  1655. Xexport NEWSCTL NEWSBIN NEWSARTS
  1656. XPATH=$NEWSCTL/bin:$NEWSBIN/relay:$NEWSBIN:$NEWSPATH ; export PATH
  1657. Xumask $NEWSUMASK
  1658. X
  1659. XSENDER="`newsreply`"
  1660. X(echo "Subject: response from `newshostname` to your sendsys"; echo "";
  1661. Xcase "$1" in
  1662. X"")    cat $NEWSCTL/sys ;;
  1663. X*)    awk -f $NEWSBIN/relay/canonsys.awk $NEWSCTL/sys | egrep "^$1:" ;;
  1664. Xesac ) | mail "$SENDER"
  1665. Xecho "$NEWSCTL/sys file has been sent to $SENDER.  Remain calm." | mail $NEWSMASTER
  1666. !
  1667. echo 'relay/ctl/senduuname':
  1668. sed 's/^X//' >'relay/ctl/senduuname' <<'!'
  1669. X#! /bin/sh
  1670. X# senduuname - mail `uuname` to sender identified in stdin's headers
  1671. X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  1672. X. ${NEWSCONFIG-/usr/lib/news/bin/config}
  1673. Xexport NEWSCTL NEWSBIN NEWSARTS
  1674. XPATH=$NEWSCTL/bin:$NEWSBIN/relay:$NEWSBIN:$NEWSPATH ; export PATH
  1675. Xumask $NEWSUMASK
  1676. X
  1677. XSENDER="`newsreply`"
  1678. X(echo "Subject: response to your senduuname"; echo ""; uuname) | mail "$SENDER"
  1679. Xecho "uuname output sent to $SENDER" | mail $NEWSMASTER
  1680. !
  1681. echo 'relay/ctl/version':
  1682. sed 's/^X//' >'relay/ctl/version' <<'!'
  1683. X#! /bin/sh
  1684. X# version - mail version id to sender identified in stdin's headers
  1685. X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  1686. X. ${NEWSCONFIG-/usr/lib/news/bin/config}
  1687. Xexport NEWSCTL NEWSBIN NEWSARTS
  1688. XPATH=$NEWSCTL/bin:$NEWSBIN/relay:$NEWSBIN:$NEWSPATH ; export PATH
  1689. Xumask $NEWSUMASK
  1690. X
  1691. XSENDER="`newsreply`"
  1692. Xecho C | mail "$SENDER"
  1693. !
  1694. echo 'relay/aux/mailnews':
  1695. sed 's/^X//' >'relay/aux/mailnews' <<'!'
  1696. X#! /bin/sh
  1697. X# send news by mail, encoded for protection
  1698. X
  1699. X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  1700. X. ${NEWSCONFIG-/usr/lib/news/bin/config}
  1701. X
  1702. XPATH=$NEWSCTL/bin:$NEWSBIN/batch:$NEWSBIN:$NEWSPATH ; export PATH
  1703. X
  1704. Xcase $# in
  1705. X0)    echo "Usage: $0 destination ..." >&2
  1706. X    exit 1
  1707. X    ;;
  1708. Xesac
  1709. X
  1710. X( echo ; bencode ) | mail $*
  1711. !
  1712. echo 'relay/aux/sendnews':
  1713. sed 's/^X//' >'relay/aux/sendnews' <<'!'
  1714. X#! /bin/sh
  1715. X# sendnews destination... - protect & mail article on stdin to destinations
  1716. XPATH=/bin:/usr/bin; export PATH
  1717. X
  1718. Xcase $# in
  1719. X0)
  1720. X    echo "usage: $0 destination..." >&2
  1721. X    exit 1 ;;
  1722. Xesac
  1723. X(echo ''; sed 's/^/N/') | mail $*
  1724. !
  1725. echo 'relay/aux/canonsys.awk':
  1726. sed 's/^X//' >'relay/aux/canonsys.awk' <<'!'
  1727. X# canonicalise the sys file:
  1728. X# delete comments & leading whitespace, collapse continued lines
  1729. X# rewritten to avoid assignment to $0, which is broken in older awks
  1730. X/^/    { thisln = $0 }
  1731. X/^#/    { partline = ""; next }        # delete comments
  1732. X/^[\t ]/    {
  1733. X    for (s = substr(thisln, n); s ~ /^[\t ]/; s = substr(thisln, ++n))
  1734. X        ;            # skip leading whitespace
  1735. X    thisln = s
  1736. X}
  1737. X/\\$/    { partline = partline substr(thisln, 1, length(thisln)-1); next }
  1738. X{                    # non-continued line
  1739. X    partline = partline thisln    # terminate the whole entry
  1740. X    if (partline != "")
  1741. X        print partline
  1742. X    partline = ""
  1743. X}
  1744. XEND    {
  1745. X    if (partline != "")
  1746. X        print partline        # flush any partial line
  1747. X}
  1748. !
  1749. echo 'relay/aux/chamod':
  1750. sed 's/^X//' >'relay/aux/chamod' <<'!'
  1751. X#!/bin/sh
  1752. X# chamod ng flag - change the "moderated" flag for ng to flag
  1753. X
  1754. X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  1755. X. ${NEWSCONFIG-/usr/lib/news/bin/config}
  1756. Xexport NEWSCTL NEWSBIN NEWSARTS
  1757. XPATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH ; export PATH
  1758. Xumask $NEWSUMASK
  1759. X
  1760. Xcase "$1" in
  1761. X"")
  1762. X    echo "$0: null newsgroup not permitted" >&2
  1763. X    exit 1
  1764. X    ;;
  1765. Xesac
  1766. Xcase "$2" in
  1767. Xmoderated)    flag=m ;;
  1768. X*)        flag=y ;;
  1769. Xesac
  1770. X
  1771. Xaflag=`awk "/$1/"' { print $4 }' $NEWSCTL/active`
  1772. Xif test "$aflag" != "$flag" -a \( "$aflag" = m -o "$aflag" = y \); then
  1773. X    # old & new flags differ & old flag is m or y
  1774. X    # watch closely - shell quoting is tricky here
  1775. X    awk '
  1776. X$1 == "'$1'"    {            # this line is for first arg.
  1777. X    print $1, $2, $3, "'$flag'"
  1778. X    next
  1779. X}
  1780. X    { print }
  1781. X' $NEWSCTL/active >$NEWSCTL/active.new
  1782. X    cp $NEWSCTL/active $NEWSCTL/active.old
  1783. X    cp $NEWSCTL/active.new $NEWSCTL/active
  1784. X    rm -f $NEWSCTL/active.new
  1785. X
  1786. X    case "$flag" in
  1787. X    m)    pfx="" ;;
  1788. X    *)    pfx=un ;;
  1789. X    esac
  1790. X    echo "newsgroup $1 was changed to ${pfx}moderated by $SENDER" |
  1791. X        mail $NEWSMASTER
  1792. Xfi
  1793. !
  1794. echo 'relay/aux/mkpdir':
  1795. sed 's/^X//' >'relay/aux/mkpdir' <<'!'
  1796. X#! /bin/sh
  1797. X# mkpdir dir ... - make directory and parents
  1798. X
  1799. X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  1800. X. ${NEWSCONFIG-/usr/lib/news/bin/config}
  1801. Xexport NEWSCTL NEWSBIN NEWSARTS
  1802. XPATH=$NEWSCTL/bin:$NEWSBIN/relay:$NEWSBIN:$NEWSPATH ; export PATH    # must include this file's dir.
  1803. X
  1804. Xumask $NEWSUMASK
  1805. X
  1806. Xstatus=0
  1807. Xfor dir
  1808. Xdo
  1809. X    mkdir "$dir" 2>/dev/null
  1810. X    if test ! -d "$dir"; then
  1811. X        mkpdir "`echo $dir | sed 's;/[^/]*$;;'`"
  1812. X        mkdir "$dir"
  1813. X        if test ! -d "$dir"; then
  1814. X            status=1
  1815. X        fi
  1816. X    fi
  1817. Xdone
  1818. Xexit $status
  1819. !
  1820. echo 'relay/aux/newsreply':
  1821. sed 's/^X//' >'relay/aux/newsreply' <<'!'
  1822. X#! /bin/sh
  1823. X# newsreply - print return address from news article on stdin
  1824. X# This version assumes a domain mailer (user@host.domain works) or
  1825. X# "internet" in mailpaths file, unless $NEWSCTL/replyusepath exists.
  1826. X
  1827. X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  1828. X. ${NEWSCONFIG-/usr/lib/news/bin/config}
  1829. Xexport NEWSCTL NEWSBIN NEWSARTS
  1830. XPATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH ; export PATH
  1831. Xumask $NEWSUMASK
  1832. X
  1833. Xart=/tmp/nc$$
  1834. Xmroute=/tmp/ncm$$
  1835. X
  1836. Xcat >$art
  1837. X
  1838. Xif test -r $NEWSCTL/replyusepath
  1839. Xthen
  1840. X    sender="`grep '^Path:' $art | sed 's/^[^:]*://' `"
  1841. X    echo "$sender"
  1842. X    rm -f $art
  1843. X    exit 0
  1844. Xfi
  1845. X
  1846. X# pick out the appropriate header
  1847. Xsender="` grep '^Reply-To:' $art `"
  1848. Xcase "$sender" in
  1849. X"")    sender="` grep '^From:' $art `" ;;
  1850. Xesac
  1851. X
  1852. X# strip header keyword, full name & duplicate lines, print result.
  1853. X# this copes with "address", "address (full name)" and "full name <address>".
  1854. Xsender=` echo "$sender" | sed 's/^[^:]*:[     ]*//
  1855. Xs/ (.*)//
  1856. Xs/.*<\(.*\)>/\1/
  1857. X1q' `
  1858. X
  1859. X# B 2.11 mailpaths/"internet" hack
  1860. Xcat $NEWSCTL/mailpaths |
  1861. X    while read ngpat route junk
  1862. X    do
  1863. X        case "$ngpat" in
  1864. X        internet)
  1865. X                echo "$route" >$mroute
  1866. X                break
  1867. X                ;;
  1868. X        esac
  1869. X    done
  1870. Xif test -s $mroute; then
  1871. X    sed "s/%s/`
  1872. X        echo $sender | sed 's/\(.*\)@\(.*\)/\2!\1/'
  1873. X        `/" <$mroute    # the real B 2.11 hack: u@d -> route!d!u
  1874. Xelse
  1875. X    echo $sender
  1876. Xfi
  1877. X
  1878. Xrm -f $art $mroute
  1879. !
  1880. echo done
  1881.  
  1882.  
  1883.