From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10952f,b69d377feb5a8a2 X-Google-Attributes: gid10952f,public X-Google-Thread: 10872d,d4c1f7c0fe672a4 X-Google-Attributes: gid10872d,public X-Google-Thread: 1070f0,d4c1f7c0fe672a4 X-Google-Attributes: gid1070f0,public X-Google-Thread: 1164f8,d4c1f7c0fe672a4 X-Google-Attributes: gid1164f8,public X-Google-Thread: 1020c6,d4c1f7c0fe672a4 X-Google-Attributes: gid1020c6,public X-Google-Thread: fcda7,d4c1f7c0fe672a4 X-Google-Attributes: gidfcda7,public From: Barry Margolin Subject: Re: Secure cleaning of /tmp was Different Unixes pros & cons Date: 1998/09/21 Message-ID: #1/1 X-Deja-AN: 393371198 Distribution: world References: <35F71814.1E0B911C@iakom.com> <360674DF.C1EDCEAF@llnl.gov> <6u5vcg$92r@web.nmti.com> <360698A2.1F42719C@llnl.gov> X-Trace: burlma1-snr1.gtei.net 906403239 4.2.32.97 (Mon, 21 Sep 1998 18:40:39 GMT) Organization: GTE Internetworking, Cambridge, MA NNTP-Posting-Date: Mon, 21 Sep 1998 18:40:39 GMT Newsgroups: comp.unix.admin,comp.sys.hp.hpux,comp.sys.sgi.admin,comp.sys.sun.admin,comp.sys.dec,comp.security.unix Originator: barmar@bbnplanet.com (Barry Margolin) In article <360698A2.1F42719C@llnl.gov>, Jim Mellander wrote: >There is still a race condition, After the directory test, the file >being deleted ($f) could be replaced with a symlink before the rm So? The symlink will be deleted. Rm doesn't follow symlinks. It's not really a security problem, but it is a correctness problem. If, during the window, the old file gets deleted by some other process and someone creates a new file with the same name, their new file will be deleted even though it's not yet 7 days old. >My feeling is that there are too many obscure 'features' of shells in >general to trust a script to do the job of cleaning /tmp or any other >publically writable directory. Perhaps we've caught all the pitfalls >here, but I sure wouldn't bet the farm on that.... The race condition exists no matter what language the cleaner is written in. Unix is missing the primitives necessary to do it right. You need either a delete_if_older_than_x() system call, a way to lock a directory, or an unlink system call that takes a device number, inode number and generation count (enough information to uniquely identify a file). The latter 2 should probably be made available only to the superuser. -- Barry Margolin, barmar@bbnplanet.com GTE Internetworking, Powered by BBN, Burlington, MA *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.