just for clarification why I send this patch alone. I think it is easier to get this patch merged before we talk about the vpn security policies. Make my branches easier and the emails shorter. This method works fine and results in an error every time something goes wrong. The message should be enough o encounter what the problem is.
So hopefully this one is ok :-)
Jonatan
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/functions/functions.util | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/src/functions/functions.util b/src/functions/functions.util index 381208c..8c8f569 100644 --- a/src/functions/functions.util +++ b/src/functions/functions.util @@ -752,3 +752,22 @@ hex2dec() { dec2hex() { printf "%02x\n" "${1}" } + +copy() { + # This function just copy config files + assert [ $# -eq 2 ] + + local src=${1} + local dst=${2} + + # Check if ${dst} is a directory + if [ -d ${dst} ]; then + log ERROR "${dst} is a directory." + return ${EXIT_ERROR} + fi + + if ! fread "${src}" > "${dst}"; then + log ERROR "Could not copy data from ${src} to ${dst}" + return ${EXIT_ERROR} + fi +}