Temp files in /etc

Jeremy Chadwick koitsu at FreeBSD.org
Sat Sep 6 03:41:40 UTC 2008


On Fri, Sep 05, 2008 at 07:40:13PM -0700, Joshua Piccari wrote:
> Hi all,
> I am setting up a few jails and I want them all to use the same /etc files
> (with the exception of the files related to the password files and
> databases), so I mounted a shared /etc folder as a nullfs with read-only
> permissions. The problem is that using utilities like pw or chpass create
> temporary files in /etc and that file system is mounted read-only.
> So is there a way to force any utilities that create temp files in /etc to
> use another location, something like /usr/local/etc for example?

It depends entirely on how each individual program makes temporary
files; there is no "standard".

libc offers a many different methods of creating temporary files:
tmpfile(3), tmpnam(3), tempnam(3), mktemp(3), and mkstemp(3).  You can
read the manpages to get an idea of how chaotic the situation is.

Other programs may implement their own temporary file creation methods
entirely, and may/may not support TMPDIR.

I would try export TMPDIR="/some/place" and then attempt using pw and
chpass, and see what happens.  If they still attempt to use /tmp,
said programs could probably be modified to support TMPDIR.

-- 
| Jeremy Chadwick                                jdc at parodius.com |
| Parodius Networking                       http://www.parodius.com/ |
| UNIX Systems Administrator                  Mountain View, CA, USA |
| Making life hard for others since 1977.              PGP: 4BD6C0CB |



More information about the freebsd-hackers mailing list