problem with 'cp' command

In some situations, the “cp” command is not behaving correctly.

Namely, the “-i” flag is not being checked during at least one operation.
Here is how this is reproducable:

$ touch myfile
$ chmod 0 myfile
$ cp /dev/null myfile
cp: Open dest for write failed. Unlink first? (y/N)

This question should only be asked if cp is running with “-i”.

(Using “-f” correctly does not fix this problem since “-f” will fail
silently with this error, instead of exiting with an error code.)

The desired action is for cp to fail with an error, not ask a question.
This behavior breaks at least one GNU configure script.

fixed…there were a couple places where the interactive flag was not
being checked properly. Now it behaves the way it should.

Cheers,

Kris

Kees Cook <cook@cpoint.net> wrote:

In some situations, the “cp” command is not behaving correctly.

Namely, the “-i” flag is not being checked during at least one operation.
Here is how this is reproducable:

$ touch myfile
$ chmod 0 myfile
$ cp /dev/null myfile
cp: Open dest for write failed. Unlink first? (y/N)

This question should only be asked if cp is running with “-i”.

(Using “-f” correctly does not fix this problem since “-f” will fail
silently with this error, instead of exiting with an error code.)

The desired action is for cp to fail with an error, not ask a question.
This behavior breaks at least one GNU configure script.


Kris Warkentin
kewarken@qnx.com
(613)591-0836 x368
“You’re bound to be unhappy if you optimize everything” - Donald Knuth