On Wednesday 17 September 2008 04:01, Ming-Ching Tiew wrote:
> > > When I tried this with gnu 'cp' the end result
> > > is /tmp/b remain as a symbolic link, and /tmp/a was
> > modified
> > > accordingly.
> > 
> > This is intended. Coreutils cp behavior is dangerous.
> > Just imagine that the user running this command wants this:
> > 
> > "copy /etc/hosts to /tmp/a, creating /tmp/a if it
> > doesn't exist,
> > or overwrite if it exists. In other words, I don't care
> > whether it exists or not, I simpy want to make an exact
> > duplicate of /etc/hosts."
> > 
> > which is what English word "copy" implies, right?
> > 
> 
> Dangerous or not it all depends on your intent.
> 
> I think the current busybox behavior is more dangerous,
> because it wipes out the symbolic link and created
> a separate copy of the file without the user
> realizing it.

That's what "make a copy of the file" means in English.
How come I'm making a copy of an ordinary file and result
is NOT an ordinary file but a symlink?

> Coreutils cp existed first, and it's behaviour has 
> been accepted as defacto.

Yes.

> Busybox cp comes into  
> the picture to "resemble" coreutils cp, and yet 
> there are differences in behaviour. That will break 
> their way of thinking or if they already have code, 
> that will break their code.

Yes.

However, in this case, in my personal opinion,
which you are free to disagree with,
the danger of this behavior is bigger
that benefits of being "standard".

Consider this: you are root and you want to copy
a file to /tmp. Will "cp file /tmp/file" do it?
Will it be safe if you have malicious non-root users
logged in to your system?

> > If you really want "overwrite symlink
> > destination" semantic,
> > why won't you do "cat /etc/hosts >/tmp/b"?
> > In such command, your intention would be much clearer.
> 
> It's all in the mind about what's considered
> the accepted "intention" or "behaviour".

Yes. In my mind "copy" means "make an exact copy",
not "open a destination and shove source's bytes in,
even if destination is, say, /dev/hda".
For that, we have utilities which don't have
"copy" in their name, such as "cat", "dd" etc.
--
vda
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to