Hylafax Developers Mailing List Archives

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

[hylafax-devel] Re: missing parts of security-patch.sh



--------
Your message dated: Sun, 18 Jun 2000 17:17:06 +1000
>At 05:46 PM 6/17/00 -0700, Andy Sparrow wrote:
>>Namely:
>>
>>i)      Testing shell variables that may not be set is dangerous,
>>         e.g.:
>>
>>         if [ -f $SYSINIT ]
>>         ...
>>
>>         is dodgy if 'SYSVINIT' is never set.
>
>SYSVINIT should *always* be set.

Then using:

	if [ -f ${SYSVINIT:?} ]
	
guarantees it, if it's an error for it not to be set at that point.

	if [ -f "$SYSVINIT" ]
	
may make the script fail more gracefully (at the risk/cost of hiding 
the error until later).

As a matter of style, I invariably use double quotes around the
variable in the test. I often use the word substitution/checking form
too, but then I tend to structure my scripts so that the first usage
of them is extremely easy to locate (e.g. non-conditional).

This buys you robustness, in that you can screw around with the top of
the script/configuration/variable setup later, and it doesn't break 
silently in the third included script of a 16,000 line installation 
suite someone else wrote 4 years ago, running in a sub-shell in the 
background where debugging it is a bitch...

>  Though looking at configure it seems this 
>has somehow being mucked up....and the Makefile in the etc directory seems 
>broken now too.

I noticed it when the configure script started giving me 'start:
Command not found' messages. It wasn't hard to spot :-)

Hard part (for me, anyway), was working out how it ran that line of
code, given that I "knew" how /bin/test works.... :-/

Then I peered at the code for an hour, trying to spot the bug, before
re-reading the man page (carefully, this time) and realising it was 
/implemented/ that way on purpose...

Ahhh, you stop learning, you start dying, ain't that the truth...

>>         Of course, on BSD-ish systems, 'SYSINIT' doesn't get set...

Drat, wish I could type SYSVINIT consistantly...

>
>On BSD type systems the sysvinit script should be copied to the sbin 
>directory instead.
>
>So that you can start and stop hylafax easily at the command line ie 
>'hylafax start' and 'hylafax stop'

Yeh, the port was taking care of that by copying a 'hylafax.sh.sample'
file to ${PREFIX}/etc/rc.d (PREFIX being set to /usr/local). 

This is a FreeBSD-ism. The port tells you that you have to take 
manual, post-install action to enable automatic startup on re-boot.
This is deliberate.

Semantics for start-up scripts vary on BSD-ish systems though.. It's
not required to provide an argument (default is to start), although
it's not prohibited to supply one either. 

I don't wanna revisit that particular TFH either (I actually /like/ 
the post-SysVr2 init.d directory, although I /still/ think it's kinda 
overkill and ugly for a small machine).

>>ii)     Some systems break the Adobe Font Metrics out of the
>>         Ghostscript package altogether and install it as a separate
>>         dependancy (presumably so that multiple ghostscript installs
>>         can be located in versioned directory names, in a similar
>>         way to how I can have multiple versions of Tcl/Tk installed
>>         on the same system).
>
>Are you saying the metric files are separate from the fonts themselves?

Yes indeedy. See a couple of annotations down.

>>         On such systems (FreeBSD at least, maybe also the other BSD
>>         systems that use the 'ports' system), PATH_AFM would get set
>>         just fine by the "last ditch" code if it weren't for the call
>>         to the 'getGSFonts' function - which obligingly(?) finds the
>>         Ghostscript 'afm' directory instead, thus no further
>>         processing is performed.
>
>Er i dont understand what you mean - the idea is that the document is 
>generated using the *same* fonts that ghostscript is going to use to 
>actually rasterize the document.

Well, on re-reading, I wasn't very clear...

See next annonation for (hopefully) a better description.

>>         However, this particular 'afm' directory doesn't have the
>>         Courier font definition required for the package to run,
>>         thus nothing works when the build is complete.
>
>
>Does it have other .afm files with encoded names?  If so textfmt et al will 
>use the Fontmap file to find the correct font.

Ooops, my bad. I reported this incorrectly (hey, it /was/ last week).

Reading through 'faxsetup.sh' again, I now recall that it blew up
saying it couldn't find Courier-Bold in the directory 'configure' 
selected for it (/usr/local/share/ghostscript/fonts).


