Re: [vox-tech] Can't Remove File
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [vox-tech] Can't Remove File
- Subject: Re: [vox-tech] Can't Remove File
- From: Jan Wynholds <jcwynholdsMAPS@yahoo.com>
- Date: Tue, 28 Nov 2000 12:51:48 -0800
--- Micah Cowan <micah@cowanbox.com> wrote:
> To continue the discussion of removing files whose
> initial character is a '-',
> I found this excerpt from Phrack issue No. 6 (the
> article is from file no. 5,
> on sabotaging Unix systems ;) ):
>
> <<
> Messing Up A Directory
> ----------------------
> Many file-handling commands use "-" options. Create
> a file with a "-" at the
> beginning of its name by doing this:
>
> cat > -filename
>
> [now type a few lines, maybe something rude like "ha
> ha you can't delete this
> file".] Type a ^D (control-d) to end input. You
> now have a file called
> -filename in your directory. It will be VERY
> difficult to remove this file.
> If you were to try rm (remove) -filename or mv
> (rename) -filename, the rm or mv
> program would interpret -filename as an option, not
> a file, and would give you
> an error message telling you that -filename was not
> a valid option...thus, the
> file stays there obnoxiously.
>
> Create a couple of hundred files with "-" as the
> first characters in their
> names...it will be a royal pain for the person who
> is blessed with these new
> files, and they will probably just have to get a new
> login.
> >>
>
> I suspect that GNU's use of the '--' argument was
> intended to answer
> this problem, as I'm sure it became fairly common
> for malevolent users to
> try stuff like this. On older UNIX systems, I'd
> imagine the sysop would have
> to write a quick an' dirty C program which unlinks
> argc[1] without processing
> for options.
>
> On Sun, Nov 26, 2000 at 04:15:21PM -0800, Peter Jay
> Salzman wrote:
> > i will gladly answer this. harry souders (did
> you realize your name is an
> > anagram of sudoers?) answered this for me about
> half a year ago. i even
> > remember the subject of the email i sent. it was
> something like 'i can't
> > believe i'm asking this..' :) frustrating,
> ain't it?
> >
> > rm -- -g
> >
> > the -- as i understand it tells rm that there's no
> more options coming.
> > therefore, anything to the right of -- gets
> interpreted as a file.
> >
> > pete
> >
> >
I tried an interesting little test...
Say that hundreds of these files (-*) were created
throughout a directory tree (my example lists only
one, for brevity). I know that I would use find to
identify , then delete them. I actually did this, and
I tried to identify them with find. Find identified
all the files, but when I tried to remove them with
the -exec 'rm -- [filename]', I got an error message
relating to: no such file or directory. (BTW, this is
RHL 7.0 on i686)
eg
[root@localhost /] # find . -name '-*' -print
./home/user/-g
[root@localhost /] # find . -name '-*' -exec 'rm --
{}' \;
find: ./home/user/-g: No such file or directory
[root@localhost /] #
Can anyone give explain this behavior from find? I
thought that this command would work. Maybe I am
foolishly incompetant, or maybe not. Maybe find
doesn't do something right. I am pretty sure that the
command that I entered is syntactically correct (at
least as far as the man page is concerned). This find
command works for all other filenames, just not ones
with a leading '-'. Is find the wrong approach to
this sort of action? Is there another approach to
this problem? If anyone can explain this, you would
be my hero.
-Jan
__________________________________________________
Do You Yahoo!?
Yahoo! Photos - 35mm Quality Prints, Now Get 15 Free!
http://photos.yahoo.com/
|