Subject: WARNING: 1.5.1 faces.sendmail is broken

From: John Mackin <[email-masked]>
Date: Sat, 20 Apr 91 01:56:47 +1000

When I looked at the patch, I didn't think it could work; I've just tried
it, and it doesn't.  Rich, I guess you didn't test it -- or had a different
idea of how it was meant to work.

Certainly, the original motivation for ``improving'' my script was so that
the extraneous stuff -- namely, the leading "X-Face:" on the first line
and the trailing newline -- could be removed from ~/.face, so that that
file could be just the literal output of compface.  I am by no means
convinced that such an ``improvement'' is a desirable thing; but that
is what people were trying to achieve.  And on some systems, with some
versions of echo, the 1.5.0 version did achieve that.

**** DO NOT USE THE 1.5.1 VERSION; IT IS A DISASTER ****

If you use it, the newline that is meant to separate the headers of
your mail from the body will get dropped, and the first part of the
body will be taken as (doubtless illegal) headers, and things will
be very bad.

If you want to use the 1.5.1 version, you can, _only if_ you add an
extra newline to the end of ~/.face.  Then it will be OK.  But I
thought the whole idea was to avoid doing that.

I would have included a version that did work and was portable, and left
the design questions till later; but the machine I have all that stuff on
is off the Internet, and I thought I should get this information to the
list as quickly as possible.

John.

---

From: richb@stard (Rich Burridge)
Date: Sat, 20 Apr 1991 03:04:30 +1000

} When I looked at the patch, I didn't think it could work; I've just tried
} it, and it doesn't.  Rich, I guess you didn't test it -- or had a different
} idea of how it was meant to work.

Well, I'm not sure why it's not working for you John. Or perhaps I should
say, I don't know why it's working for me? This is getting rather confusing.
Can we have some feedback from the other guinea pigs (sorry, I mean beta
users) on this list?

This message is bought to you via the new faces.sendmail script. I'm
using mush (but I've just tried /usr/ucb/mail and didn't get a problem
with that either). I'm running SunOS v4.1.1(revB) on a 4/65.

Here's my ~/.face file (no trailing blank line):

