Hope this works out well for everybody. Thanks & Merged.

Regards--
Subrata

On Fri, 2008-10-17 at 00:19 +0200, Daniel Gollub wrote:
> Hi,
> 
> Logfiles of the ltp testdriver "runltp" can get corrupted due to "unsafe"
> temporary directories and not failing when temporary already exist.
> 
> The temp directory is /tmp/ltp-$$ which can cause logfile corruption once
> the PID overflows, since "mkdir -p" will NOT fail, and runltp starts writing
> into an already existing log directory.
> 
> This patch creates a temporary directory by using "mktemp", which replaces
> the "mkdir -p" call. runltp will fail once "mktemp" runs out of combinations
> (instead of corrupting logfiles silently).
> 
> Patch is based on the idea from Erik Hamera to create more "safe" temp
> directories. Various patch improvements/fixes got contributed by Klaus Wagner
> as well.
> 
> Signed-off-by: Daniel Gollub <[EMAIL PROTECTED]>
> 
> ---
>  runltp |   29 +++++++++++++++++++----------
>  1 file changed, 19 insertions(+), 10 deletions(-)
> 
> Index: runltp
> ===================================================================
> --- runltp.orig
> +++ runltp
> @@ -76,8 +76,8 @@ setup()
>      }
>      export LTPROOT=${PWD}
>      export TMPBASE="/tmp"
> -    export TMP="${TMPBASE}/ltp-$$"
> -    export TMPDIR="${TMP}"
> +    # use mktemp to create "safe" temporary directories
> +    export TMPTEMPLATE="${TMPBASE}/ltp-XXXXXXXXXX"
>      export PATH="${PATH}:${LTPROOT}/testcases/bin"
> 
>      [ -d $LTPROOT/testcases/bin ] ||
> @@ -214,11 +214,8 @@ main()
>                  ALT_DIR_OUT=1 ;;
>              esac ;;
>                     
> -        d)  # append $$ to TMP, as it is recursively 
> -            # removed at end of script.
> -            export TMPBASE=$OPTARG
> -            export TMP="${TMPBASE}/ltp-$$"
> -            export TMPDIR="$TMP";;
> +        d)  # use mktemp to create "safe" temporary directories
> +         export TMPDIR="${OPTARG}" ;;
> 
>          D)  NUM_PROCS=1; NUM_FILES=1; NUM_BYTES=$((1024 * 1024 * 1024)); 
> CLEAN_FLAG=0
>              ARGUMENT_LIST=$OPTARG
> @@ -375,7 +372,7 @@ main()
>                       Pausing for 10 seconds..."
>       EOF
>              sleep 10 
> -            INSTANCES="-x $OPTARG -O ${TMP}";;
> +            INSTANCES="-x $OPTARG";;
>      
>          \?) usage;;
>          esac
> @@ -450,9 +447,16 @@ main()
> 
>      # Added -m 777 for tests that call tst_tmpdir() and try to 
>      #  write to it as user nobody
> -    mkdir -m 777 -p $TMP || \
> +    TMP=`mktemp -d $TMPTEMPLATE` || \
>      {
> -        echo "FATAL: Unable to make temporary directory $TMP"
> +        echo "FATAL: Unable to make temporary directory: $TMP"
> +        exit 1
> +    }
> +    export TMP
> +
> +    chmod 777 $TMP || \
> +    {
> +      echo "unable to chmod 777 $TMP ... aborting"
>          exit 1
>      }
>      
> @@ -462,6 +466,11 @@ main()
>        exit 1
>      }
>      
> +    ! [ -z $INSTANCES ] && \
> +    {
> +         INSTANCES="$INSTANCES -O ${TMP}"
> +    }
> +    
>      [ "$RUN_NETEST" -eq 1 ] && \
>      {
>          [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \
> 
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Ltp-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ltp-list


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to