Photo ID race condition
dshaw at jabberwocky.com
Tue May 28 05:30:02 CEST 2002
On Mon, May 27, 2002 at 08:40:30PM -0500, Keith Ray wrote:
> Hmm, I should have been more explicit on my setup ;) I was using 1.0.7a-cvs
> from May 24. The photo viewer was the default:
> #define DEFAULT_PHOTO_COMMAND "start /w %i"
> Mozilla is the default .jpg viewer. For some reason, execution returns to
> GnuPG immediately after launching Mozilla. Mozilla does not finish loading
> itself and then the picture before GnuPG deletes the temporary directory and
> file. Thus, solution #3 isn't working.
It looks like Mozilla is being "helpful" here and returning control
before doing the requested command. If that is the case, then this is
not something that GnuPG can address. Are you sure that is what is
happening? What happens when you do "start /w foobar.jpg" from the
command line on some other jpg you may have lying around?
> Unless there is a way to modify the "start" command to actually wait
> when launching an object file instead of an executable, I think the
> best route would be to read the registry to find the default viewer
> and then "start" that.
GnuPG is a crypto program, and reading the registry to figure out
photo viewers is getting too far astray from that core functionality.
This is where bugs come in and bugs in crypto software can be very
dangerous. I did add generic call-a-program functionality because it
is usable in several places (keyservers as well as photo IDs) but it
must be kept simple and easily verifiable.
In any event, the whole point of "start" itself is to read the
registry and start the appropriate program, so there is no point in
adding code to do this to GnuPG.
> I will code up a patch against CVS and e-mail it to you when I'm done.
The "/w" flag for start means "wait". Unfortunately, it seems that
Mozilla's start-in-the-background feature defeats this. If that is
what is happening then there is nothing that can (easily) be done here
with start or even internal to GnuPG since it can only wait for a
program that does not start in the background (some viewers give you a
If you must use Mozilla as your viewer, then use %I in your
photo-viewer rather than %i (that is, capital "I" rather than
lowercase "i"). This will make GnuPG not delete the temp file at all,
so you will need to delete it yourself when you are done with it.
Like I said before, 1.0.8 has a slightly different implementation (not
yet checked in, so you won't see it in CVS) that allows for better
handling of arguments in the photo-viewer command line, but there is
very little that can be done about the start-in-the-background
problem. If it makes you feel any better, it's the same way on Unix
when using temp files, but at least the Unix viewers usually aren't
written to background themselves automatically.
David Shaw | dshaw at jabberwocky.com | WWW http://www.jabberwocky.com/
"There are two major products that come out of Berkeley: LSD and UNIX.
We don't believe this to be a coincidence." - Jeremy S. Anderson
More information about the Gnupg-devel