home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 400-499 / ff473.lzh / CNewsSrc / cnews_src.lzh / doc / interface < prev    next >
Text File  |  1990-01-11  |  16KB  |  363 lines

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