home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / cnews.tar / doc / interface < prev    next >
Text File  |  1992-12-17  |  17KB  |  581 lines

  1. .Ch "The Interface Between C News And The Outside World"
  2. .Ix "outside world" interface
  3. .SH
  4. Intro and Generalities
  5. .PP
  6. C News relates to the ``outside world'',
  7. the system it is installed on, in a number of ways.
  8. This document attempts to enumerate them and explain what goes on.
  9. .PP
  10. In general,
  11. C News
  12. attempts to rely only on ``common basic Unix'',
  13. .Ix Unix dependencies
  14. and in particular it is not particularly BSD-specific or System-V-specific.
  15. Specifically,
  16. it makes no use of ornate locking mechanisms,
  17. silly interprocess-communication schemes,
  18. peculiar networking primitives,
  19. extensions to C,
  20. or other annoyances.
  21. .SH
  22. Directories And Userids
  23. .PP
  24. .Ix directories
  25. .Ix userids
  26. .Ix /usr/lib/newsbin
  27. .Ix /usr/lib/news
  28. .Ix /usr/spool/news
  29. Most of the components of C News live in \fI/usr/lib/newsbin\fR,
  30. with control files in \fI/usr/lib/news\fR and spooling areas
  31. (for current news, inbound traffic, and outbound traffic) in
  32. \fI/usr/spool/news\fR.
  33. See the document
  34. \fIDirectory Layout and PATH in C News\fR
  35. for elaboration on the structure,
  36. \fIFiles in /usr/lib/news (aka NEWSCTL)\fR
  37. for a summary of control files,
  38. and
  39. \fIConfiguration Mechanisms in C News\fR
  40. for how to change the locations of the directories.
  41. .PP
  42. There is an extensive subdirectory structure under \fI/usr/lib/newsbin\fR,
  43. with only a few heavily-used utilities in the top-level directory.
  44. In the following,
  45. programs not explicitly described as going elsewhere are all under there
  46. somewhere.
  47. .PP
  48. C News's spool areas and major control files need to be owned by a
  49. specific userid,
  50. normally \fInews\fR.
  51. (We believe that nothing except some of the Makefiles knows this name.)
  52. We suggest that this userid should not own anything else on the system.
  53. The programs in \fI/usr/lib/newsbin\fR can be
  54. owned by \fIbin\fR (or anyone else)
  55. except for those that need to be setuid.
  56. .Ix setuid
  57. (On our systems the non-setuid ones are owned by \fIbin\fR.)
  58. .SH
  59. Unix Utilities
  60. .Ix Unix utilities
  61. .PP
  62. C News requires a fairly complete Unix or equivalent.
  63. (We take no position on whether 4BSD, or System V, is Unix or not;
  64. our private opinion is that neither truly deserves the name any more,
  65. although we occasionally change our minds about which is less deserving.)
  66. .Ix Unix spelling
  67. (Note also that ``Unix'' is used here as an abbreviation for
  68. \fBThe UNIX Operating System\fR\(rg,
  69. a registered trademark of AT&T;
  70. we acquired our bad habits and incorrect capitalization from
  71. Unix [sic] documentation supplied by the Bell System in the mid-1970s.)
  72. .PP
  73. .Ix shell
  74. In particular,
  75. C News relies heavily on shell files.
  76. ``Shell'' here means,
  77. of course,
  78. the standard shell,
  79. written by
  80. Steve Bourne.
  81. .Ix "Steve Bourne"
  82. If your \fI/bin/sh\fR is not a Bourne shell or \fIvery\fR good imitation,
  83. you're in trouble.
  84. Note,
  85. in particular,
  86. .Ix shell Korn
  87. .Ix ksh
  88. that some old versions of the Korn shell differ from
  89. the Bourne shell in some important details of quoting behavior, and
  90. we \fIknow\fR this causes problems with C News.
  91. You need a standard shell.
  92. .PP
  93. To the best of our ability,
  94. all our shell files begin with ``#!\ /bin/sh''.
  95. As far as we know,
  96. nothing actually relies on being able to \fIexec\fR a
  97. shell file;
  98. that is,
  99. if ``#!\ /bin/sh'' is just a comment to your shell,
  100. that should be okay.
  101. .Ix shell C
  102. .Ix csh
  103. If your shell misinterprets it as a request to run the C shell,
  104. however,
  105. you're in trouble.
  106. Running the following might help:
  107. .DS
  108. .ft B
  109. for f in `find . \-type f \-print`
  110. do
  111.     if test " `sed 1q $f`" = "#! /bin/sh"
  112.     then
  113.         ed $f <<'!'
  114. 1s/#!/: use/
  115. w
  116. !
  117.     fi
  118. done
  119. .ft
  120. .DE
  121. .Ix shell comments
  122. If your shell doesn't know about ``#'' comments at all,
  123. again you're in trouble.
  124. We hope that no modern shell makes either of these mistakes.
  125. .PP
  126. We believe that none of our stuff relies on relatively modern shell features
  127. like shell functions or
  128. \fIgetopts\fR (as distinct from \fIgetopt\fR).
  129. .Ix shell builtins
  130. If \fItest\fR and \fIecho\fR are not built-in commands in your shell,
  131. efficiency will suffer
  132. but everything should still run.
  133. It's possible that a few obscure things will break if your shell does not
  134. support ``['' as a synonym for \fItest\fR,
  135. although we try to avoid this usage.
  136. .PP
  137. Within the shell files,
  138. C News
  139. makes heavy use of a wide variety of Unix
  140. utilities,
  141. .Ix sed
  142. .Ix awk
  143. notably \fIsed\fR and \fIawk\fR.
  144. Any \fIawk\fR should do;
  145. in particular,
  146. nothing needs the
  147. .Ix nawk
  148. .Ix awk new
  149. ``new \fIawk\fR''.
  150. Although we have tried to avoid it,
  151. it is possible that some things depend
  152. on \fIawk\fR recognizing ``\et'' inside strings,
  153. which very old \fIawk\fRs
  154. didn't.
  155. .PP
  156. If your Unix does not put all standard Unix programs in
  157. the standard directories\(em\fI/bin\fR and
  158. .Ix /bin
  159. .Ix /usr/bin
  160. \fI/usr/bin\fR\(emyou will need to modify C News's default PATH to include
  161. whatever bizarre directories are involved.
  162. See the \fIConfiguration Mechanisms\fR document for details.
  163. In particular,
  164. for some insane reason,
  165. .Ix 4BSD insanity
  166. .Ix /usr/ucb
  167. 4BSD relocated a few standard
  168. utilities like \fIwc\fR to \fI/usr/ucb\fR,
  169. which causes trouble
  170. (and not just to C News!).
  171. We simply put some links in \fI/usr/bin\fR to fix this on our systems,
  172. and this is what we recommend you do,
  173. but if you can't,
  174. you'll have to
  175. change the PATH.
  176. .PP
  177. .Ix mail
  178. Several parts of
  179. C News
  180. rely on being able to send mail to an administrative
  181. account
  182. (the name of which can be chosen;
  183. see \fIConfiguration Mechanisms\fR).
  184. The assumption is that a message,
  185. .Ix "RFC 822" mail
  186. without any RFC822 headers,
  187. can be piped
  188. .Ix /bin/mail
  189. into \fI/bin/mail\fR
  190. (or whatever \fImail\fR is first in the PATH)
  191. invoked with a single argument which is the addressee,
  192. and be delivered to the addressee's mailbox intact,
  193. possibly embellished
  194. with headers.
  195. That is,
  196. with news's standard PATH,
  197. if
  198. .DS
  199. .ft B
  200. echo "relaynews: hi there Joe" | mail joe
  201. .ft
  202. .DE
  203. does not result in the message ``relaynews: hi there Joe''
  204. arriving in the mailbox
  205. ``joe'',
  206. you're going to have to fake it.
  207. (Note that some BSD mailers run into trouble with the colon in the example,
  208. interpreting such a line as a header.)
  209. See \fIDirectory Layout\fR for insight on where to put a fake \fImail\fR
  210. so that C News components will use it rather than \fI/bin/mail\fR.
  211. .PP
  212. Similarly,
  213. several parts of
  214. C News
  215. .Ix hostname
  216. rely on being able to invoke \fIhostname\fR
  217. without arguments,
  218. and have it return a single word which is the name of the
  219. CPU the code is running on.
  220. Again,
  221. you'll have to fake it if you don't have \fIhostname\fR
  222. or if it outputs something strange.
  223. .PP
  224. .Ix compress
  225. Input reception and output batching both want to use the \fIcompress\fR
  226. data-compression program.
  227. \fICompress\fR has been published on Usenet and is shipped with many Unix
  228. systems these days,
  229. but if you don't have it,
  230. we recommend that you get
  231. it from your neighbors or the \fIcomp.sources.unix\fR archives.
  232. .Ix comp.sources.unix
  233. It is possible to configure
  234. C News
  235. so that it doesn't use \fIcompress\fR
  236. to compress news being transmitted,
  237. but you don't want to.
  238. \fICompress\fR is good and it is fast.
  239. .SH
  240. Libraries
  241. .PP
  242. .Ix libraries
  243. C News
  244. is mostly self-contained as far as libraries go.
  245. It does need some things that are not yet universal,
  246. like a full set
  247. of string functions (e.g. \fIstrtok\fR);
  248. .Ix functions string
  249. we provide reasonably portable versions of these for places that lack them.
  250. .SH
  251. Networking
  252. .PP
  253. (We're talking here about networking in the sense of NFS and all those fun
  254. things,
  255. not \fIuucp\fR or TCP/IP.)
  256. C News
  257. is designed to run on systems which consist of a conglomeration of
  258. machines on a local network,
  259. with only one of them acting as news server.
  260. Be warned,
  261. though,
  262. that if you're doing this,
  263. .Ix rsh
  264. .Ix "remote command execution"
  265. you need to have \fIrsh\fR
  266. or some reasonably equivalent way of executing a program on another CPU.
  267. If you've only got one machine,
  268. .Ix server
  269. .Ix files server
  270. just make sure you \fIdon't\fR have a \fI/usr/lib/news/server\fR file and
  271. forget the whole issue.
  272. .SH
  273. Highly System-Specific Things
  274. .PP
  275. .Ix dependencies system
  276. .Ix "system dependencies"
  277. There are two small utilities within
  278. C News
  279. that are inevitably highly
  280. system-specific and have a high probability of needing changes to match
  281. your system.
  282. Both normally live in \fI/usr/lib/newsbin\fR proper.
  283. .PP
  284. .Df spacefor
  285. \fISpacefor\fR is invoked by various components of C News to find out
  286. how much disk space is available.
  287. The space margins in it are ones we find reasonable, but you may need
  288. to adjust them.
  289. On an old System V system in particular
  290. (one where \fIdf\fR can't be applied
  291. to any directory name,
  292. but needs to be given a name in \fI/dev\fR),
  293. you
  294. will also probably need to modify the locations to be \fIdf\fRed.
  295. You will also need to fix \fIspacefor\fR if your system's \fIdf\fR yields
  296. results in some strange format or in some strange units.
  297. We believe that we get it right for stock 4BSD,
  298. many (but probably not all)
  299. System Vs,
  300. modern Irix,
  301. and real Unix (Version 7).
  302. .Ix Unix real
  303. .Ix Unix V7
  304. Beware introducing major inefficiencies:
  305. \fIspacefor\fR is called a lot.
  306. Beware,
  307. also,
  308. that \fIspacefor\fR is not intended to permit routine operation
  309. using filesystems that are on the brink of being full;
  310. the limits it imposes are only approximate,
  311. and no attempt has been made
  312. to tune its clients to exploit every last available block.
  313. .PP
  314. .Df queuelen
  315. \fIQueuelen\fR is invoked by the batcher to determine how long the current
  316. \fIuucp\fR queues are,
  317. so it can judge whether it should suspend batching
  318. of output to a given site.
  319. .Ix uucp
  320. There is too much diversity in \fIuucp\fRs for us to try to do this for all
  321. possible versions.
  322. We think we get it right for the two most common flavors
  323. (HDB, aka BNU, and old subdirectory versions).
  324. Our versions measure queue length in batches,
  325. not bytes,
  326. but it would not be hard to change this:
  327. \fIqueuelen\fR,
  328. .Ix batchparms
  329. the \fIbatchparms\fR control file,
  330. .Ix sendbatches
  331. and the \fIsendbatches\fR
  332. how-many-batches-should-I-try-to-add logic need to agree on the units of
  333. measurement,
  334. but (we think) nothing else cares.
  335. .PP
  336. .Df newshostname
  337. It is just possible that you might have to modify \fInewshostname\fR,
  338. which also lives in \fI/usr/lib/newsbin\fR itself.
  339. \fINewshostname\fR delivers the name which should be applied to the
  340. whole system (not just the particular CPU) for news purposes.
  341. It tries to be fairly clever about different ways of getting the name,
  342. and in particular will take it out of \fI/usr/lib/news/whoami\fR if
  343. .Ix whoami
  344. that file exists,
  345. but if you're doing something odd on a strange system,
  346. changes may be needed.
  347. .SH
  348. Input
  349. .PP
  350. .Ix input network
  351. .Ix "network input"
  352. Input from the net via \fIuucp\fR (or equivalent) shows up as batches of
  353. news to be fed to \fIrnews\fR or its obsolete synonym \fIcunbatch\fR.
  354. .Df rnews
  355. .Df cunbatch
  356. These two programs normally live in \fI/bin\fR,
  357. although nothing in the
  358. code knows about this and they can go elsewhere
  359. (one of our systems does this).
  360. .Ix newsspool
  361. Both are simple front ends that invoke \fIinput/newsspool\fR to store the
  362. batch,
  363. while taking precautions to report trouble and not to overflow disks.
  364. Neither \fIrnews\fR nor \fIcunbatch\fR needs to be setuid.
  365. .PP
  366. .Ix NNTP input
  367. Input via NNTP over the Internet (or equivalent) uses rather different
  368. machinery
  369. .Ix nntpd
  370. .Ix snntpd
  371. (typically one of
  372. .I nntpd
  373. or
  374. .I snntpd
  375. receives batches)
  376. but ends up creating a saved batch in much the same way as
  377. \fIinput/newsspool\fR does.
  378. .PP
  379. .Df newsspool
  380. \fIInput/newsspool\fR is a small C program that saves a batch,
  381. writing into a file in \fI/usr/spool/news/in.coming\fR.
  382. .Ix in.coming
  383. It must be able to create files there, and \fIinput/newsrun\fR (see below)
  384. needs to be able to read them and delete them.
  385. .Ix newsrun
  386. This gets a little tricky because \fInewsspool\fR will usually be
  387. run by \fIuuxqt\fR as userid \fIuucp\fR (or something like that),
  388. not as \fInews\fR,
  389. which \fInewsrun\fR needs to run as.
  390. The recommended solution is to have
  391. \fInewsspool\fR owned by \fInews\fR and setuid.
  392. An alternative is to give the \fIin.coming\fR directory
  393. the userid of \fInews\fR and the groupid of \fIuucp\fR,
  394. or vice versa,
  395. and set permissions so that either can access it.
  396. One of our systems ran that way for a while.
  397. .PP
  398. .Df newsrun
  399. To actually process incoming news,
  400. \fIinput/newsrun\fR gets invoked
  401. to decompress the spooled batches and
  402. feed them to \fIrelay/relaynews\fR (see below).
  403. There is an option for \fInewsspool\fR to invoke
  404. \fInewsrun\fR when a batch is spooled,
  405. but a (usually)
  406. .Ix cron
  407. preferable method is to have \fIcron\fR invoke \fInewsrun\fR once an hour.
  408. \fINewsrun\fR does its own locking to prevent multiple occurrences running
  409. simultaneously.
  410. There is a related program,
  411. .Ix newsrunning
  412. \fIinput/newsrunning\fR, that can be used
  413. to set or clear a flag that stops \fInewsrun\fR;
  414. this may be a useful tactic if \fInewsrun\fR should not run at
  415. certain times.
  416. Both \fInewsrun\fR and \fInewsrunning\fR must be run as \fInews\fR.
  417. .PP
  418. When a user posts news,
  419. he (or his news reader) does it by feeding the
  420. article to \fI/bin/inews\fR.
  421. .Df inews
  422. In C News, \fIinews\fR is a complex shell file that attends to preliminaries
  423. and then invokes \fIrelay/relaynews\fR.
  424. \fIInews\fR does not need to be setuid (indeed,
  425. we make no use of setuid
  426. shell files at all,
  427. since they are grossly insecure).
  428. .Ix setuid
  429. .Df relaynews
  430. \fIRelaynews\fR is the heart of
  431. C News,
  432. the program that actually pulls
  433. batches apart and places articles into the database.
  434. .SH
  435. News Readers
  436. .Ix "news readers"
  437. .PP
  438. C News
  439. is fully compatible with
  440. B News
  441. to any news-reader program that
  442. does not inspect the middle field of \fI/usr/lib/news/history\fR too closely.
  443. .Ix history
  444. Standard B News news readers work fine.
  445. We supply a simple news reader
  446. (written by,
  447. and included with permission of,
  448. Michael Rourke)
  449. as a naive-user replacement for the B News
  450. \fIreadnews\fR.
  451. .Ix "news readers" readnews
  452. More complex programs are preferable for serious news enthusiasts.
  453. We recommend
  454. Larry Wall's \fIrn\fR
  455. .Ix "news readers" rn
  456. or
  457. Kim Storm's
  458. .I nn
  459. .Ix "news readers" nn
  460. (which we use, unmodified),
  461. but there are others.
  462. .SH
  463. Output
  464. .PP
  465. \fIRelay/relaynews\fR normally queues up news for transmission to other
  466. systems by appending article names and sizes to batch files
  467. in subdirectories under \fI/usr/spool/news/out.going\fR.
  468. .Ix out.going
  469. These are then processed by \fIbatch/sendbatches\fR,
  470. .Df sendbatches
  471. which should be run
  472. regularly,
  473. as \fInews\fR,
  474. by \fIcron\fR.
  475. .Ix cron
  476. \fISendbatches\fR can be configured to use a variety of transmission
  477. mechanisms,
  478. the usual one being \fIuux\fR.
  479. .Ix uux
  480. Alternately,
  481. one might run
  482. .I sendnntp
  483. .Ix sendnntp
  484. to invoke
  485. .I snntp .
  486. .Ix snntp
  487. .SH
  488. Expiry And Related
  489. .PP
  490. .Df expire
  491. .Ix article removal
  492. .Ix article archiving
  493. News articles are removed,
  494. possibly with archiving to an archive area,
  495. by the expiry subsystem.
  496. \fIExpire/doexpire\fR should be invoked now and then,
  497. .Ix doexpire
  498. as \fInews\fR,
  499. by \fIcron\fR.
  500. .Ix cron
  501. We suggest nightly.
  502. \fIDoexpire\fR actually invokes \fIexpire/expire\fR to do the dirty work.
  503. .PP
  504. C News \fIexpire\fR does not have an option to rebuild the
  505. \fI/usr/lib/news/history\fR file from scratch,
  506. .Ix history
  507. since that has nothing to do with expiry.
  508. To rebuild \fIhistory\fR,
  509. e.g. if it has been destroyed,
  510. use \fIexpire/mkhistory\fR.
  511. .Ix mkhistory
  512. .Ix history rebuild
  513. .PP
  514. Some news readers
  515. (notably the NNTP-based ones)
  516. need to have the third field of \fI/usr/lib/news/active\fR
  517. updated occasionally to show the lowest article number still present in each
  518. newsgroup.
  519. .Ix active "third field"
  520. .Ix files active
  521. Frankly,
  522. we think such news readers
  523. (and NNTP)
  524. simply need to be fixed.
  525. C News
  526. \fIexpire\fR does not do this updating.
  527. For those who use such news readers,
  528. however,
  529. \fIexpire/upact\fR will do
  530. such an update.
  531. .Ix upact
  532. It should be run as \fInews\fR.
  533. A much faster, but somewhat less portable,
  534. C implementation is
  535. supplied as \fIexpire/updatemin\fR.
  536. .Ix updatemin
  537. .SH
  538. Reboots and Administration
  539. .Ix reboots
  540. .Ix crashes
  541. .Ix lock
  542. .PP
  543. If the system crashes,
  544. things like locks must be cleaned out if C News
  545. is to function properly after reboot.
  546. \fI/etc/rc\fR,
  547. or equivalent,
  548. should run \fImaint/newsboot\fR during reboot,
  549. as \fInews\fR.
  550. .Ix /etc/rc
  551. .Ix newsboot
  552. .PP
  553. .Ix logs
  554. Certain log files can grow without bounds if not renamed/removed now and
  555. then.
  556. We recommend running \fImaint/newsdaily\fR once a day.
  557. .Ix newsdaily
  558. It tends to logs,
  559. keeping a generation or two for use in trouble tracking,
  560. and also sends mail to the news administrator in the event that something
  561. funny has happened.
  562. .PP
  563. In general,
  564. .Ix lock problems
  565. C News does not attempt to break locks,
  566. on the philosophy that a stale lock may mean something is badly wrong.
  567. (See
  568. \fILocking in C News\fR for details on locking methods.)
  569. The various programs will either give up,
  570. to return later,
  571. or wait
  572. patiently for the lock to go away.
  573. If one doesn't keep an eye on things, a problem of some kind can hang up
  574. the news system for quite a while.
  575. Running \fImaint/newswatch\fR once in a while\(emwe recommend a few times
  576. a day\(emwill alert administrators to signs of trouble.
  577. .Ix newswatch
  578. Except on grossly slow systems,
  579. C News locks should never hang around for
  580. any great length of time.
  581.