From 38b2718c876bce73463efe70a8eb5753b4f13d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Mon, 7 Nov 2011 18:26:53 +0100 Subject: [PATCH] Avoid using the find command to check if new image files are safe, for better performance --- src/image_mad/remotes/fs/fsrc | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/image_mad/remotes/fs/fsrc b/src/image_mad/remotes/fs/fsrc index 24ad43fbd6..fb3980a2af 100644 --- a/src/image_mad/remotes/fs/fsrc +++ b/src/image_mad/remotes/fs/fsrc @@ -67,15 +67,19 @@ function fs_du { } function check_restricted { - if [ -n "`find -L $SAFE_DIRS -path $1 2>/dev/null`" ] ; then - echo 0 - return - fi + for path in $SAFE_DIRS ; do + if [ -n "`readlink -f $1 | grep -E "^$path"`" ] ; then + echo 0 + return + fi + done - if [ -n "`find -L $RESTRICTED_DIRS -path $1 2>/dev/null`" ]; then - echo 1 - return - fi + for path in $RESTRICTED_DIRS ; do + if [ -n "`readlink -f $1 | grep -E "^$path"`" ] ; then + echo 1 + return + fi + done echo 0 } \ No newline at end of file