home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / wCNews_1.0.30.lha / notebook / config.man < prev    next >
Encoding:
Text File  |  1994-01-04  |  8.4 KB  |  199 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.                        ¢1mConfiguration¢22m ¢1mMechanisms¢22m ¢1min¢22m ¢1mC¢22m ¢1mNews¢22m
  11.  
  12.                                  ¢4mHenry¢24m ¢4mSpencer¢24m
  13.                                 Dept. of Zoology
  14.                              University of Toronto
  15.  
  16.  
  17.           ¢1mIntro¢22m
  18.           There  is  an  overall  problem with news stuff in that some
  19.           pathnames and such are site¡specific.  In C News  this  hits
  20.           both  shell  files  and  C programs, the former a particular
  21.           inconvenience because they are not compiled and hence  can't
  22.           easily pick it up from a library at compile time.  It's easy
  23.           to edit shell files, but there are too many of them for this
  24.           to be very convenient.
  25.           Several  mechanisms are needed to solve the entire problem..
  26.  
  27.           ¢1mConfiguration¢22m ¢1mParameters¢22m
  28.           Although there are many things that theoretically  could  be
  29.           site¡specific, there are only a few that really crop up con¡
  30.           stantly, are highly likely to change, and have to  be  known
  31.           to  running  code.   Here's  a tentative list, with internal
  32.           names and common defaults:
  33.           lll.       NEWSARTS  pathname      of      the       article
  34.           database   /usr/spool/news  NEWSCTL   pathname  of  the con¡
  35.           trol¡file  directory   /usr/lib/news  NEWSBIN   pathname  of
  36.           the  program  directory     /usr/lib/newsbin NEWSPATH  shell
  37.           PATH setting for news  /bin:/usr/bin NEWSUMASK default umask
  38.           for  file creation     002 NEWSMASTER     where to send mail
  39.           about    trouble   usenet     NEWSCONFIG     see     "Subst"
  40.           section /usr/lib/news/bin/config
  41.  
  42.           ¢1mEnvironment¢22m ¢1mVariables¢22m
  43.           All C News programs that care about configuration parameters
  44.           are expected to look at environment variables with the  same
  45.           names  as  the parameters, and to use the environment values
  46.           to override internal defaults.  This is primarily  aimed  at
  47.           testing  and special purposes rather than production use, as
  48.           there is a fundamental problem: the environment is insecure.
  49.           The environment variables are nevertheless very useful.
  50.           There  is  a  need for a canned interface to the environment
  51.           variables, to simplify their use.  There is also a  require¡
  52.           ment  for  centrally¡set defaults for normal production use.
  53.           These requirements are addressed differently for C and shell
  54.           programs.
  55.  
  56.           ¢1mC¢22m ¢1mInterface¢22m
  57.           ¢4mLibcnews¢24m provides a set of inquiry functions:
  58.                char *fullartfile(char *name);
  59.                     Returns  a full pathname for the NEWSARTS¡relative
  60.                     file ¢4mname¢24m; if ¢4mname¢24m is NULL, returns the  value  of
  61.  
  62.  
  63.  
  64.                                    5 Sept 1989
  65.  
  66.  
  67.  
  68.  
  69.  
  70.                                        ¡2¡
  71.  
  72.  
  73.                     NEWSARTS.
  74.                char *ctlfile(char *name);
  75.                     Returns  a  full pathname for the NEWSCTL¡relative
  76.                     file ¢4mname¢24m; if ¢4mname¢24m is NULL, returns the  value  of
  77.                     NEWSCTL.
  78.                char *binfile(char *name);
  79.                     Returns  a  full pathname for the NEWSBIN¡relative
  80.                     file ¢4mname¢24m; if ¢4mname¢24m is NULL, returns the  value  of
  81.                     NEWSBIN.
  82.                char *newspath(void);
  83.                     Returns the value of the NEWSPATH parameter.
  84.                int newsumask(void);
  85.                     Returns the value of the NEWSUMASK parameter.
  86.                char *newsmaster(void);
  87.                     Returns the value of NEWSMASTER.
  88.           Functions  which  return  string  values  return pointers to
  89.           areas which they may later re¡use, so the values  should  be
  90.           copied  if  they  are to persist past later calls.  There is
  91.           also a function ¢4martfile¢24m which returns a  relative  pathname,
  92.           as  a  special¡purpose optimization, and a function ¢4mcd¢24m which
  93.           does a ¢4mchdir¢24m and notes the location for future use  by  ¢4mart¡¢24m
  94.           ¢4mfile¢24m.
  95.           The  first inquiry function to be invoked automatically ini¡
  96.           tializes their internal housekeeping.  Against the possibil¡
  97.           ity  of  malicious  setting of environment variables, if any
  98.           environment  variables  are  in  fact  present  to  override
  99.           default  values, and at least one value in fact differs from
  100.           the default, this initialization includes a call to a  func¡
  101.           tion the user must supply:
  102.                void unprivileged(char *reason);
  103.                     Drop  any special powers that should not be avail¡
  104.                     able to a normal user program, e.g. those obtained
  105.                     by  set¡uid  bit.  ¢4mReason¢24m is the name of the first
  106.                     environment variable that caused trouble.
  107.           Programs that do not use the set¡uid bit can normally have a
  108.           null   implementation  of  ¢4munprivileged¢24m,  but  to  encourage
  109.           thought about the matter this is ¢4mnot¢24m provided as a  default.
  110.           Suitable  external  declarations for all these functions can
  111.           be found in the include file ¢4mconfig.h¢24m in the C News  include
  112.           directory.
  113.  
  114.           ¢1mShell¢22m ¢1minterface¢22m
  115.           All  shell  files that want to know configuration parameters
  116.           should execute NEWSCTL/bin/config using the `.' command;  it
  117.           sets  shell variables with the same names as the parameters.
  118.           Note that it does not export these variables, so subordinate
  119.           shell  files  need to pick up ¢4mconfig¢24m themselves.  This is to
  120.           preserve the property that subordinate programs see environ¡
  121.           ment variables set only if the user set them.
  122.  
  123.           ¢1mSubst¢22m
  124.           The alert mind will have noticed a circularity in the previ¡
  125.           ous section: it's not possible  to  find  NEWSCTL/bin/config
  126.           until one knows where NEWSCTL is.  There are also occasional
  127.  
  128.  
  129.  
  130.                                    5 Sept 1989
  131.  
  132.  
  133.  
  134.  
  135.  
  136.                                        ¡3¡
  137.  
  138.  
  139.           annoyances in that documentation and such wants to know  the
  140.           local  defaults,  and  can't  get  them from either the C or
  141.           shell interface.  Hence the use of ¢4msubst¢24m.
  142.           ¢4mSubst¢24m does substitutions into source files (including  shell
  143.           files)  in  such  a way that it is not necessary to maintain
  144.           two versions of the file.  In the top¡level directory of the
  145.           C  News  sources are four files: ¢4msubst¢24m itself, the ¢4msubstitu¡¢24m
  146.           ¢4mtions¢24m file defining the values of the configuration  parame¡
  147.           ters,  and  ¢4msubst.hs¢24m  and ¢4msubst.gc¢24m, which are lists of files
  148.           (relative to the top¡level source directory) that need  sub¡
  149.           stitutions  done.   (The  use of two `list' files reflects C
  150.           News's dual authorship.)  See the ¢4msubst¢24m(1) manual  page  for
  151.           the gory details of the syntax.  The only C program affected
  152.           is the configuration¡inquiry part of the  library,  but  all
  153.           shell  files  that  need any of the configuration parameters
  154.           need to be in one of the lists.
  155.  
  156.           ¢1mProgram¢22m ¢1mstartup¢22m
  157.           As a result of all this, a C program which needs to  know  a
  158.           configuration parameter simply calls the appropriate inquiry
  159.           function, and is prepared for a return call to ¢4munprivileged¢24m.
  160.           A  shell  program has to do a bit more work; it should start
  161.           with something on the order of:
  162.                #! /bin/sh
  163.                # foobar - does foo, bar, and bletch
  164.  
  165.                # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  166.                . ${NEWSCONFIG-/usr/lib/news/bin/config}
  167.  
  168.                PATH=$NEWSCTL/bin:$NEWSBIN/xxx:$NEWSBIN:$NEWSPATH ; export PATH
  169.                umask $NEWSUMASK
  170.           (A prototype for this is in conf/proto.sh.)  (See an  accom¡
  171.           panying  document  for  the logic of the PATH setting.)  The
  172.           NEWSCONFIG configuration parameter specifies the location of
  173.           the  configurer shell program, which is then executed to set
  174.           up the rest of the parameters.  The reason for doing it this
  175.           way  is  to  ensure that new parameters can be added without
  176.           having to change every shell file.
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.                                    5 Sept 1989
  197.  
  198.  
  199.