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: fcda7,d4c1f7c0fe672a4 X-Google-Attributes: gidfcda7,public X-Google-Thread: 1020c6,d4c1f7c0fe672a4 X-Google-Attributes: gid1020c6,public X-Google-Thread: 1070f0,d4c1f7c0fe672a4 X-Google-Attributes: gid1070f0,public X-Google-Thread: 1164f8,d4c1f7c0fe672a4 X-Google-Attributes: gid1164f8,public From: Tapani Tarvainen Subject: Re: Secure cleaning of /tmp was Different Unixes pros & cons Date: 1998/09/22 Message-ID: #1/1 X-Deja-AN: 393616995 References: <35F71814.1E0B911C@iakom.com> <3602E82F.C8638268@llnl.gov> <6tuuep$kks@web.nmti.com> <360674DF.C1EDCEAF@llnl.gov> Organization: University of Jyvaskyla, Finland Newsgroups: comp.unix.admin,comp.sys.hp.hpux,comp.sys.sgi.admin,comp.sys.sun.admin,comp.sys.dec,comp.security.unix NNTP-Posting-User: tt > 'find' doesn't remove anything, it finds a real file called > /tmp/foo/bar/passwd and then calls 'rm' to remove it. The security risk is > that in the time between when 'find' finds and 'rm' removes, one can move > away /tmp/foo/bar/bar, and create a link from /tmp/foo/bar to /etc. Then > 'rm' will remove your /etc/passwd, or whatever file you wanted rm'd. Am I missing something here? In every current system I know of, rm would only remove the link, not the file it points to. Moreover, find will neither follow symlinks unless explicitly requested nor expand any special characters in filenames before forking the rm. Thus, simply touch /tmp find /tmp -depth -atime +1 -exec rm -rf -- {} \; looks perfectly safe. Indeed any concoctions processing find's results with a shell script are probably worse, as making them foolproof against special characters is very difficult. Are there really systems out there where ln -s /etc/passwd /tmp/junk rm /tmp/junk would actually remove /etc/passwd or is there something else going on I don't understand? -- Tapani Tarvainen