Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Jan 2007 03:17:10 +0100
From:      Dirk Engling <erdgeist@erdgeist.org>
To:        Colin Percival <cperciva@freebsd.org>
Cc:        freebsd-security@freebsd.org, Pawel Jakub Dawidek <pjd@freebsd.org>
Subject:   Re: HEADS UP: Re: FreeBSD Security Advisory FreeBSD-SA-07:01.jail
Message-ID:  <45AC35A6.7090103@erdgeist.org>
In-Reply-To: <45AC2E9F.20901@freebsd.org>
References:  <200701111841.l0BIfWOn015231@freefall.freebsd.org> <45A6DB76.40800@freebsd.org> <20070113112937.GI90718@garage.freebsd.pl> <45ABDC7C.6060407@erdgeist.org> <20070115210826.GA2839@garage.freebsd.pl> <45ABEEEE.4030609@erdgeist.org> <20070115220039.GB2839@garage.freebsd.pl> <45AC29EA.70009@erdgeist.org> <45AC2E9F.20901@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Colin Percival wrote:

> No.  `cp -f` unlinks the existing file and creates a new file, but will
> still follow a symlink if one is created between the "unlink" syscall and
> the "open" syscall.
> 
>                     /* remove existing destination file name,
>                      * create a new file  */
>                     (void)unlink(to.p_path);
>                                 if (!lflag)
>                         to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT,
>                                   fs->st_mode & ~(S_ISUID | S_ISGID));

You are right. Atomically in binary is not atomical enough.

mv in its rename()-form will do the job, so we need to create a file in
. by mktemp and mv it to the real name when filled.

Regards

  erdgeist
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iD8DBQFFrDWmImmQdUyYEgkRAgSgAJ0c5mcaM4LByBUE0LC1Iqdj8ZFSAACdF9qM
fFETX4I+Fvue0u+343bBG8c=
=MkSh
-----END PGP SIGNATURE-----



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