[5594] in bugtraq

home help back first fref pref prev next nref lref last post

Re: Safe /tmp cleanup

daemon@ATHENA.MIT.EDU (Valdis Kletnieks)
Thu Nov 13 15:16:41 1997

Date: 	Thu, 13 Nov 1997 12:43:28 -0500
Reply-To: Valdis.Kletnieks@VT.EDU
From: Valdis Kletnieks <Valdis.Kletnieks@VT.EDU>
X-To:         douglas-siebert@uiowa.edu
To: BUGTRAQ@NETSPACE.ORG
In-Reply-To:  Your message of "Thu, 13 Nov 1997 10:48:43 CST." 
              <199711131648.KAA08976@l-ecn069.icaen.uiowa.edu>

--==_Exmh_1875402210P
Content-Type: text/plain; charset=us-ascii

On Thu, 13 Nov 1997 10:48:43 CST, you said:
> >     find2perl /dir /ect -eval '-A > 1.5 and unlink' | perl

> > Perl is your friend.  Use Perl.
> Wrong.  Check out this snippet from find.pl (from perl 5.003):

I can't help it if you're using old, outdated, buggy software.  5.004_01 came
out in May 97, current is 5.004_04.

>                 # Get link count and check for directoriness.
 (code elided)

This code has been overhauled for 5.004.  In particular, it now passes along
a 'wanted' function that can do any additional checking you desire.

> It "checks for directoriness", and if it is a directory it chdir's into it.
> This does not do anything at all to prevent someone changing the name which
> used to be a directory into a link to somewhere else in the meantime.  You

You can use the 'wanted' function to do this checking.

However, Randal's one-liner passed the 'wanted' function '-A > 1.5 and unlink'
which does, in fact, do *no* checking of the type needed.  However, the lstat
information of the *original* directory is available to the 'wanted' function,
and it can re-lstat the *current*, do compares of dev/inode pairs, and reject
if it's been changed.

Bottom line:  find2perl *can* do it securely.  But not with Randal's original
one-line solution.
--
                                Valdis Kletnieks
                                Computer Systems Senior Engineer
                                Virginia Tech


--==_Exmh_1875402210P
Content-Type: application/pgp-signature

-----BEGIN PGP MESSAGE-----
Version: 2.6.2

iQCVAwUBNGs8PtQBOOoptg9JAQFIogQAozaxBX5kUEMeJ6Em49eEJHOuIdSS1Du0
727Vialiqa00t4O7jvl/hL+hllI2e0ylwed4zAOLN/f+0xX1Aqs1iqXS0//qKmS5
7lZM/FRTnlDYX96TCHg29gf6uelhhnP+wZKLjORYrcCnnDtcxZ1bhcp1QPevB4u3
Urtnr0jtneA=
=VHXu
-----END PGP MESSAGE-----

--==_Exmh_1875402210P--

home help back first fref pref prev next nref lref last post