Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Jan 2007 17:47:11 -0800
From:      Colin Percival <cperciva@freebsd.org>
To:        Dirk Engling <erdgeist@erdgeist.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:  <45AC2E9F.20901@freebsd.org>
In-Reply-To: <45AC29EA.70009@erdgeist.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>

next in thread | previous in thread | raw e-mail | index | archive | help
Dirk Engling wrote:
> Please try the "cp -f" before guessing, what it might do ;)
> 
> cp -f removes anything on that location before relinking the new file.
> Atomically.

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));


Colin Percival



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