------CUT HERE------
Y}N{(a7(Nu]wrKSz:kGC&t@v8%uR^Y{y#;Fi*Z]A,qHkF6e(GVt"p^=(_Wyd$
	TS*Z_A\F}5?'8l(le<7AU78a,@J-^5-O>QO"e%Lof2(PtE5w-FnjKk>7sk9T}
	oWMM:)c+EI5G~>+2[oW}?tx)WOH%`A|ivL!71qx'avX*;Nd{BOO2);d](wKt8
	TSbZg'OeegxvS7,YNY,^
------CUT HERE------

The message starts on the first line when the mailer chucks me into vi.
I've included the script I'm using below (which should be what you've all
got after applying patch #1).

I realise I did end up putting several parts of patch #1 together in a hurry,
but yes, I did test this.

So what are other people seing? Is v1.5.1 a disaster? I realise the handling
of X-Face: lines has been 'ed up, by James latest patch, but I've confidence
that James, John and Mark (all we need now is somebody called Matthew that
understands James code) will sort that out next week.

------CUT HERE------faces.sendmail------CUT HERE------
#!/bin/sh
#
#  @(#)faces.sendmail 1.3 91/04/19
#
#  Small script to automatically add X-Face: compressed image lines to a
#  mail message header. This shell script should be run by adding a line
#  similar to:
#
#  set sendmail=/usr/local/bin/faces.sendmail
#
#  to your ~/.mailrc file. See the faces manual pages for more details, and
#  how to setup yout ~/.face file.
# 
#  Original version: Copyright 1990 John J. Mackin. All rights reserved.
#
#  This derived version: Copyright 1991 - Philippe-Andre Prindeville
#                                         Glenn Statchell
#
#  Permission is given to distribute these sources, as long as the
#  copyright messages are not removed, and no monies are exchanged.
#
#  No responsibility is taken for any errors or inaccuracies inherent
#  either to the comments or the code of this program, but if
#  reported to me then an attempt will be made to fix them.
#
TMP=/tmp/face$$ export TMP
sed '1s/^/X-Face:/' $HOME/.face >> $TMP
sed -n  -e '/^$/!{p;d;}' \
	-e "r "$TMP \
	-e n \
	-e ': copy' -e p -e n -e 'b copy' | /usr/lib/sendmail "$@"
rm -f $TMP

---

From: Dave Cohrs <[email-masked]>
Date: Fri, 19 Apr 91 12:58:57 CDT

Well, v1.5.1 does seem to have problems.  Rich, your X-Face line came out
really odd when my machine uncompressed it.  The left half was normal, the
right have was reverse video, or something like that.

I had all the #define's the same as the previous times I had compiled, so I'm
at a loss.  Perhaps it's a result of this problem John mentioned.

dave

---

From: John Mackin <[email-masked]>
Date: Sun, 21 Apr 91 22:58:20 +1000

In the first referenced message, I wrote:

    From: John Mackin <[email-masked]>
    Date: Sat, 20 Apr 91 01:56:47 +1000
    Subject: WARNING: 1.5.1 faces.sendmail is broken

    When I looked at the patch, I didn't think it could work; I've just
    tried it, and it doesn't.  Rich, I guess you didn't test it -- or
    had a different idea of how it was meant to work.
    [...]
    **** DO NOT USE THE 1.5.1 VERSION; IT IS A DISASTER ****

This stirred up a bit of comment, most of which seemed to me to be
somewhat confused.  I decided to wait until I had a chance to develop
a new version of the script before following up to it all; I've now
done that.  In mail that wasn't sent to the list, Philippe suggested
that I was ``overreacting''.  I think he thought I was claiming _his_
version of faces.sendmail -- viz., 1.5._0_ -- was a disaster.  I was
not claiming that; please reread the referenced message.  All I said
about the 1.5.0 faces.sendmail was that it would work on some systems,
with some versions of echo.  That was perfectly true, and cannot be
considered an ``overreaction'' by anyone.

Then Dave Cohrs, in the second referenced message, wrote:

    Well, v1.5.1 does seem to have problems.  [...] Perhaps it's a
    result of this problem John mentioned.

The problems Dave was talking about, though, were in fact nothing to
do with faces.sendmail at all.  In case anyone is still in the dark
about them, they have to do with the fact that the 1.5.1 version of
compface/gen.c seems to be incorrect.  Victor's version may be better;
I haven't personally looked into that, but I am following it up with
James, and will get back to the list when I have definite information.

Rich wrote, in the third referenced message (text re-ordered):

    So what are other people seing? Is v1.5.1 a disaster?

I never meant to imply that 1.5.1 in general was a disaster.  I meant
to imply that 1.5.1 _faces.sendmail_ was a disaster -- and it is.

    Well, I'm not sure why it's not working for you John. Or perhaps I
    should say, I don't know why it's working for me? This is getting
    rather confusing.  Can we have some feedback from the other guinea
    pigs (sorry, I mean beta users) on this list?

    [Rich gives details of just how 1.5.1 faces.sendmail works OK for him]

    I realise I did end up putting several parts of patch #1 together
    in a hurry, but yes, I did test this.

Well now.  Faced with a situation like that, I investigated further.
The facts are indeed exactly as I stated them in the first referenced
message.  1.5.1 faces.sendmail _does_ drop the newline between the headers
and the body.  There is no question at all about that.  If anyone on the
list would like to see it happening for themselves, all they need do is
do what I did: edit faces.sendmail to finish with `> PUS' instead of
`| /usr/lib/sendmail "$@"', send some mail and cat PUS.  There will be
_no_ blank line between the last line of the X-Face: header and the
first line of the body.

Why doesn't the universe end, then?  It seems that some implementations
of sendmail decide that they can smell disaster on the East wind under
these conditions, and supply a blank line for free.  That's the only
reason it works.  Move to a different delivery agent, or perhaps even
a different version of sendmail, and all bets are off.  And of course,
not even this gross sendmail hack can save the day if the first line
of the message happens to begin with whitespace: in that case, sendmail
will happily believe it is a continuation of the X-Face: header, and it's
good night, Irene.

So.  Where does that leave us?  It leaves us with 1.4 faces.sendmail, which
works, is portable, and doesn't seem to do what everyone wants; with 1.5.0
faces.sendmail, which works on some systems under some conditions, and isn't
portable; and with 1.5.1 faces.sendmail, which doesn't work.

Herewith, the _last_ revision of faces.sendmail.

It does what you want.  It's portable.  It works.  (And it only uses one
sed.)

Rich, you might like to make this `official' by giving it a real version
number and arranging for it to go in the archive server and version on
iuvax.

And of course, if I have screwed up, I am sure everyone will let me know.
I don't think I have, though.

John.

#!/bin/sh
#
#  @(#)faces.sendmail 1.3-unofficial
#
#  Small script to automatically add X-Face: compressed image lines to a
#  mail message header. This shell script should be run by adding a line
#  similar to:
#
#  set sendmail=/usr/local/bin/faces.sendmail
#
#  to your ~/.mailrc file. See the faces manual pages for more details, and
#  how to setup yout ~/.face file.
# 
#  Copyright 1990, 1991 John J. Mackin. All rights reserved.
#
#  Permission is given to distribute these sources, as long as the
#  copyright messages are not removed, and no monies are exchanged.
#
#  No responsibility is taken for any errors or inaccuracies inherent
#  either to the comments or the code of this program, but if
#  reported to me then an attempt will be made to fix them.
#
cat $HOME/.face - | sed -n \
	-e '1s/^/X-Face:/' \
	-e 1h \
	-e 1d \
	-e '/^[ 	]/{H;d;}' \
	-e ': copy0' \
	-e '/^$/!{p;n;}' \
	-e '/^$/!b copy0' \
	-e g \
	-e p \
	-e 'a\

' \
	-e n \
	-e ': copy' \
	-e p \
	-e n \
	-e 'b copy' | /usr/lib/sendmail "$@"