It selects the ghostscript 'fonts' directory because this code
(starting @ #3594 of 'configure' in 4.1b2):


   if [ -z "$FONTMAP" ]; then
           FONTMAP=`getGSFonts`
   fi
   Note "Setting the Fontmap path to $FONTMAP"

   #
   # Location of Adobe Font Metric files.
   #
   if [ -z "$PATH_AFM" ]; then
       # if the fontmap path is available use that
       # else just guess
       if [ -n "$FONTMAP" ]; then
           PATH_AFM=$FONTMAP
       else        
           DIR_AFMS="
               /usr/lib/afm
               /usr/local/lib/afm
               /usr/local/share/ghostscript/fonts
               /usr/local/lib/ghostscript/fonts
               /usr/share/ghostscript/fonts
               /usr/gnu/lib/ghostscript/fonts
               /opt/gnu/lib/ghostscript/fonts
               /usr/lib/ghostscript/fonts
               /usr/lib/gnu/ghostscript/fonts
           "
           case $TARGET in
           *-irix*)        DIR_AFMS="/usr/lib/DPS/AFM $DIR_AFMS";;
           *-bsdi*)        DIR_AFMS="/usr/contrib/lib/flexfax/afm $DIR_AFMS";;
           *-sunos*)       DIR_AFMS="/usr/openwin/lib/fonts/afm $DIR_AFMS";;
           esac
           PATH_AFM=
           for i in $DIR_AFMS; do
               test -d $i && { PATH_AFM=$i; break; }
           done  
       fi
   fi
   if [ -z "$PATH_AFM" ]; then
       # put it where ghostscript normally puts things
       PATH_AFM=/usr/local/lib/ghostscript/fonts
       Note "WARNING, could not locate a directory with font metric information,"
       Note "guessing that font metric information goes in $PATH_AFM."
   else 
       Note "Looks like font metric information goes in $PATH_AFM."
   fi

(on FreeBSD at least), checks for FONTMAP, which is unset. Thus it calls
'getGSFonts()', and sets FONTMAP to the location of
'/usr/local/share/ghostscript/fonts' - which on this system, /doesn't/
contain the AFM files, as they're installed separately, as a
dependancy of /all/ of the Ghostscript versions.

Thus, in the next test, PATH_AFM is checked, found empty, and, as
FONTMAP is non-empty, PATH_AFM is set to FONTMAP. If it failed that
test, it'd run what I coined the "last-ditch" code, which would search
a list of directories for the AFM files, and it'd be set correctly,
because the correct location (for FreeBSD systems) is /before/
/usr/local/share/ghostscript/fonts in that list.

My hack was simply to avoid running 'getGSFonts()' if the system was
FreeBSD,and set the FONTMAP to the "correct" location. (And, 
incidentally, I fat-fingered the patch - the call to 'Note' should 
appear either outside the 'case' statement or in both clauses of it, 
ideally).


