]> git.ipfire.org Git - people/stevee/network.git/commitdiff
copy: Do not empty $dst when source file cannot be read
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 19 Jul 2017 18:50:48 +0000 (20:50 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 19 Jul 2017 18:50:48 +0000 (20:50 +0200)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.util

index 5935dcc2c8d9d63d672447ac1fb0ea7157f9221d..664e90917d3ca374ee68a2aca6680f1aa70b6714 100644 (file)
@@ -760,6 +760,12 @@ copy() {
        local src=${1}
        local dst=${2}
 
+       # Check if we can read from the source
+       if [ ! -r "${src}" ]; then
+               log ERROR "Cannot read ${src}"
+               return ${EXIT_ERROR}
+       fi
+
        # Check if ${dst} is a directory
        if [ -d "${dst}" ]; then
                log ERROR "${dst} is a directory"