From owner-freebsd-ports Wed Jun 7 3:45:13 2000 Delivered-To: freebsd-ports@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id EAA5D37BAB7; Wed, 7 Jun 2000 03:45:11 -0700 (PDT) (envelope-from kris@FreeBSD.org) Received: from localhost (kris@localhost) by freefall.freebsd.org (8.9.3/8.9.2) with ESMTP id DAA68624; Wed, 7 Jun 2000 03:45:12 -0700 (PDT) (envelope-from kris@FreeBSD.org) X-Authentication-Warning: freefall.freebsd.org: kris owned process doing -bs Date: Wed, 7 Jun 2000 03:45:12 -0700 (PDT) From: Kris Kennaway To: Maxim Sobolev Cc: mi@privatelabs.com, freebsd-ports@FreeBSD.org, Ade Lovett Subject: Re: Call for arbitrage [Fwd: Re: ports/19047: net/arpwatch patched to use tmpfile() instead of mktemp()] In-Reply-To: <393E1D01.301DD0D7@FreeBSD.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org I believe the question is whether tmpfile() should be used in preference to mkstemp(). On FreeBSD, either tmpfile() or mkstemp() have identical security properties (tmpfile() in fact calls mkstemp() internally), but as stated in the manpage, on other platforms tmpfile() is broken. Therefore, my recommendation is to use something like: int fd; FILE *fp; if ((fd = mkstemp(foo)) == -1) { err(1, "mkstemp"); } else { unlink(fd); } if ((fp = fdopen(fd, "w+")) == NULL) err(1, "fdopen"); ... The unlink is to make sure that the temporary file is not left lying around if the process exits before it would otherwise have been created (in the old mktemp() scheme). This method is portable across platforms, and can safely be reintegrated by the software author. Kris ---- In God we Trust -- all others must submit an X.509 certificate. -- Charles Forsythe To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message