To address your other question, here's the contents of the 'afm' and
'fonts' directories as installed:

  pc# pwd
  /usr/local/lib/afm
  pc# ls
  AvantGarde-Book                 Helvetica-Oblique
  AvantGarde-BookOblique          NewCenturySchlbk-Bold
  AvantGarde-Demi                 NewCenturySchlbk-BoldItalic
  AvantGarde-DemiOblique          NewCenturySchlbk-Italic
  Bookman-Demi                    NewCenturySchlbk-Roman
  Bookman-DemiItalic              Palatino-Bold
  Bookman-Light                   Palatino-BoldItalic
  Bookman-LightItalic             Palatino-Italic
  Courier                         Palatino-Oblique
  Courier-Bold                    Palatino-Roman
  Courier-BoldOblique             Symbol
  Courier-Oblique                 Times-Bold
  Helvetica                       Times-BoldItalic
  Helvetica-Bold                  Times-Italic
  Helvetica-BoldOblique           Times-Oblique
  Helvetica-Narrow                Times-Roman
  Helvetica-Narrow-Bold           ZapfChancery-MediumItalic
  Helvetica-Narrow-BoldOblique    ZapfDingbats
  Helvetica-Narrow-Oblique

  pc# file *
  AvantGarde-Book:              ASCII font metrics
  AvantGarde-BookOblique:       ASCII font metrics
  AvantGarde-Demi:              ASCII font metrics
  AvantGarde-DemiOblique:       ASCII font metrics
  Bookman-Demi:                 ASCII font metrics
  Bookman-DemiItalic:           ASCII font metrics
  Bookman-Light:                ASCII font metrics
  Bookman-LightItalic:          ASCII font metrics
  Courier:                      ASCII font metrics
  Courier-Bold:                 ASCII font metrics
  Courier-BoldOblique:          ASCII font metrics
  Courier-Oblique:              ASCII font metrics
  Helvetica:                    ASCII font metrics
  Helvetica-Bold:               ASCII font metrics
  Helvetica-BoldOblique:        ASCII font metrics
  Helvetica-Narrow:             ASCII font metrics
  Helvetica-Narrow-Bold:        ASCII font metrics
  Helvetica-Narrow-BoldOblique: ASCII font metrics
  Helvetica-Narrow-Oblique:     ASCII font metrics
  Helvetica-Oblique:            ASCII font metrics
  NewCenturySchlbk-Bold:        ASCII font metrics
  NewCenturySchlbk-BoldItalic:  ASCII font metrics
  NewCenturySchlbk-Italic:      ASCII font metrics
  NewCenturySchlbk-Roman:       ASCII font metrics
  Palatino-Bold:                ASCII font metrics
  Palatino-BoldItalic:          ASCII font metrics
  Palatino-Italic:              ASCII font metrics
  Palatino-Oblique:             ASCII font metrics
  Palatino-Roman:               ASCII font metrics
  Symbol:                       ASCII font metrics
  Times-Bold:                   ASCII font metrics
  Times-BoldItalic:             ASCII font metrics
  Times-Italic:                 ASCII font metrics
  Times-Oblique:                ASCII font metrics
  Times-Roman:                  ASCII font metrics
  ZapfChancery-MediumItalic:    ASCII font metrics
  ZapfDingbats:                 ASCII font metrics

  pc# cd /usr/local/share/ghostscripts/fonts; ls
  a010013l.afm    c059013l.pfm    hritro.gsf      n019024l.pfb    n022023l.pfm
  a010013l.pfb    c059016l.afm    hrpld.pfa       n019024l.pfm    n022024l.afm
  a010013l.pfm    c059016l.pfb    hrpldb.gsf      n019043l.afm    n022024l.pfb
  a010015l.afm    c059016l.pfm    hrpldbi.gsf     n019043l.pfb    n022024l.pfm
  a010015l.pfb    c059033l.afm    hrpldi.pfa      n019043l.pfm    p052003l.afm
  a010015l.pfm    c059033l.pfb    hrplr.gsf       n019044l.afm    p052003l.pfb
  a010033l.afm    c059033l.pfm    hrplrb.gsf      n019044l.pfb    p052003l.pfm
  a010033l.pfb    c059036l.afm    hrplrbo.gsf     n019044l.pfm    p052004l.afm
  a010033l.pfm    c059036l.pfb    hrplro.gsf      n019063l.afm    p052004l.pfb
  a010035l.afm    c059036l.pfm    hrpls.gsf       n019063l.pfb    p052004l.pfm
  a010035l.pfb    d050000l.afm    hrplsb.gsf      n019063l.pfm    p052023l.afm
  a010035l.pfm    d050000l.pfb    hrplsbo.gsf     n019064l.afm    p052023l.pfb
  b018012l.afm    d050000l.pfm    hrplso.gsf      n019064l.pfb    p052023l.pfm
  b018012l.pfb    fcyr.afm        hrplt.pfa       n019064l.pfm    p052024l.afm
  b018012l.pfm    fcyr.gsf        hrpltb.gsf      n021003l.afm    p052024l.pfb
  b018015l.afm    fcyri.afm       hrpltbi.gsf     n021003l.pfb    p052024l.pfm
  b018015l.pfb    fcyri.gsf       hrplti.pfa      n021003l.pfm    putb.pfa
  b018015l.pfm    fhirw.gsf       hrscc.pfa       n021004l.afm    putbi.pfa
  b018032l.afm    fhirw.pfm       hrsccb.gsf      n021004l.pfb    putr.pfa
  b018032l.pfb    fkarw.gsf       hrscco.gsf      n021004l.pfm    putri.pfa
  b018032l.pfm    fkarw.pfm       hrscs.pfa       n021023l.afm    s050000l.afm
  b018035l.afm    fonts.dir       hrscsb.gsf      n021023l.pfb    s050000l.pfb
  b018035l.pfb    fonts.scale     hrscso.gsf      n021023l.pfm    s050000l.pfm
  b018035l.pfm    hrger.pfa       hrsyr.gsf       n021024l.afm    u003043t.afm
  bchb.afm        hrgerb.gsf      n019003l.afm    n021024l.pfb    u003043t.gsf
  bchb.pfa        hrgerd.gsf      n019003l.pfb    n021024l.pfm    u003043t.pfm
  bchbi.afm       hrgero.gsf      n019003l.pfm    n022003l.afm    u004006t.afm
  bchbi.pfa       hrgkc.gsf       n019004l.afm    n022003l.pfb    u004006t.gsf
  bchr.afm        hrgks.gsf       n019004l.pfb    n022003l.pfm    u004006t.pfm
  bchr.pfa        hrgrr.pfa       n019004l.pfm    n022004l.afm    z003034l.afm
  bchri.afm       hrgrrb.gsf      n019023l.afm    n022004l.pfb    z003034l.pfb
  bchri.pfa       hrgrro.gsf      n019023l.pfb    n022004l.pfm    z003034l.pfm
  c059013l.afm    hritr.pfa       n019023l.pfm    n022023l.afm
  c059013l.pfb    hritrb.gsf      n019024l.afm    n022023l.pfb

