Somewhat insecure implementation of cp. Needs work as indicated in the comments.