Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Nov 2000 15:58:46 -0500
From:      Garance A Drosihn <drosih@rpi.edu>
To:        Jeroen Ruigrok van der Werven <jruigrok@via-net-works.nl>, audit@FreeBSD.ORG
Subject:   Re: printjob.c mktemp() problem
Message-ID:  <p0433010cb62cc872490a@[128.113.24.47]>
In-Reply-To: <20001024222716.B2020@lucifer.bart.nl>
References:  <20001024140510.G93799@lucifer.bart.nl> <20001024222716.B2020@lucifer.bart.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
At 10:27 PM +0200 10/24/00, Jeroen Ruigrok van der Werven wrote:
>New patch at http://lucifer.bart.nl/~asmodai/printjob.c.diff
>
>However, there are some things I don't like in the current patch.
>
>I have these feeling that I am missing something.
>
>My memory keeps nagging about calling mkstemp() twice and only
>unlink() once, and then in the general case, whilst the original
>code only had one mktemp() and subsequently open()'d the tempfile.

Just so people know, I am taking a little time to look at this
more closely now.  The previous series of patches would not have
worked right for a number of reasons (even ignoring the issue of
putting the files in /tmp, when they shouldn't have been there).

The updates do not take into account all the forking that is
going on in lpd.  With the older code, a temp-name was picked,
lpd would fork to run some filter, the child would open that
tempname as stderr, and then exec the filter.  When the filter
completed, the contents of the tempname would be copied to the
logfile, and the tempname would be unlinked.

With the proposed code, the tempname is not CHOSEN until you're
already in the child which is going to exec the filter.  That
means (among other things) that all the copying/unlinking
code that's in the parent is going to fail, because it still
has the original pattern (errsXXXX) instead of the correct
temporary filename which only the child will know.

So, I will come up with an alternate version of the patch,
which will also fix some other problems with the handling
of these tempfiles.  It'll take me a little time and testing
to make sure I have it right, though.
-- 

---
Garance Alistair Drosehn            =   gad@eclipse.acs.rpi.edu
Senior Systems Programmer           or  gad@freebsd.org
Rensselaer Polytechnic Institute    or  drosih@rpi.edu


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?p0433010cb62cc872490a>