where the types are (e.g.):

  pc# file a*
  a010013l.afm: ASCII font metrics
  a010013l.pfb: PostScript Type 1 font program data
  a010013l.pfm: raw G3 data, byte-padded

etc.

Incidentally, 'fonts.(dir|scale)' don't contain any definitions for
'Courier'.

>>iii)    You might want to add these lines to 'configure' around
>>         about the definition settings for the socket API (roughly
>>         line 2311 in my copy):
>>
>>         *-freebsd4*)    CONFIG_SOCKARGLENTYPE=u_int32_t;;
>>         *-freebsd5*)    CONFIG_SOCKARGLENTYPE=u_int32_t;;
>
>...are you sure the above isn't the 'size_t' type, that seems to be what 
>alot of the other platforms are using.

Ummm, Yes, quite sure, see the definitions below...

FreeBSD 4.0-STABLE (and 5.0-CURRENT) is the chosen development platform 
of the KAME Project (integrated IPv6 stack and tools & IPSec for IPv4/v6, 
see http://www.kame.net).

The KAME code is an integrated part of FreeBSD since 4.0-RELEASE.
OpenBSD 2.7 and up have it too, add NetBSD if you're talking development 
trees. 

Perhaps that's the reason for the changes.


FreeBSD 3.4-STABLE #3: Sun Apr  2 21:22:34 PDT 2000:

   *      @(#)socket.h    8.4 (Berkeley) 2/21/94
   * $FreeBSD: src/sys/sys/socket.h,v 1.27.2.4 2000/03/08 06:32:44 fenner Exp $
   */

  #ifndef _SYS_SOCKET_H_
  #define _SYS_SOCKET_H_

  /*
   * Definitions related to sockets: types, address families, options.
   */

  /*
   * Data types.
   */
  typedef u_char          sa_family_t;
  typedef int             socklen_t;



FreeBSD 4.0-STABLE #0: Mon May 22 21:32:32 PDT 2000:

   *  @(#)socket.h    8.4 (Berkeley) 2/21/94
   * $FreeBSD: src/sys/sys/socket.h,v 1.39 2000/03/11 19:51:04 shin Exp $
   */

  #ifndef _SYS_SOCKET_H_
  #define _SYS_SOCKET_H_

  /*
   * Definitions related to sockets: types, address families, options.
   */

  /*
   * Data types.
   */
  typedef u_char      sa_family_t;
  typedef u_int32_t   socklen_t;


HTH

Regards,

AS



____________________ HylaFAX(tm) Developers Mailing List ____________________
 To unsub: mail -s unsubscribe hylafax-devel-request@hylafax.org < /dev/null



Home
Report any problems to webmaster@hylafax.org

HylaFAX is a trademark of Silicon Graphics Corporation.
Internet connectivity for hylafax.org is provided by:
VirtuALL Private Host Services