home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
-
-
-
-
- ¢1mConfiguration¢22m ¢1mMechanisms¢22m ¢1min¢22m ¢1mC¢22m ¢1mNews¢22m
-
- ¢4mHenry¢24m ¢4mSpencer¢24m
- Dept. of Zoology
- University of Toronto
-
-
- ¢1mIntro¢22m
- There is an overall problem with news stuff in that some
- pathnames and such are site¡specific. In C News this hits
- both shell files and C programs, the former a particular
- inconvenience because they are not compiled and hence can't
- easily pick it up from a library at compile time. It's easy
- to edit shell files, but there are too many of them for this
- to be very convenient.
- Several mechanisms are needed to solve the entire problem..
-
- ¢1mConfiguration¢22m ¢1mParameters¢22m
- Although there are many things that theoretically could be
- site¡specific, there are only a few that really crop up con¡
- stantly, are highly likely to change, and have to be known
- to running code. Here's a tentative list, with internal
- names and common defaults:
- lll. NEWSARTS pathname of the article
- database /usr/spool/news NEWSCTL pathname of the con¡
- trol¡file directory /usr/lib/news NEWSBIN pathname of
- the program directory /usr/lib/newsbin NEWSPATH shell
- PATH setting for news /bin:/usr/bin NEWSUMASK default umask
- for file creation 002 NEWSMASTER where to send mail
- about trouble usenet NEWSCONFIG see "Subst"
- section /usr/lib/news/bin/config
-
- ¢1mEnvironment¢22m ¢1mVariables¢22m
- All C News programs that care about configuration parameters
- are expected to look at environment variables with the same
- names as the parameters, and to use the environment values
- to override internal defaults. This is primarily aimed at
- testing and special purposes rather than production use, as
- there is a fundamental problem: the environment is insecure.
- The environment variables are nevertheless very useful.
- There is a need for a canned interface to the environment
- variables, to simplify their use. There is also a require¡
- ment for centrally¡set defaults for normal production use.
- These requirements are addressed differently for C and shell
- programs.
-
- ¢1mC¢22m ¢1mInterface¢22m
- ¢4mLibcnews¢24m provides a set of inquiry functions:
- char *fullartfile(char *name);
- Returns a full pathname for the NEWSARTS¡relative
- file ¢4mname¢24m; if ¢4mname¢24m is NULL, returns the value of
-
-
-
- 5 Sept 1989
-
-
-
-
-
- ¡2¡
-
-
- NEWSARTS.
- char *ctlfile(char *name);
- Returns a full pathname for the NEWSCTL¡relative
- file ¢4mname¢24m; if ¢4mname¢24m is NULL, returns the value of
- NEWSCTL.
- char *binfile(char *name);
- Returns a full pathname for the NEWSBIN¡relative
- file ¢4mname¢24m; if ¢4mname¢24m is NULL, returns the value of
- NEWSBIN.
- char *newspath(void);
- Returns the value of the NEWSPATH parameter.
- int newsumask(void);
- Returns the value of the NEWSUMASK parameter.
- char *newsmaster(void);
- Returns the value of NEWSMASTER.
- Functions which return string values return pointers to
- areas which they may later re¡use, so the values should be
- copied if they are to persist past later calls. There is
- also a function ¢4martfile¢24m which returns a relative pathname,
- as a special¡purpose optimization, and a function ¢4mcd¢24m which
- does a ¢4mchdir¢24m and notes the location for future use by ¢4mart¡¢24m
- ¢4mfile¢24m.
- The first inquiry function to be invoked automatically ini¡
- tializes their internal housekeeping. Against the possibil¡
- ity of malicious setting of environment variables, if any
- environment variables are in fact present to override
- default values, and at least one value in fact differs from
- the default, this initialization includes a call to a func¡
- tion the user must supply:
- void unprivileged(char *reason);
- Drop any special powers that should not be avail¡
- able to a normal user program, e.g. those obtained
- by set¡uid bit. ¢4mReason¢24m is the name of the first
- environment variable that caused trouble.
- Programs that do not use the set¡uid bit can normally have a
- null implementation of ¢4munprivileged¢24m, but to encourage
- thought about the matter this is ¢4mnot¢24m provided as a default.
- Suitable external declarations for all these functions can
- be found in the include file ¢4mconfig.h¢24m in the C News include
- directory.
-
- ¢1mShell¢22m ¢1minterface¢22m
- All shell files that want to know configuration parameters
- should execute NEWSCTL/bin/config using the `.' command; it
- sets shell variables with the same names as the parameters.
- Note that it does not export these variables, so subordinate
- shell files need to pick up ¢4mconfig¢24m themselves. This is to
- preserve the property that subordinate programs see environ¡
- ment variables set only if the user set them.
-
- ¢1mSubst¢22m
- The alert mind will have noticed a circularity in the previ¡
- ous section: it's not possible to find NEWSCTL/bin/config
- until one knows where NEWSCTL is. There are also occasional
-
-
-
- 5 Sept 1989
-
-
-
-
-
- ¡3¡
-
-
- annoyances in that documentation and such wants to know the
- local defaults, and can't get them from either the C or
- shell interface. Hence the use of ¢4msubst¢24m.
- ¢4mSubst¢24m does substitutions into source files (including shell
- files) in such a way that it is not necessary to maintain
- two versions of the file. In the top¡level directory of the
- C News sources are four files: ¢4msubst¢24m itself, the ¢4msubstitu¡¢24m
- ¢4mtions¢24m file defining the values of the configuration parame¡
- ters, and ¢4msubst.hs¢24m and ¢4msubst.gc¢24m, which are lists of files
- (relative to the top¡level source directory) that need sub¡
- stitutions done. (The use of two `list' files reflects C
- News's dual authorship.) See the ¢4msubst¢24m(1) manual page for
- the gory details of the syntax. The only C program affected
- is the configuration¡inquiry part of the library, but all
- shell files that need any of the configuration parameters
- need to be in one of the lists.
-
- ¢1mProgram¢22m ¢1mstartup¢22m
- As a result of all this, a C program which needs to know a
- configuration parameter simply calls the appropriate inquiry
- function, and is prepared for a return call to ¢4munprivileged¢24m.
- A shell program has to do a bit more work; it should start
- with something on the order of:
- #! /bin/sh
- # foobar - does foo, bar, and bletch
-
- # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
- . ${NEWSCONFIG-/usr/lib/news/bin/config}
-
- PATH=$NEWSCTL/bin:$NEWSBIN/xxx:$NEWSBIN:$NEWSPATH ; export PATH
- umask $NEWSUMASK
- (A prototype for this is in conf/proto.sh.) (See an accom¡
- panying document for the logic of the PATH setting.) The
- NEWSCONFIG configuration parameter specifies the location of
- the configurer shell program, which is then executed to set
- up the rest of the parameters. The reason for doing it this
- way is to ensure that new parameters can be added without
- having to change every shell file.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 5 Sept 1989
-
-
-