The same PID?

Peter da Silva peter at baylor.UUCP
Fri Aug 30 04:30:26 AEST 1985


> >> (what happens when you get the same pid
> >> as someone else did earlier?).
> 
> This can happen very easily:  Process X does a mktemp (or tmpnam), then
> execs another program that also wants to mktemp (or tmpnam).  It's still
> got the same PID!

Yes, but at this point the first program isn't there, and had better have
cleaned up its temp files first.

Someone mentioned a security problem, using a scenario like this:

	cracker observes root preparing to edit /etc/passwd
	cracker creates a bunch of files in /tmp with the same name
and so on as the editor, pids increasing fron current pid to some large
number.
	editor creates temp files & cracker has read/write access to same.

This is about the only situation I can see where mktemp does anything
worthwhile that sprintf("/tmp/foo%dx%d", getpid(), i++) doesn't. Of course
in a case like this vipw should really create a nameless file.
-- 
	Peter (Made in Australia) da Silva
		UUCP: ...!shell!neuro1!{hyd-ptd,baylor,datafac}!peter
		MCI: PDASILVA; CIS: 70216,1076



More information about the Comp.lang.c mailing list