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

  1. Subject:  v19i080:  Cnews production release, Part03/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 80
  8. Archive-name: cnews2/part03
  9.  
  10. : ---CUT HERE---
  11. echo 'conf/build':
  12. sed 's/^X//' >'conf/build' <<'!'
  13. X#! /bin/sh
  14. X
  15. X# functions and headers we are prepared to fake
  16. Xmightfake='fsync getopt index memcpy memcmp memchr memset mkdir
  17. X    putenv rindex strchr strrchr strpbrk strspn strcspn strtok symlink'
  18. Xmightfakehdrs='stdlib.h string.h'
  19. X
  20. X# directories in which to do makes
  21. X# batch must precede input; relay must precede misc
  22. Xpgmdirs='conf batch expire input relay misc rna'
  23. X
  24. X# control files built in conf
  25. Xctlf="active allowed errlog history history.pag history.dir localgroups"
  26. Xctlf="$ctlf log mailname mailpaths organization postdefltdist postdefltgroup"
  27. Xctlf="$ctlf replyusepath server sys whoami"
  28. X
  29. Xecho 'This interactive command will build shell files named doit.root,'
  30. Xecho 'doit.bin, doit.news, and again.root to do all the work.  It will not'
  31. Xecho 'actually do anything itself, so feel free to abort and start again.'
  32. Xecho
  33. Xecho 'You probably need your system manuals handy.'
  34. Xecho
  35. Xecho 'When a question is asked in the form "How are you [okay]? ", the'
  36. Xecho 'answer in brackets is what you will get if you just hit RETURN.'
  37. X
  38. Xchmod +x query            # just in case
  39. Xif test " `./query hi | wc -c`" -ne 2
  40. Xthen
  41. X    echo 'The "query" utility that this command needs does not seem to'
  42. X    echo 'be working properly.  It is supposed to work like "echo"'
  43. X    echo 'except not produce a newline at the end.  You will have to fix'
  44. X    echo 'it (it is a shell file).  (Most versions of "echo" have a way'
  45. X    echo 'to suppress the newline, but unfortunately there are at least'
  46. X    echo 'two different incompatible ways.)'
  47. X    exit 1
  48. Xfi
  49. X
  50. Xecho
  51. Xecho 'C News wants to keep most of its files under a uid which preferably'
  52. Xecho 'should be all its own.  Its programs, however, can and probably should'
  53. Xecho 'be owned by another user, typically the same one who owns most of the'
  54. Xecho 'rest of the system.'
  55. X./query 'What user id should be used for news files [news]? '
  56. Xread newsuid
  57. Xcase "$newsuid" in
  58. X'')    newsuid=news    ;;
  59. Xesac
  60. X./query 'What group id should be used for news files [news]? '
  61. Xread newsgid
  62. Xcase "$newsgid" in
  63. X'')    newsgid=news    ;;
  64. Xesac
  65. X./query 'What user id should be used for news programs [bin]? '
  66. Xread binuid
  67. Xcase "$binuid" in
  68. X'')    binuid=bin    ;;
  69. Xesac
  70. X./query 'What group id should be used for news programs [bin]? '
  71. Xread bingid
  72. Xcase "$bingid" in
  73. X'')    bingid=bin    ;;
  74. Xesac
  75. X
  76. Xanswer=
  77. Xif test -d /var -a -d /usr/share
  78. Xthen
  79. X    echo
  80. X    echo 'It would appear that your system is among the victims of the'
  81. X    echo '4.4BSD / SVR4 directory reorganization, with (e.g.) shared'
  82. X    ./query 'data in /usr/share.  Is this correct [yes]? '
  83. X    read answer
  84. X    case "$answer" in
  85. X    y*|Y*|'')    answer=y    ;;
  86. X    esac
  87. Xfi
  88. Xif test " $answer" = " y"
  89. Xthen
  90. X    echo 'This will affect where C News directories go.  We recommend'
  91. X    echo 'making the directories wherever they have to go and then making'
  92. X    echo 'symbolic links to them under the standard names that are used'
  93. X    echo 'as defaults in the following questions.  Should such links'
  94. X    ./query 'be made [yes]? '
  95. X    read makelinks
  96. X    case "$makelinks" in
  97. X    y*|Y*|'')    makelinks=y    ;;
  98. X    esac
  99. X    echo 'Our 4.4ish friends suggest putting articles in /var/spool/news'
  100. X    echo 'and control files in /usr/share/news, with programs left where'
  101. X    echo 'they are in /usr/lib/newsbin.'
  102. Xfi
  103. X
  104. Xneedsubst=
  105. Xecho
  106. Xecho 'C News lives primarily under three directories:  one for articles (and'
  107. Xecho 'incoming and outgoing spooling), one for control files, and one for'
  108. Xecho 'programs.'
  109. X./query 'Where should articles live [/usr/spool/news]? '
  110. Xread newsarts
  111. Xcase "$newsarts" in
  112. X'')    newsarts=/usr/spool/news    ;;
  113. X*)    needsubst=y    ;;
  114. Xesac
  115. X./query 'Where should control files live [/usr/lib/news]? '
  116. Xread newsctl
  117. Xcase "$newsctl" in
  118. X'')    newsctl=/usr/lib/news    ;;
  119. X*)    needsubst=y    ;;
  120. Xesac
  121. X./query 'Where should programs live [/usr/lib/newsbin]? '
  122. Xread newsbin
  123. Xcase "$newsbin" in
  124. X'')    newsbin=/usr/lib/newsbin    ;;
  125. X*)    needsubst=y    ;;
  126. Xesac
  127. Xif test " $makelinks" = " y"
  128. Xthen
  129. X    realarts="$newsarts"
  130. X    realctl="$newsctl"
  131. X    realbin="$newsbin"
  132. X    newsarts="/usr/spool/news"
  133. X    newsctl="/usr/lib/news"
  134. X    newsbin="/usr/lib/newsbin"
  135. Xfi
  136. X
  137. Xecho
  138. Xecho 'C News by default assumes that all normal Unix programs can be found'
  139. Xecho 'in /bin or /usr/bin.  This is naive, especially on Berkeley-derived'
  140. Xecho 'systems where some standard programs inexplicably moved to /usr/ucb.'
  141. Xnewspath='/bin:/usr/bin'
  142. Xif test '(' ! -f /bin/wc -a ! -f /usr/bin/wc ')' -o \
  143. X            '(' ! -f /bin/hostname -a ! -f /usr/bin/hostname -a \
  144. X                        -f /usr/ucb/hostname ')'
  145. Xthen
  146. X    echo 'It would appear that some standard programs live in /usr/ucb'
  147. X    ./query 'on your system.  Is that right [yes]? '
  148. X    read ucb
  149. Xelse
  150. X    echo 'It would appear that /usr/ucb does not exist or is not needed'
  151. X    ./query 'for normal operation on your system.  Is that right [yes]? '
  152. X    read ucb
  153. X    case "$ucb" in
  154. X    y*|Y*|'')    ucb=no    ;;
  155. X    n*|N*)        ucb=yes    ;;
  156. X    esac
  157. Xfi
  158. Xcase "$ucb" in
  159. Xy*|Y*|'')    ./query 'Should /usr/ucb go before or after /bin and /usr/bin [after]? '
  160. X        read answer
  161. X        case "$answer" in
  162. X        a*|A*|'')    newspath="$newspath:/usr/ucb"    ;;
  163. X        *)        newspath="/usr/ucb:$newspath"    ;;
  164. X        esac
  165. X        needsubst=y
  166. X        ;;
  167. Xesac
  168. Xwhile true
  169. Xdo
  170. X    echo 'Is there any other directory which should be searched to find'
  171. X    ./query 'standard programs on your system [no]? '
  172. X    read answer
  173. X    case "$answer" in
  174. X    n*|N*|'')    break    ;;
  175. X    *)        needsubst=y    ;;
  176. X    esac
  177. X    ./query 'What is the full name of the directory? '
  178. X    read dir
  179. X    ./query 'Should it go before or after the others [after]? '
  180. X    read answer
  181. X    case "$answer" in
  182. X    a*|A*|'')    newspath="$newspath:$dir"    ;;
  183. X    *)        newspath="$dir:$newspath"    ;;
  184. X    esac
  185. Xdone
  186. X
  187. Xecho
  188. Xecho 'C News normally uses a umask of 002, turning off only the others-write'
  189. Xecho 'bit in the permissions of files used.  (The correspondence between bits'
  190. Xecho 'and number is:  rwx = 421, so turning off group-write bits and all'
  191. Xecho 'others-access bits would be a mask of 027, for example.)  Usually'
  192. Xecho 'a umask of 002 or 022 is appropriate.'
  193. X./query 'What umask should C News use [002]? '
  194. Xread newsumask
  195. Xcase "$newsumask" in
  196. X'')    newsumask=002    ;;
  197. X*)    needsubst=y    ;;
  198. Xesac
  199. X
  200. Xecho
  201. Xecho 'C News wants to mail some forms of trouble reports to an administrator.'
  202. Xecho 'You probably want to make this a system mailbox, rather than that of a'
  203. Xecho "specific user, so you won't have to change the software when you get a"
  204. Xecho 'new administrator.'
  205. X./query 'Where should C News mail trouble reports [usenet]? '
  206. Xread newsmaster
  207. Xcase "$newsmaster" in
  208. X'')    newsmaster=usenet    ;;
  209. X*)    needsubst=y    ;;
  210. Xesac
  211. X
  212. Xecho
  213. Xecho 'The shell files that are everywhere in C News want to pick up their'
  214. Xecho 'configuration parameters (mostly, the last few questions you have'
  215. Xecho 'answered) from a file at a known location; this is very hard to avoid'
  216. Xecho 'unless you play tricks with environment variables (see documentation).'
  217. Xecho 'Where should the shell configuration file be'
  218. X./query "located [$newsctl/bin/config]? "
  219. Xread newsconfig
  220. Xcase "$newsconfig" in
  221. X'')    newsconfig=$newsctl/bin/config    ;;
  222. X*)    needsubst=y    ;;
  223. Xesac
  224. X
  225. Xecho
  226. X./query 'What is the full pathname of the chown command [/etc/chown]? '
  227. Xread chown
  228. Xcase "$chown" in
  229. X'')    chown=/etc/chown    ;;
  230. Xesac
  231. Xecho "Can I say '$chown $newsuid.$newsgid file' to change both the user id"
  232. X./query 'and group id of a file [yes]? '
  233. Xread chboth
  234. Xcase "$chboth" in
  235. Xy*|Y*|'')    chboth=y    ;;
  236. Xesac
  237. Xif test " $chboth" != " y"
  238. Xthen
  239. X    ./query 'Is there a chgrp command to change the group of a file [yes]? '
  240. X    read chgrp
  241. X    case "$chgrp" in
  242. X    n*|N*)    echo 'You will need to edit doit.root by hand before running it.'
  243. X        echo "It will assume that 'chown $newsuid.$newsgid' works."
  244. X        chboth=y
  245. X        ;;
  246. X    *)    ./query 'What is the full pathname of the chgrp command [/etc/chgrp]? '
  247. X        read chgrp
  248. X        case "$chgrp" in
  249. X        '')    chgrp=/etc/chgrp    ;;
  250. X        esac
  251. X        ;;
  252. X    esac
  253. Xfi
  254. X
  255. Xecho
  256. Xecho 'building doit.root...'
  257. X>doit.root
  258. Xif test ! -w doit.root
  259. Xthen
  260. X    echo 'It appears that I cannot create doit.root.  Aborting.'
  261. X    exit 1
  262. Xfi
  263. X(
  264. X    echo "umask $newsumask"
  265. X    echo 'set -x'
  266. X    echo ": making directories..."
  267. X    if test " $makelinks" = " y"
  268. X    then
  269. X        echo "mkdir $realarts $realctl $realbin"
  270. X        if test " $realarts" != " $newsarts"
  271. X        then
  272. X            echo "ln -s $realarts $newsarts"
  273. X        fi
  274. X        if test " $realctl" != " $newsctl"
  275. X        then
  276. X            echo "ln -s $realctl $newsctl"
  277. X        fi
  278. X        if test " $realbin" != " $newsbin"
  279. X        then
  280. X            echo "ln -s $realbin $newsbin"
  281. X        fi
  282. X    fi
  283. X    n="$newsarts $newsarts/in.coming $newsarts/in.coming/bad"
  284. X    n="$n $newsarts/out.going $newsctl $newsctl/bin"
  285. X    b="$newsbin"
  286. X    echo "for d in $n $b"
  287. X    echo "do"
  288. X    echo "    if test ! -d \$d"
  289. X    echo "    then"
  290. X    echo "        mkdir \$d"
  291. X    echo "    fi"
  292. X    echo "done"
  293. X    if test " $chboth" = " y"
  294. X    then
  295. X        echo "$chown $newsuid.$newsgid $n"
  296. X        echo "$chown $binuid.$bingid $b"
  297. X    else
  298. X        echo "$chown $newsuid $n"
  299. X        echo "$chgrp $newsgid $n"
  300. X        echo "$chown $binuid $b"
  301. X        echo "$chgrp $bingid $b"
  302. X    fi
  303. X    echo ": done"
  304. X) >>doit.root
  305. Xecho 'done'
  306. X
  307. Xecho
  308. Xecho 'C News has libraries for several kinds of Unix:'
  309. Xecho '    bsd42    4.2BSD and successors'
  310. Xecho '    usg    AT&T System V'
  311. Xecho '    v7    Version 7 (4.1BSD is pretty close, ditto Xenix)'
  312. Xecho '    v8    Version 8, aka Eighth Edition'
  313. Xwhile true
  314. Xdo
  315. X    ./query 'Which best describes your system [v7]? '
  316. X    read unixkind
  317. X    if test " $unixkind" = " "
  318. X    then
  319. X        unixkind=v7
  320. X    fi
  321. X    if test -d ../lib$unixkind
  322. X    then
  323. X        break
  324. X    fi
  325. X    echo 'Sorry, no such library is supplied.'
  326. Xdone
  327. X
  328. Xecho
  329. Xecho 'C News has libraries for small address spaces (16 bits) and big'
  330. Xecho 'ones (preferably 32 bits, but anything rather bigger than 16).'
  331. Xwhile true
  332. Xdo
  333. X    ./query 'Which best describes your system [big]? '
  334. X    read addrsize
  335. X    if test " $addrsize" = " "
  336. X    then
  337. X        addrsize=big
  338. X    fi
  339. X    if test -d ../lib$addrsize
  340. X    then
  341. X        break
  342. X    fi
  343. X    echo 'Sorry, no such library is supplied.'
  344. Xdone
  345. X
  346. Xecho
  347. Xecho 'Systems vary in whether certain library functions and system calls'
  348. Xecho 'are present.  C News contains reasonably-portable versions of the'
  349. Xecho 'possibly-missing library functions, and fake versions of the'
  350. Xecho 'possibly-missing system calls, but it needs to know which are missing.'
  351. Xfake=
  352. Xfor fn in $mightfake
  353. Xdo
  354. X    ./query "Does your system have  $fn() [yes]? "
  355. X    read answer
  356. X    case "$answer" in
  357. X    y*|Y*|'')    ;;
  358. X    *)    fake="$fake $fn.o"    ;;
  359. X    esac
  360. Xdone
  361. X./query "Does your system have a library function ldiv() as in ANSI C? [no]? "
  362. Xread answer
  363. Xcase "$answer" in
  364. Xn*|N*|'')    fake="$fake ldiv.o"    ;;
  365. Xesac
  366. X./query 'Does your system have the "dbm" library [yes]? '
  367. Xread answer
  368. Xcase "$answer" in
  369. Xy*|Y*|'')    ./query 'What is the compile option needed to get it [-ldbm]? '
  370. X        read answer
  371. X        case "$answer" in
  372. X        '')    answer=-ldbm    ;;
  373. X        esac
  374. X        dbm="DBM=$answer"
  375. X        ;;
  376. X*)    fake="$fake dbm.o"
  377. X    dbm='DBM='
  378. X    echo "Okay, we'll fake it for you.  You might want to look at"
  379. X    echo "contrib/dbz, which is a probably-superior fake that we have"
  380. X    echo "not examined closely."
  381. X    ;;
  382. Xesac
  383. X
  384. Xecho
  385. Xecho 'Many systems, notably older ones, have implementations of the Standard'
  386. Xecho 'I/O library ("stdio") in which fgets, fputs, fread, and fwrite, although'
  387. Xecho 'correct, are quite slow.  We supply versions of these functions which'
  388. Xecho 'are faster than those in any stdio we know; they are compatible with'
  389. Xecho 'most AT&T-derived stdios.  If they work on your system, they are a'
  390. Xecho 'major performance win for C News.  There is a simple compatibility'
  391. Xecho 'check run after the library is built.  The only system we know of'
  392. Xecho 'where the test works but the functions do not is SunOS 4.0.'
  393. X./query 'Do you want to use our fast stdio library [yes]? '
  394. Xread libstdio
  395. Xcase "$libstdio" in
  396. Xy*|Y*|'')    libstdio=libstdio    ;;
  397. X*)        libstdio=        ;;
  398. Xesac
  399. X
  400. Xif test " $dbm" != " DBM="
  401. Xthen
  402. X    echo
  403. X    echo 'Does the store() function in your dbm library return a'
  404. X    ./query 'value (some old ones did not) [yes]? '
  405. X    read storeval
  406. X    case "$storeval" in
  407. X    y*|Y*|'')    storeval=y    ;;
  408. X    esac
  409. Xelse
  410. X    storeval=y
  411. Xfi
  412. X
  413. Xfound=
  414. Xfor f in $fake dummy
  415. Xdo
  416. X    if test " $f" = " index.o"
  417. X    then
  418. X        found=y
  419. X    fi
  420. Xdone
  421. Xif test " $found" = " "
  422. Xthen
  423. X    echo
  424. X    echo 'A well-tuned index() function customized to a particular machine'
  425. X    echo 'is usually faster than portable C.  Is your index() function'
  426. X    ./query 'indeed fast (okay to guess) [yes]? '
  427. X    read fastindex
  428. X    case "$fastindex" in
  429. X    y*|Y*|'')    fastindex=y    ;;
  430. X    esac
  431. Xfi
  432. X
  433. Xecho
  434. Xecho 'Modern Unixes can generally use the setuid() system call to set the'
  435. Xecho 'real and effective user ids to the current effective user id.  In'
  436. Xecho 'old Unixes, only "root" can change the real user id.  This causes'
  437. Xecho 'various problems for C News.  C News provides a small program named'
  438. Xecho '"setnewsids" to run setuserid-root; all it does is change user and'
  439. Xecho 'group ids and then execute C News "relaynews".  It is needed only in'
  440. Xecho 'systems that are too old to do setuid(geteuid()).  Relaynews invokes'
  441. Xecho 'it automatically if needed (and it then invokes relaynews in return).'
  442. X./query 'Can this system do setuid(geteuid()) [yes]? '
  443. Xread sete
  444. Xcase "$sete" in
  445. Xy*|Y*|'')    sete=y    ;;
  446. Xesac
  447. X
  448. Xecho
  449. Xecho 'Some systems have header files that others lack, and C News'
  450. Xecho 'is prepared to fake missing ones.'
  451. Xfakehdrs=
  452. Xfor h in $mightfakehdrs
  453. Xdo
  454. X    ./query "Does your system have an ANSI-C-conforming <$h> [yes]? "
  455. X    read answer
  456. X    case "$answer" in
  457. X    y*|Y*|'')    ;;
  458. X    *)    fakehdrs="$fakehdrs ../include/$h"    ;;
  459. X    esac
  460. Xdone
  461. X./query "Does your system have <sys/timeb.h> [yes]? "
  462. Xread answer
  463. Xcase "$answer" in
  464. Xn*|N*)    fakehdrs="$fakehdrs ../include/sys/timeb.h"    ;;
  465. Xesac
  466. X
  467. Xecho
  468. Xecho 'Some old systems think sprintf() returns a value of type "char *".'
  469. Xecho 'The modern standard is that it returns "int".  Does your sprintf()'
  470. X./query 'return "char *" [no]? '
  471. Xread answer
  472. Xcase "$answer" in
  473. Xn*|N*|'')    ;;
  474. X*)        echo 'You may have to hand-edit our "libc.h" include file if'
  475. X        echo 'your compiler objects to us declaring sprintf() to'
  476. X        echo 'return "int".  (This will usually happen only if your'
  477. X        echo '<stdio.h> header file declares sprintf() -- some do,'
  478. X        echo 'some do not.)  If you do need to edit "libc.h", look'
  479. X        echo 'for the definition of "sprvalue".'
  480. X        ;;
  481. Xesac
  482. X
  483. Xecho
  484. Xecho 'Very old Unix systems needed the order of object modules in a library'
  485. Xecho 'chosen very carefully.  V7 introduced "ranlib" which removes the need'
  486. Xecho 'for this.  Recent System Vs have had the same facility built into "ar"'
  487. Xecho '(look for "symdef" in the "ar" manual page) so "ranlib" is not needed.'
  488. X./query "Does your system have a 'ranlib' command [no]? "
  489. Xread ranlib
  490. Xcase "$ranlib" in
  491. Xn*|N*|'')
  492. X    ./query 'Does your "ar" have a "symdef" feature [yes]? '
  493. X    read answer
  494. X    case "$answer" in
  495. X    n*|N*)    echo 'You have trouble and may need to modify doit.bin before'
  496. X        echo 'running it.  It will assume "ranlib" is present.'
  497. X        ranlib=y
  498. X        ;;
  499. X    *)    ranlib=
  500. X        ;;
  501. X    esac
  502. X    ;;
  503. X*)    ranlib=y
  504. X    ;;
  505. Xesac
  506. X
  507. Xecho
  508. Xecho 'Historically the C compiler is named "cc", but this is not true on'
  509. Xecho 'some systems, and on others there are several different C compilers.'
  510. X./query 'What is the name of the C compiler to be used [cc]? '
  511. Xread cc
  512. Xcase "$cc" in
  513. X'')    cc=    ;;
  514. X*)    cc="CC=$cc"    ;;
  515. Xesac
  516. X
  517. Xecho
  518. Xecho 'Historically the only normal compilation option needed for most'
  519. Xecho 'programs is -O, but again compilers, especially newer ones, differ.'
  520. X./query "What options should be given to the compiler [-O]? "
  521. Xread copts
  522. Xcase "$copts" in
  523. X'')    copts=    ;;
  524. X*)    copts="COPTS='$copts'"    ;;
  525. Xesac
  526. X
  527. Xecho
  528. X./query 'Does your system have a "hostname" command [yes]? '
  529. Xread hostname
  530. Xcase "$hostname" in
  531. Xy*|Y*|'')    hostname=y    ;;
  532. X*)    ./query 'Does it have a "uname" command with a "-n" option [yes]? '
  533. X    read hostname
  534. X    case "$hostname" in
  535. X    y*|Y*|'')    hostname=u    ;;
  536. X    *)        hostname=    ;;
  537. X    esac
  538. X    ;;
  539. Xesac
  540. X
  541. Xecho
  542. Xecho 'C News tries to limit the backlog of news batches spooled up for'
  543. Xecho 'transmission to a site, to control use of disk space.  To do this,'
  544. Xecho 'it needs to be able to determine the length of the queue of news'
  545. Xecho 'batches for a particular site.  This is UUCP-version-dependent.'
  546. Xecho 'There is a good chance that you will have to customize the "queuelen"'
  547. Xecho 'program.  C News knows about several versions:'
  548. Xecho '    hdb    Honey DanBer, aka Basic Networking Utilities'
  549. Xecho '    sub    old uucp with subdirectories (e.g. /usr/spool/uucp/C.)'
  550. Xecho "    null    don't run uucp or don't care about queue lengths"
  551. Xwhile true
  552. Xdo
  553. X    ./query 'Which one is most appropriate [hdb]? '
  554. X    read uucptype
  555. X    case "$uucptype" in
  556. X    '')    uucptype=hdb    ;;
  557. X    sub)    echo 'Beware -- test "queuelen" to make sure it works.'    ;;
  558. X    esac
  559. X    case "$uucptype" in
  560. X    hdb|sub|null)    break    ;;
  561. X    esac
  562. X    echo 'Sorry, no such choice is available.'
  563. Xdone
  564. X
  565. Xecho
  566. Xecho 'C News often wants to ask how much disk space is available.  The'
  567. Xecho 'format of output from the "df" command unfortunately varies a lot.'
  568. Xecho 'C News knows about several different versions:'
  569. Xecho '    bsd    4.2BSD and later'
  570. Xecho '    sysv    most System Vs'
  571. Xecho '    sgi    Silicon Graphics Iris systems'
  572. Xecho '    v7    plain old style:  no headers or fluff, just name and number'
  573. Xecho "    null    don't know or don't care how much space is available"
  574. Xwhile true
  575. Xdo
  576. X    ./query 'Which one is most appropriate [bsd]? '
  577. X    read dftype
  578. X    case "$dftype" in
  579. X    '')    dftype=bsd    ;;
  580. X    sysv)    echo 'Beware -- test "spacefor" to make sure it works.'
  581. X        echo 'System V "df" formats vary widely, indeed wildly.'
  582. X        echo '"Consider it standard".  Sure.'
  583. X        ;;
  584. X    esac
  585. X    case "$dftype" in
  586. X    bsd|sysv|sgi|v7|null)    break    ;;
  587. X    esac
  588. X    echo 'Sorry, no such choice is available.'
  589. Xdone
  590. X
  591. Xecho
  592. Xecho 'Some "df" commands, especially on old systems, must be given the'
  593. Xecho 'name of a device.  Modern ones can be given any directory name and'
  594. Xecho 'the system handles the details of figuring out what device is meant.'
  595. X./query 'Does your "df" accept a directory name as an argument [yes]? '
  596. Xread answer
  597. Xcase "$answer" in
  598. Xn*|N*)    echo 'You are going to have to customize "spacefor" for your system.'
  599. X    echo 'It will be generated assuming that directory names do work.'
  600. X    ;;
  601. Xesac
  602. X
  603. Xecho
  604. X./query 'Are you planning to use expire to archive news on disk [no]? '
  605. Xread answer
  606. Xcase "$answer" in
  607. Xy*|Y*)    echo 'You probably want to customize the "archive" entry in'
  608. X    echo '"spacefor" so it knows where your archiving is done and how'
  609. X    echo 'much space you want free there.'
  610. X    ;;
  611. Xesac
  612. X
  613. Xecho
  614. X./query 'Are you particularly short of disk space [no]? '
  615. Xread answer
  616. Xcase "$answer" in
  617. Xy*|Y*)    echo 'You may want to reconsider whether you really want to get'
  618. X    echo 'news, unless you are getting only a very small set of groups.'
  619. X    echo 'In any case, you definitely want to inspect "spacefor" and'
  620. X    echo 'change some of its thresholds for free space.'
  621. X    ;;
  622. X*)    echo 'You may want to inspect "spacefor" to make sure its defaults'
  623. X    echo 'for things like desired free space are appropriate for your'
  624. X    echo 'system, although the defaults are fairly conservative.'
  625. X    ;;
  626. Xesac
  627. X
  628. Xecho
  629. Xecho 'Are you running C News on a group of machines hooked together with'
  630. X./query 'NFS, with articles filed on only one "server" machine [no]? '
  631. Xread answer
  632. Xserver=
  633. Xcase "$answer" in
  634. Xy*|Y*)    if test " $hostname" = " "
  635. X    then
  636. X        echo 'With a server but no "hostname" command, you will have'
  637. X        echo 'problems and will probably have to tinker by hand to'
  638. X        echo 'get a fake "hostname" that does the right thing.  The'
  639. X        echo 'generated files will assume you have "hostname".'
  640. X        hostname=y
  641. X    fi
  642. X    if test " $hostname" = " u"
  643. X    then
  644. X        ./query 'What is the "uname -n" name of the server? '
  645. X    else
  646. X        ./query 'What is the "hostname" name of the server? '
  647. X    fi
  648. X    read server
  649. X    ;;
  650. Xesac
  651. X
  652. Xecho
  653. Xecho 'Several programs need to know an overall name for the system news is'
  654. Xecho 'being run on, where "system" may include multiple machines if they'
  655. Xecho 'share a common set of control files and articles; this is used in'
  656. Xecho 'article headers and related places.  For uucp sites, this usually'
  657. Xecho 'should be the uucp name.  What is the name of the overall system'
  658. X./query 'for news purposes? '
  659. Xread whoami
  660. X
  661. Xecho
  662. Xecho 'The "From:" lines of news postings, on the other hand, should carry'
  663. Xecho 'a mailing address, which in particular should be a domain address'
  664. Xecho 'for sites that have one.  What is the mailing-address name of this'
  665. X./query "system, preferably a domain address [$whoami.uucp]? "
  666. Xread mailname
  667. Xcase "$mailname" in
  668. X'')    mailname="$whoami.uucp"    ;;
  669. Xesac
  670. X
  671. Xecho
  672. Xecho 'What is the name of the organization, for insertion into articles'
  673. X./query 'posted from here? '
  674. Xread organization
  675. X
  676. Xecho
  677. Xecho 'What user other than root (if any) should be allowed to create'
  678. X./query 'new news groups [no such user]? '
  679. Xread allowed
  680. X
  681. Xecho
  682. Xecho 'Manual pages are normally stored in a tree structure under /usr/man.'
  683. Xecho 'Local practices vary a great deal, however, and System V has also'
  684. Xecho 'introduced some bizarre distortions into this once-simple structure.'
  685. X./query 'What is the top-level manual-page directory [/usr/man]? '
  686. Xread manpages
  687. Xcase "$manpages" in
  688. X'')    manpages=/usr/man    ;;
  689. Xesac
  690. X
  691. Xecho
  692. Xchaps='1 5 8'
  693. Xecho 'C News adds manual pages to chapters 1 (programs), 5 (files), and'
  694. Xecho '8 (administrative programs).  These chapter numbers have changed'
  695. Xecho 'in some variants of Unix.  Also, originally pages from chapter 5 (for'
  696. Xecho "example) were stored in $manpages/man5.  This has also changed in"
  697. X./query 'some variants.  Has your system made either of these changes [no]? '
  698. Xread answer
  699. Xcase "$answer" in
  700. Xy*|Y*)    echo 'You will have to hand-edit the last few lines of doit.bin'
  701. X    echo 'to install the manual pages where they belong on your system.'
  702. X    ;;
  703. Xesac
  704. X
  705. Xecho
  706. Xecho 'The "rnews" and "cunbatch" commands (which are identical, the latter'
  707. Xecho 'being purely for backward compatibility with seriously-old systems)'
  708. Xecho 'have to be installed somewhere where uucp can find them to execute'
  709. Xecho 'them.  It is not normally necessary for users to be able to run'
  710. Xecho 'them, so they need not go in the directories searched for normal'
  711. Xecho 'commands... although uucp often searches only those directories.'
  712. X./query 'What directory should "rnews" and "cunbatch" go in [/bin]? '
  713. Xread rbin
  714. Xcase "$rbin" in
  715. X'')    rbin=/bin    ;;
  716. Xesac
  717. X
  718. Xecho
  719. Xecho 'The "inews", "postnews", "readnews", and "checknews" commands should'
  720. Xecho 'go in one of the directories searched for normal commands, so users'
  721. Xecho 'can run them without special arrangements.  What directory should'
  722. X./query 'these commands go in [/bin]? '
  723. Xread bin
  724. Xcase "$bin" in
  725. X'')    bin=/bin    ;;
  726. Xesac
  727. X
  728. Xecho
  729. Xecho 'For replies to control messages, C News invokes "mail" (typically'
  730. Xecho '/bin/mail unless you make special arrangements) with either an'
  731. Xecho 'Internet-style "@" address or a uucp-style "!" address.  Internet'
  732. Xecho 'style is probably better... if your mailer supports it at all.'
  733. X./query 'Will "mail" handle "@" addresses [no]? '
  734. Xread atok
  735. Xcase "$atok" in
  736. Xy*|Y*)    atok=y    ;;
  737. X*)    atok=    ;;
  738. Xesac
  739. X
  740. Xecho
  741. Xecho 'Postnews can supply a default newsgroup, to assist naive users in'
  742. Xecho 'getting the group right for simple postings.  What should the default'
  743. X./query 'newsgroup for postnews be [no default]? '
  744. Xread postdefltgroup
  745. X
  746. Xecho
  747. Xecho 'Postnews can supply a default distribution, to restrict news to a'
  748. Xecho 'local area unless the user specifically changes it.  This is probably'
  749. Xecho 'a good idea.  What should the default distribution for postnews'
  750. X./query 'be [world]? '
  751. Xread postdefltdist
  752. X
  753. Xecho
  754. Xecho 'building doit.bin...'
  755. X>doit.bin
  756. Xif test ! -w doit.bin
  757. Xthen
  758. X    echo 'It appears that I cannot create doit.bin.  Aborting.'
  759. X    exit 1
  760. Xfi
  761. X(
  762. X    echo "umask $newsumask"
  763. X    echo "set -x"
  764. X    echo ': setting up for substitutions'
  765. X    echo "cat >nsubstitutions <<'!'"
  766. X    cat <<!
  767. X# master substitutions file
  768. X#
  769. X# where the programs live (see also NEWSCONFIG)
  770. XNEWSBIN        $newsbin
  771. X# where the control files live
  772. XNEWSCTL        $newsctl
  773. X# where the articles live
  774. XNEWSARTS    $newsarts
  775. X# what PATH should be used for finding normal programs
  776. X# (things not in NEWSBIN, that is)
  777. XNEWSPATH    $newspath
  778. X# the umask under which files should be created
  779. XNEWSUMASK    $newsumask
  780. X# who to send mail to when there is trouble
  781. XNEWSMASTER    $newsmaster
  782. X# configuration file that lets shell files pick up all of this
  783. XNEWSCONFIG    $newsconfig
  784. X!
  785. X    echo '!'
  786. X    echo 'if test -r substitutions && cmp -s nsubstitutions substitutions'
  787. X    echo 'then'
  788. X    echo '    rm nsubstitutions'
  789. X    echo 'else'
  790. X    echo '    mv nsubstitutions substitutions'
  791. X    echo 'fi'
  792. X    echo ': done'
  793. X    echo ': building headers'
  794. X    echo 'cd ..'
  795. X    echo 'if test ! -d include'
  796. X    echo 'then'
  797. X    echo '    mkdir include include/sys'
  798. X    echo 'fi'
  799. X    echo 'cd h'
  800. X    echo 'rm -f nnewshsed'
  801. X    if test " $fastindex" != " y"
  802. X    then
  803. X        echo 'echo "/FASTINDEX.*qqq/s;^;/* ;" >>nnewshsed'
  804. X    fi
  805. X    if test " $storeval" = " y"
  806. X    then
  807. X        echo 'echo "/NOSTOREVAL.*qqq/s;^;/* ;" >>nnewshsed'
  808. X    fi
  809. X    if test " $addrsize" = " big"
  810. X    then
  811. X        echo 'echo "/SMALLMEM.*qqq/s;^;/* ;" >>nnewshsed'
  812. X    fi
  813. X    echo 'if test -f newshsed && cmp -s nnewshsed newshsed'
  814. X    echo 'then'
  815. X    echo '    rm -f nnewshsed'
  816. X    echo 'else'
  817. X    echo '    mv nnewshsed newshsed'
  818. X    echo 'fi'
  819. X    echo 'make all || exit 1'
  820. X    echo 'cd ../hfake'
  821. X    echo "ed - Makefile <<'!'"
  822. X    echo "/NEEDED =/s~.*~NEEDED = $fakehdrs~"
  823. X    echo "w"
  824. X    echo "!"
  825. X    echo "make all || exit 1"
  826. X    echo ": done"
  827. X    echo ": making substitutions..."
  828. X    echo "cd ../conf"
  829. X    if test " $needsubst" = " y"
  830. X    then
  831. X        echo "make substs"
  832. X    else
  833. X        echo ": make substs        not necessary, defaults used"
  834. X    fi
  835. X    echo ": done"
  836. X    echo ": making spacefor, queuelen, etc...."
  837. X    echo "rm -f spacefor queuelen hostname setnewsids"
  838. X    echo "make spacefor.$dftype"
  839. X    echo "cp spacefor.$dftype spacefor"
  840. X    echo "make queuelen.$uucptype"
  841. X    echo "cp queuelen.$uucptype queuelen"
  842. X    if test " $hostname" = " y"
  843. X    then
  844. X        echo "# ( echo '#! /bin/sh' ; echo 'echo $whoami' ) >hostname"
  845. X    elif test " $hostname" = " u"
  846. X    then
  847. X        echo "( echo '#! /bin/sh' ; echo 'uname -n' ) >hostname"
  848. X    else
  849. X        echo "( echo '#! /bin/sh' ; echo 'echo $whoami' ) >hostname"
  850. X    fi
  851. X    echo ': done'
  852. X    echo ': making library...'
  853. X    if test " $ranlib" = " y"
  854. X    then
  855. X        echo "touch ../ranlibed"
  856. X        echo "sleep 2"
  857. X    fi
  858. X    echo "for dir in lib$unixkind lib$addrsize libc libcnews $libstdio"
  859. X    echo "do"
  860. X    echo "    cd ../\$dir"
  861. X    echo "    make u $cc $copts || exit 1"
  862. X    echo "done"
  863. X    echo "cd ../libfake"
  864. X    echo "ed - Makefile <<'!'"
  865. X    echo "/NEEDED =/s/.*/NEEDED = $fake/"
  866. X    echo "w"
  867. X    echo "!"
  868. X    echo "make u $cc $copts || exit 1"
  869. X    echo "cd ../conf"
  870. X    if test " $ranlib" = " y"
  871. X    then
  872. X        echo "make ../ranlibed"
  873. X    fi
  874. X    echo ': library done'
  875. X    if test " $libstdio" != " "
  876. X    then
  877. X        echo ': testing libstdio'
  878. X        echo 'cd ../libstdio'
  879. X        echo "make trials $cc $copts || exit 1"
  880. X        echo ': done'
  881. X    fi
  882. X    echo ': building programs'
  883. X    echo 'cd ../conf'
  884. X    if test " $sete" != " y"
  885. X    then
  886. X        echo "make setnewsids NEWSUSER=$newsuid NEWSGROUP=$newsgid $cc $copts"
  887. X    fi
  888. X    echo "for dir in $pgmdirs"
  889. X    echo "do"
  890. X    echo "    cd ../\$dir"
  891. X    echo "    make all $dbm $cc $copts"
  892. X    echo "done"
  893. X    echo ": done"
  894. X    echo ": building prototype control files"
  895. X    echo "cd ../conf"
  896. X    echo "rm -f $ctlf"
  897. X    echo "cp config.proto config"
  898. X    echo "echo '$mailname' >mailname"
  899. X    echo "cat <<'!' >organization"
  900. X    echo "$organization"
  901. X    echo '!'
  902. X    if test " $allowed" != " "
  903. X    then
  904. X        echo "echo '$allowed' >allowed"
  905. X    fi
  906. X    if test " $server" != " "
  907. X    then
  908. X        echo "echo '$server' >server"
  909. X    fi
  910. X    if test " $atok" != " y"
  911. X    then
  912. X        echo echo "'replies must use "!" addresses' >replyusepath"
  913. X    fi
  914. X    if test " $postdefltdist" != " "
  915. X    then
  916. X        echo "echo '$postdefltdist' >>postdefltdist"
  917. X    fi
  918. X    if test " $postdefltgroup" != " "
  919. X    then
  920. X        echo "echo '$postdefltgroup' >>postdefltgroup"
  921. X    fi
  922. X    echo "echo '$whoami' >whoami"
  923. X    echo "echo 'general 00000 00000 y' >active"
  924. X    echo "echo 'news.announce.newusers 00000 00000 y' >>active"
  925. X    echo ">errlog"
  926. X    echo ">history"
  927. X    echo ">history.pag"
  928. X    echo ">history.dir"
  929. X    echo "echo 'general    general local news' >localgroups"
  930. X    echo ">log"
  931. X    echo "echo 'all    uunet!%s' >mailpaths"    # crude
  932. X    echo "cp sys.proto sys"
  933. X    echo "cat >cron <<'!'"
  934. X    cat <<!
  935. X15 *    1-31 *    0-6    su news -c '$newsbin/input/newsrun'
  936. X30 8    1-31 *    1-5    su news -c '$newsbin/input/newsrunning off'
  937. X00 17    1-31 *    1-5    su news -c '$newsbin/input/newsrunning on'
  938. X40 *    1-31 *    0-6    su news -c '$newsbin/batch/sendbatches'
  939. X59 0    1-31 *    0-6    su news -c '$newsbin/expire/doexpire'
  940. X45 3    1-31 *    0-6    su news -c '$newsbin/expire/superkludge comp.mail.maps'
  941. X10 8    1-31 *    0-6    su news -c '$newsbin/maint/newsdaily'
  942. X00 5,13,21    1-31 *    0-6    su news -c '$newsbin/maint/newswatch'
  943. X!
  944. X    echo "!"
  945. X    echo "echo 'su news -c $newsbin/maint/newsboot' >rc"
  946. X    echo ": done"
  947. X    echo ': installing programs'
  948. X    echo "for dir in $pgmdirs"
  949. X    echo "do"
  950. X    echo "    cd ../\$dir"
  951. X    echo "    make bininstall BIN=$bin RBIN=$rbin $dbm"
  952. X    echo "done"
  953. X    echo ": done"
  954. X    echo ': installing manual pages'
  955. X    echo 'cd ../man'
  956. X    for chap in $chaps
  957. X    do
  958. X        for f in `ls ../man | egrep "\.$chap\$"`
  959. X        do
  960. X            echo "cp $f $manpages/man$chap/$f"
  961. X        done
  962. X    done
  963. X    echo ': done'
  964. X) >>doit.bin
  965. Xecho 'done'
  966. X
  967. Xecho
  968. Xecho 'building doit.news...'
  969. X>doit.news
  970. Xif test ! -w doit.news
  971. Xthen
  972. X    echo 'It appears that I cannot create doit.news.  Aborting.'
  973. X    exit 1
  974. Xfi
  975. X(
  976. X    echo "umask $newsumask"
  977. X    echo 'set -x'
  978. X    echo ': installing programs'
  979. X    echo "for dir in $pgmdirs"
  980. X    echo "do"
  981. X    echo "    cd ../\$dir"
  982. X    echo "    make newsinstall BIN=$bin RBIN=$rbin $dbm"
  983. X    echo "done"
  984. X    echo ": done"
  985. X    echo ": installing control files"
  986. X    echo "cd ../conf"
  987. X    echo "for f in $ctlf"
  988. X    echo "do"
  989. X    echo "    if test -r $newsctl/\$f"
  990. X    echo "    then"
  991. X    echo "        echo \"$newsctl/\$f already exists; left unchanged\""
  992. X    echo "    elif test ! -r \$f"
  993. X    echo "    then"
  994. X    echo "        : \"\$f\" not wanted"
  995. X    echo "    else"
  996. X    echo "        cp \$f $newsctl/\$f"
  997. X    echo "    fi"
  998. X    echo "done"
  999. X    echo "if test -r $newsconfig"
  1000. X    echo "then"
  1001. X    echo "    echo '$newsconfig already exists; left unchanged'"
  1002. X    echo "else"
  1003. X    echo "    cp config $newsconfig"
  1004. X    echo "    chmod +x $newsconfig"
  1005. X    echo "fi"
  1006. X    echo ": It is virtually certain that some of those control files"
  1007. X    echo ": need modifying to suit your system.  In particular, you"
  1008. X    echo ": should pick up a current 'active' file from your neighbors."
  1009. X    echo ": done"
  1010. X) >>doit.news
  1011. Xecho 'done'
  1012. X
  1013. Xecho
  1014. Xecho 'building again.root...'
  1015. X>again.root
  1016. Xif test ! -w again.root
  1017. Xthen
  1018. X    echo 'It appears that I cannot create again.root.  Aborting.'
  1019. X    exit 1
  1020. Xfi
  1021. X(
  1022. X    echo "umask $newsumask"
  1023. X    echo 'set -x'
  1024. X    if test " $sete" != " y"
  1025. X    then
  1026. X        echo ": installing setnewsids"
  1027. X        echo "cp setnewsids $newsctl"
  1028. X        echo "$chown root $newsctl/setnewsids"
  1029. X        echo "chmod u+s $newsctl/setnewsids"
  1030. X        echo ": done"
  1031. X    fi
  1032. X    echo ": setting uids for setuid programs..."
  1033. X    them="$newsbin/input/newsspool $newsbin/relay/relaynews"
  1034. X    if test " $chboth" = " y"
  1035. X    then
  1036. X        echo "$chown $newsuid.$newsgid $them"
  1037. X    else
  1038. X        echo "$chown $newsuid $them"
  1039. X        echo "$chgrp $newsgid $them"
  1040. X    fi
  1041. X    echo "chmod u+s,g+s $them"
  1042. X    echo ": done"
  1043. X) >>again.root
  1044. Xecho 'done'
  1045. X
  1046. Xecho
  1047. Xchmod +x doit.root doit.bin doit.news again.root
  1048. Xecho 'You should now run doit.root as root (or as somebody with the power'
  1049. Xecho "to create $newsctl, $newsarts, and $newsbin"
  1050. Xecho "and run chown), doit.bin as $binuid, doit.news as $newsuid, and"
  1051. Xecho "again.root as root (or as somebody with the power to run chown),"
  1052. Xecho 'in that order.  Finally, you will want to add the contents of'
  1053. Xecho "'cron', or something similar, to your cron's work-to-be-done"
  1054. Xecho "file(s), and the contents of 'rc', or something similar, to"
  1055. Xecho '/etc/rc or whatever your system executes when booting.'
  1056. Xecho
  1057. Xecho '"make gclean" will clean up everything afterwards.  "make lclean"'
  1058. Xecho 'does a less drastic cleanup affecting only the library directories.'
  1059. Xecho '"make spotless" does "make gclean" and also removes the doit files.'
  1060. Xecho
  1061. Xecho 'Good luck and happy news reading.'
  1062. !
  1063. echo 'conf/setnewsids.c':
  1064. sed 's/^X//' >'conf/setnewsids.c' <<'!'
  1065. X/*
  1066. X * setnewsids - sets ids to news/news, execs relay/relaynews.  Should be setuid-root.
  1067. X *    also add NEWSPERMS to the environment.
  1068. X */
  1069. X
  1070. X#include <stdio.h>
  1071. X#include <errno.h>
  1072. X#include <pwd.h>
  1073. X#include <grp.h>
  1074. X#include <sys/types.h>
  1075. X
  1076. X#include "news.h"
  1077. X#include "libc.h"
  1078. X#include "config.h"
  1079. X
  1080. X#ifndef RELAYNEWS
  1081. X#define RELAYNEWS binfile("relay/relaynews")
  1082. X#endif
  1083. X#ifndef NEWSUSER
  1084. X#define NEWSUSER "news"
  1085. X#endif
  1086. X#ifndef NEWSGROUP
  1087. X#define NEWSGROUP "news"
  1088. X#endif
  1089. X
  1090. Xchar *progname;
  1091. X
  1092. Xstatic int userealids = NO;
  1093. X
  1094. X/*
  1095. X * main - parse arguments and handle options
  1096. X */
  1097. Xmain(argc, argv)
  1098. Xint argc;
  1099. Xchar *argv[];
  1100. X{
  1101. X    extern int optind;
  1102. X    extern char *optarg;
  1103. X
  1104. X    progname = argv[0];
  1105. X
  1106. X    /* setuid daemon prelude; various precautions */
  1107. X    (void) umask(2);    /* undo silly umasks, ignore newsumask() */
  1108. X    (void) alarm(0);    /* cancel any pending alarm */
  1109. X    /*
  1110. X     * Reset certain environment variables to sane values.
  1111. X     */
  1112. X    if (putenv("PATH=/bin:/usr/bin") ||
  1113. X        putenv("IFS= \t\n"))
  1114. X        exit(1);
  1115. X    closeall(1);        /* closes all but std descriptors */
  1116. X    stdfdopen();        /* ensure standard descriptors are open */
  1117. X
  1118. X    setids();        /* change of real and effective ids */
  1119. X    /* we are now running as news, so you can all relax */
  1120. X
  1121. X    if (putenv("NEWSPERMS="))    /* avoid loops with this marker */
  1122. X        exit(1);
  1123. X    execv(RELAYNEWS, argv);    /* re-run relaynews */
  1124. X    error("can't exec %s", RELAYNEWS);
  1125. X}
  1126. X
  1127. Xsetids()            /* change of real and effective ids */
  1128. X{
  1129. X    int newsuid = getuid(), newsgid = getgid();    /* default to real ids */
  1130. X
  1131. X    (void) ctlfile((char *)NULL);    /* trigger unprivileged(), set userealids */
  1132. X    if (!userealids) {
  1133. X        register struct passwd *pwp;
  1134. X        register struct group *grp;
  1135. X
  1136. X        pwp = getpwnam(NEWSUSER);
  1137. X        if (pwp != NULL) {
  1138. X            newsuid = pwp->pw_uid;
  1139. X            newsgid = pwp->pw_gid;
  1140. X        }
  1141. X        (void) endpwent();
  1142. X        grp = getgrnam(NEWSGROUP);
  1143. X        if (grp != NULL)
  1144. X            newsgid = grp->gr_gid;
  1145. X        (void) endgrent();
  1146. X    }
  1147. X    if (setgid(newsgid) < 0 || setuid(newsuid) < 0 ||
  1148. X        getgid() != newsgid || getuid() != newsuid)    /* xenix workaround */
  1149. X        error("set[ug]id failed", "");
  1150. X    /* we are now running as news, so you can all relax */
  1151. X}
  1152. X
  1153. Xvoid
  1154. Xunprivileged()            /* called if NEWSARTS, NEWSCTL or NEWSBIN present */
  1155. X{
  1156. X    userealids = YES;
  1157. X}
  1158. !
  1159. echo 'conf/spacefor.proto':
  1160. sed 's/^X//' >'conf/spacefor.proto' <<'!'
  1161. X#! /bin/sh
  1162. X# spacefor - determine available disk space
  1163. X# About how many things of $1 bytes will fit in the available space for
  1164. X# stuff of type $2 ("incoming", "articles", "control", "outbound $3",
  1165. X# or "archive") without cramping things too badly?
  1166. X#
  1167. X# You'll have to change this -- your blocksize, minimum-free-desired amounts,
  1168. X# and df output format will probably differ, and you may need to name
  1169. X# your filesystems explicitly.
  1170. X
  1171. X# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  1172. X. ${NEWSCONFIG-/usr/lib/news/bin/config}
  1173. X
  1174. XPATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH ; export PATH
  1175. Xumask $NEWSUMASK
  1176. X
  1177. X# punt to server if necessary
  1178. Xif test -r $NEWSCTL/server
  1179. Xthen
  1180. X    server="`cat $NEWSCTL/server`"
  1181. X    me="`hostname`"
  1182. X    if test " $server" != " $me"
  1183. X    then
  1184. X        exec rsh $server "PATH=$PATH `basename $0` $*"
  1185. X        # does not return
  1186. X    fi
  1187. Xfi
  1188. X
  1189. X# head off special case
  1190. Xcase "$1" in
  1191. X0)    echo 10000 ; exit 0 ;;
  1192. Xesac
  1193. X
  1194. X# argument to df, df units, and free space desired (in df units)
  1195. Xdfunit=1024            # default unit (bytes)
  1196. Xcase "$2" in
  1197. Xincoming)    arg="$NEWSARTS/in.coming" ; desire=5000 ;;
  1198. Xarticles)    arg="$NEWSARTS" ; desire=5000 ;;
  1199. Xcontrol)    arg="$NEWSCTL" ; desire=3000 ;;
  1200. Xoutbound)    arg="/usr/spool/uucp" ; desire=10000 ;;    # ignore $3
  1201. Xarchive)    arg="$NEWSARTS" ; desire=1 ;;        # system-specific
  1202. X*)        echo "$0: bad type argument \`$2'!!" >&2
  1203. X        exit 2 ;;
  1204. Xesac
  1205. X
  1206. X# this is set up for the stupid 4BSD df
  1207. Xdf $arg | awk "BEGIN { nf = 4 ; nr = 2 }
  1208. X    NR == nr && NF >= nf {
  1209. X        nb = (\$nf - $desire) * $dfunit / $1
  1210. X        if (nb > 10000)
  1211. X            nb = 10000    # ensure representable as integer
  1212. X        nb = int(nb)
  1213. X        if (nb <= 0)
  1214. X            print 0
  1215. X        else
  1216. X            print nb
  1217. X        exit
  1218. X    }
  1219. X    NR == nr && NF < nf {        # idiotic Berkeley continuation
  1220. X        nr += 1
  1221. X        nf -= 1
  1222. X    }"
  1223. !
  1224. echo 'notebook/dirs':
  1225. sed 's/^X//' >'notebook/dirs' <<'!'
  1226. X.DA "12 Dec 1988"
  1227. X.TL
  1228. XDirectory Layout and PATH in C News
  1229. X.AU
  1230. XHenry Spencer
  1231. X.AI
  1232. XDept. of Zoology
  1233. XUniversity of Toronto
  1234. X.SH
  1235. XIntro
  1236. X.LP
  1237. XC News is constrained by historical compatibility with B News,
  1238. Xbut we also want to provide more flexibility for local news administrators.
  1239. XAccordingly, our directory organization is a little different from that
  1240. Xof B News.
  1241. XWe also make a lot of use of subordinate programs rather than lumping
  1242. Xeverything into a few giant lumps, and this means we need a notion of
  1243. Xsearch paths.
  1244. X.LP
  1245. XSee also ``Configuration Mechanisms in C News'', which talks about how
  1246. Xto alter the defaults for these paths and such.
  1247. X.SH
  1248. XDirectory organization
  1249. X.LP
  1250. XWe retain the notion that a single directory (usually /usr/spool/news)
  1251. Xis the top of the news-article database.
  1252. XWe also use subdirectories of this directory, using names including `.' to
  1253. Xensure that they cannot collide with newsgroup names,
  1254. Xto hold incoming batches and outgoing batch control files.
  1255. XOne can debate whether this is the right place for these activities,
  1256. Xbut in practice /usr/spool/news tends to be where people want to put
  1257. Xpotentially-big traffic-handling directories,
  1258. Xand it's not worth providing for separate variation of the location.
  1259. X.LP
  1260. XWe do split the former /usr/lib/news into two, however.
  1261. XWe reserve /usr/lib/news itself for control files that are logically
  1262. Xpart of the database.
  1263. X(It would make sense to put those under some subdirectory of
  1264. X/usr/spool/news, but that would break a lot of programs that think these
  1265. Xfiles live in /usr/lib/news.)
  1266. XThe programs\(emthose which don't need to be directly executable by
  1267. Xusers or \fIuucp\fR\(emlive in /usr/lib/newsbin.
  1268. XActually, they usually live in subdirectories thereof,
  1269. Xwith each significant subsystem having its own subdirectory to keep the
  1270. Xindividual directories manageable in complexity.
  1271. XThere are occasional general-purpose utilities at the top level;
  1272. Xthere aren't enough of them to be worth a separate directory.
  1273. X.SH
  1274. XPATH
  1275. X.LP
  1276. XIn general, things are organized to permit sharing of /usr/lib/newsbin
  1277. Xamong multiple databases.
  1278. XIt doesn't make sense to share /usr/lib/news among multiple databases,
  1279. Xas much of the stuff that lives there is logically part of the database.
  1280. X.LP
  1281. XThere is a possibility that an individual database will want to override
  1282. Xspecific decisions made by the programs, i.e. will want its own version
  1283. Xof some programs.
  1284. XAccordingly, provision is made for a `bin' directory under /usr/lib/news.
  1285. XNews software should set its PATH to something on the order of
  1286. X.DS
  1287. X/usr/lib/news/bin:/usr/lib/newsbin/xxx:/usr/lib/newsbin:/bin:/usr/bin
  1288. X.DE
  1289. X(See the ``Configuration Mechanisms'' document for how this
  1290. Xshould \fIactually\fR be written, to facilitate configuration changes
  1291. Xand local customization.)
  1292. XThat is, first look in the database's bin directory for overrides,
  1293. Xthen in some subdirectory of /usr/lib/newsbin for the subsystem's
  1294. Xprograms, then in newsbin itself for news-wide utilities,
  1295. Xthen in the standard system directories for standard Unix utilities.
  1296. !
  1297. echo 'notebook/bdiffs':
  1298. sed 's/^X//' >'notebook/bdiffs' <<'!'
  1299. X.TL
  1300. XDifferences between B 2.11 news and C news
  1301. X.AU
  1302. XGeoff Collyer
  1303. X.AI
  1304. XDepartment of Statistics
  1305. XUniversity of Toronto
  1306. X.SH
  1307. XIntroduction
  1308. X.PP
  1309. XThis document attempts to describe the major
  1310. Xdifferences between
  1311. XB 2.11 news
  1312. Xand
  1313. XC news;
  1314. Xit cannot pretend to be complete.
  1315. XSince the message format of both is the one described in
  1316. XARPA Internet RFC 1036,
  1317. Xthe differences arise primarily in how the software is set up
  1318. Xand administered.
  1319. X.PP
  1320. XC news
  1321. Xwas begun before
  1322. XB 2.11 news
  1323. Xwas released,
  1324. Xand later updated to match the worthwhile changes in
  1325. XB 2.11 news.
  1326. X.SH
  1327. XDifferences in files
  1328. X.PP
  1329. X.I Locking.
  1330. XC news
  1331. Xlocks are intended to be compatible with those of
  1332. XB 2.10 news.
  1333. XC news
  1334. Xlocks out
  1335. X.I expire
  1336. Xand
  1337. X.I rnews
  1338. Xby linking to the name
  1339. X.I /usr/lib/news/LOCK
  1340. Xand repeating until successful;
  1341. Xthere is no time-out
  1342. Xsuch as the one in
  1343. XB 2.10 news,
  1344. Xso humans can lock the news system and
  1345. Xperform surgery on it with confidence.
  1346. XB 2.11 news
  1347. Xis believed to use more modern kernel locking facilities
  1348. Xsuch as
  1349. X.I flock (2)
  1350. Xand
  1351. X.I lockf (2).
  1352. XOne important difference is that
  1353. XC news's
  1354. Xlocks will work across network file systems,
  1355. Xmodulo problems caused by lock removal in
  1356. X.I /etc/rc .
  1357. X.PP
  1358. X.I "Log files."
  1359. XC news's
  1360. Xare terse.
  1361. X.PP
  1362. X.I "History file."
  1363. XC news
  1364. Xuses an extended
  1365. XB 2.10 news
  1366. Xformat:
  1367. Xthe second field consists of two subfields
  1368. Xseparated by a tilde:
  1369. Xtime received as an integer (a
  1370. X.I time_t
  1371. Xin fact),
  1372. Xand
  1373. Xthe value of the
  1374. X.I Expires:
  1375. Xheader,
  1376. X"-" if none.
  1377. XB 2.11 news
  1378. Xdoes not record the
  1379. X.I Expires:
  1380. Xvalue and stores the time received in a peculiar variant of
  1381. X.I ctime (3)
  1382. Xformat,
  1383. Xwhich cannot be parsed by
  1384. X.I getdate (3),
  1385. Xto the annoyance of
  1386. X.I nntp .
  1387. XYou must lock the news system with
  1388. X.I locknews
  1389. Xbefore editing the history file.
  1390. X.PP
  1391. X.I "active file."
  1392. XC news
  1393. Xwill tolerate two,
  1394. Xthree,
  1395. Xor
  1396. Xfour
  1397. Xfields in the
  1398. X.I active
  1399. Xfile,
  1400. Xand
  1401. Xany number of digits in the article-number fields
  1402. X(hint: five is too few).
  1403. XC news
  1404. Xalso supports two new values for the fourth field:
  1405. X.B x ,
  1406. Xmeaning
  1407. X``quietly discard articles for this group'',
  1408. Xand
  1409. X.B = realgroup
  1410. Xmeaning
  1411. X``file articles for this group under
  1412. X.I realgroup
  1413. Xinstead''.
  1414. X.B =
  1415. Xis useful for coping with badly-run
  1416. Xlocal newsgroups,
  1417. Xoften created from mailing lists.
  1418. XYou must lock the news system with
  1419. X.I locknews
  1420. Xbefore editing the active file.
  1421. X.PP
  1422. X.I "sys file."
  1423. XC news
  1424. Xignores blank lines and
  1425. X.B #
  1426. Xcomment lines in the
  1427. X.I sys
  1428. Xfile.
  1429. XMany obsolete flags draw fatal diagnostics,
  1430. Xnotably
  1431. X.B N ,
  1432. Xthe old,
  1433. Xunbatched ihave/sendme flag.
  1434. XIf the fourth field is a relative command name,
  1435. X.B /usr/lib/news/bin
  1436. Xand
  1437. X.B /usr/lib/newsbin/relay
  1438. Xwill be searched before the standard search path.
  1439. XIf the fourth field is a relative file name,
  1440. X.B /usr/spool/news/out.going
  1441. Xwill be prepended.
  1442. XThe ihave/sendme kludges of B news
  1443. Xhave been expunged;
  1444. Xone must say what one means,
  1445. Xusing three to five entries,
  1446. Xtypically.
  1447. X.SH
  1448. XDifferences in behaviour
  1449. X.PP
  1450. X.I "Control messages."
  1451. X.I Checkgroups
  1452. Xis non-destructive in C news;
  1453. Xit merely mails its output to
  1454. X.B $NEWSMASTER
  1455. X(e.g.
  1456. X.B usenet ).
  1457. XThe superfluous
  1458. X.I Supersedes:
  1459. Xheader is not honoured.
  1460. X.PP
  1461. X.I "Newsgroup aliases."
  1462. XC news
  1463. Xdoes not implement newsgroup aliases,
  1464. Xsince we believe that header munging is to be avoided
  1465. Xexcept under extreme duress.
  1466. XIt is possible to file articles locally under different newsgroups
  1467. Xby use of the active file
  1468. X.B =
  1469. Xflag.
  1470. !
  1471. echo 'notebook/libs':
  1472. sed 's/^X//' >'notebook/libs' <<'!'
  1473. X.TL
  1474. XA Tour Through the C News Libraries and Include Files
  1475. X.AU
  1476. XGeoff Collyer
  1477. X.AI
  1478. XDepartment of Statistics
  1479. XUniversity of Toronto
  1480. X.SH
  1481. Xlibc and friends
  1482. X.LP
  1483. X.I libc
  1484. Xcontains routines that are sufficiently useful
  1485. Xand general that they could profitably be added to
  1486. Xone's C library.
  1487. XIndeed,
  1488. Xon some systems they are in the C library.
  1489. XNotable inventions include
  1490. X.I fgetmfs
  1491. Xwhich safely reads arbitrarily-long input lines;
  1492. Xit has an
  1493. X.B fgetmfs.h
  1494. Xover in the header directories.
  1495. X.I ldiv
  1496. Xis the ANSI one,
  1497. Xif you need it.
  1498. X.I memlist
  1499. Xis a
  1500. Xpackage to ease keeping track of a lot of allocated memory.
  1501. X.I stdfdopen
  1502. Xis invoked by setuid programs
  1503. Xto ensure that the standard file descriptors are indeed open,
  1504. Xopening
  1505. X.B /dev/null
  1506. Xon each closed standard descriptor.
  1507. X.\".B libc/memcpy.fast
  1508. X.\"contains some alternate
  1509. X.\"implementations of
  1510. X.\".I memcpy (3)
  1511. X.\"which may be faster than the ones in your local C library.
  1512. X.LP
  1513. X.B libstdio
  1514. Xcontains new (faster) guts for
  1515. Xthe original
  1516. X.UX
  1517. X.I stdio
  1518. Xlibrary;
  1519. Xif they compile on your V7,
  1520. X4BSD
  1521. Xor System III
  1522. Xsystem,
  1523. Xyou may want to use them instead of the default versions
  1524. Xin your C library.
  1525. XOn System V,
  1526. Xthese routines are only slightly faster than the versions in the C library.
  1527. X.LP
  1528. X.B libfake
  1529. Xcontains things that probably should be in your C library,
  1530. Xbut might not be, and a couple of fake routines for system calls
  1531. Xyou might not have.
  1532. X.SH
  1533. Xlibcnews
  1534. X.LP
  1535. X.B libcnews
  1536. Xcontains functions of general use to news software,
  1537. Xbut not the world at large.
  1538. X.I complain
  1539. Xis like
  1540. X.I warning ,
  1541. Xbut never prints the symbolic value of
  1542. X.I errno .
  1543. X.PP
  1544. XThere is a locking package,
  1545. Xcontaining
  1546. X.I lockdebug ,
  1547. X.I newslock ,
  1548. X.I newsunlock ,
  1549. X.I errunlock ,
  1550. Xand
  1551. X.I nemalloc .
  1552. X.I lockdebug
  1553. Xenables or disables lock debugging.
  1554. X.I newslock
  1555. Xattempts to lock
  1556. Xthe news transport layer
  1557. Xagainst
  1558. Xread-then-write access to the
  1559. X.B active
  1560. Xfile,
  1561. Xwriting to the
  1562. X.B history *,
  1563. X.B log ,
  1564. X.B errlog ,
  1565. Xand batch files.
  1566. XIt returns only when it has the lock;
  1567. Xin the meantime it sleeps and retries until it gets the lock.
  1568. XThere is no timeout;
  1569. Xthis is a feature.
  1570. X.I newsunlock
  1571. Xremoves the above-mentioned lock
  1572. Xif this process locked the news system.
  1573. X.I errunlock
  1574. Xis like
  1575. X.I error
  1576. Xexcept that it
  1577. Xunlocks the news system
  1578. X(via
  1579. X.I newsunlock)
  1580. Xbefore exiting;
  1581. Xit is should always be called instead of
  1582. X.I exit (3)
  1583. Xor
  1584. X.I exit (2)
  1585. Xif there is any chance that this process has locked the news system.
  1586. X.I nemalloc
  1587. Xis like
  1588. X.I emalloc
  1589. Xbut it calls
  1590. X.I errunlock
  1591. Xif it can't allocate memory.
  1592. X.PP
  1593. X.I ltoza
  1594. Xconverts a
  1595. X.B "long int"
  1596. Xto a string of a given width,
  1597. Xcontaining the decimal representation,
  1598. Xzero-padding as needed on the left.
  1599. X.I ltozan
  1600. Xis like
  1601. X.I ltoza
  1602. Xbut omits the terminating NUL,
  1603. Xso it can be used to overwrite a string without truncating it.
  1604. X.I ngmatch
  1605. Xreturns a truth-value
  1606. Xresulting from comparing
  1607. Xa list of newsgroup patterns
  1608. Xand
  1609. Xa list of newsgroups.
  1610. XOne may substitute ``distribution'' for ``newsgroup''.
  1611. X.PP
  1612. XThere is a package of pathname manipulators.
  1613. X.I artfile
  1614. Xreturns a name for its filename argument,
  1615. Xassumed to be relative to
  1616. X.I $NEWSARTS ;
  1617. X.I fullartfile
  1618. Xpromises to return a fully-qualified path name.
  1619. X.I ctlfile
  1620. Xreturns a name for its filename argument,
  1621. Xassumed to be relative to
  1622. X.I $NEWSCTL .
  1623. X.I binfile
  1624. Xreturns a name for its filename argument,
  1625. Xassumed to be relative to
  1626. X.I $NEWSBIN .
  1627. X.I cd
  1628. Xchanges to its argument directory,
  1629. Xcheck for errors,
  1630. Xand notes the directory name,
  1631. Xby making a private copy,
  1632. Xfor later optimisations.
  1633. X.I newsumask
  1634. Xreturns the value of
  1635. X.I $NEWSUMASK .
  1636. X.I newspath
  1637. Xreturns the value of
  1638. X.I $NEWSPATH .
  1639. X.I newsmaster
  1640. Xreturns the value of
  1641. X.I $NEWSMASTER .
  1642. XAll these functions
  1643. Xsupply default values for the
  1644. X.I NEWS *
  1645. Xvariables if none are found in the environment.
  1646. XIf values are found in the environment,
  1647. Xthey are used,
  1648. Xand a function named
  1649. X.I unprivileged
  1650. Xis called.
  1651. X.PP
  1652. X.I readline
  1653. Xis like
  1654. X.I fgets ,
  1655. Xbut executes
  1656. X.I newslock
  1657. Xupon encountering EOF
  1658. Xand retries the read.
  1659. XThis is used when reading growing files
  1660. Xsuch as
  1661. X.B history
  1662. Xor
  1663. Xbatch files.
  1664. X.I strlower
  1665. Xdown-cases an entire string,
  1666. Xin place.
  1667. X.I strsave
  1668. Xis like
  1669. X.I strdup
  1670. Xbut it calls
  1671. X.I nemalloc
  1672. Xrather than
  1673. X.I emalloc .
  1674. X.I str3save
  1675. Xtakes three strings,
  1676. Xallocates space for their concatenation
  1677. Xvia
  1678. X.I nemalloc ,
  1679. Xincluding terminating NUL,
  1680. Xand concatenates them onto it.
  1681. XA
  1682. X.I NULL
  1683. Xargument will be replaced by an empty string.
  1684. X.I timestamp
  1685. Xwrites a timestamp on a given stream,
  1686. Xand returns the current time via an argument
  1687. Xfor later use.
  1688. X.SH
  1689. XUnix-variant-specific libraries
  1690. X.LP
  1691. XThere are several libraries that provide functions
  1692. Xfor talking to specific Unix variants.
  1693. XThese are basically functions that change from one variant to another.
  1694. X.B libfake
  1695. X(see above) contains things which simply might not be there in a
  1696. Xparticular system.
  1697. X.LP
  1698. XThese libraries all provide the same virtual interface to
  1699. Xoperating-system-dependent services:
  1700. X.I fclsexec ,
  1701. X.I fopenexcl ,
  1702. X.I getcwd (3),
  1703. Xand
  1704. X.I gethostname (3).
  1705. XImplementations for vanilla implementations of these
  1706. X.UX
  1707. Xvariants are provided:
  1708. XSeventh Edition,
  1709. Xincluding 4.1BSD
  1710. X(\c
  1711. X.B libv7 );
  1712. XEighth
  1713. Xand Ninth Editions
  1714. X(\c
  1715. X.B libv8 );
  1716. X4.2BSD and later
  1717. X(\c
  1718. X.B libbsd42 );
  1719. XSystem III and System V
  1720. X(\c
  1721. X.B libusg ).
  1722. X.I fclsexec
  1723. Xsets the close-on-exec flag
  1724. Xfor a given
  1725. X.I stdio
  1726. Xstream.
  1727. X.I fopenexcl
  1728. Xperforms an ``exclusive create'' open:
  1729. Xthe open fails if the file already exists.
  1730. X.SH
  1731. XAddress-space-size-specific libraries
  1732. X.LP
  1733. XThese libraries provide alternate versions of the
  1734. X.B active
  1735. Xand
  1736. X.B sys
  1737. Xfile code:
  1738. X.B libsmall
  1739. Xshould work on any machine,
  1740. Xbut is suboptimally fast;
  1741. X.B libbig
  1742. Xhas worked even on PDP-11s,
  1743. Xand is quite fast,
  1744. Xbut consumes memory without apology.
  1745. X.SH
  1746. XInclude files
  1747. X.LP
  1748. X.B libh
  1749. Xcontains include files
  1750. Xunique to C news.
  1751. X.B news.h
  1752. Xdefines a few limits,
  1753. Xsome file names,
  1754. Xsome types
  1755. X(\c
  1756. X.B boolean
  1757. Xand
  1758. X.B statust ),
  1759. Xsome characters,
  1760. Xsome status bits,
  1761. Xsome macros for speed,
  1762. Xand
  1763. Xdeclares functions in
  1764. X.B libcnews
  1765. Xor miscellaneous functions in
  1766. X.I relaynews
  1767. X(oops!).
  1768. X.B config.h
  1769. Xdeclares the pathname functions in
  1770. X.B libcnews .
  1771. X.B fgetmfs.h
  1772. Xdeclares symbolic values and macros for using
  1773. X.B fgetmfs .
  1774. X.B libc.h
  1775. Xis a start at a V9-like declaration of all of the C library.
  1776. X.B memlist.h
  1777. Xdefines the interface to
  1778. X.B memlist .
  1779. X.LP
  1780. X.B hfake
  1781. Xcontains a few include files that your system ought to have but might not.
  1782. X.B stdlib.h
  1783. Xis a degenerate ANSI
  1784. X.B stdlib.h .
  1785. X.B string.h
  1786. Xdeclares the string functions.
  1787. X.B timeb.h
  1788. Xdeclares the structure used by
  1789. X.I ftime .
  1790. !
  1791. echo done
  1792.  
  1793.  
  1794.