| 
									
										
										
										
											2008-09-15 09:57:02 +00:00
										 |  |  | #!/bin/sh
 | 
					
						
							|  |  |  | # Run under electric-fence | 
					
						
							| 
									
										
										
										
											2008-11-16 19:44:53 +00:00
										 |  |  | LIBDIRS=`../libtool --config | grep sys_lib_dlsearch_path_spec | sed -e 's/.*"\(.*\)"/\1/'` | 
					
						
							| 
									
										
										
										
											2008-09-15 16:23:19 +00:00
										 |  |  | if test -z "$LIBEFENCE"; then | 
					
						
							| 
									
										
										
										
											2008-11-17 15:28:24 +00:00
										 |  |  | 	for i in $LIBDIRS /usr/local/lib; do | 
					
						
							| 
									
										
										
										
											2008-10-19 11:34:19 +00:00
										 |  |  | 		if test -f "$i/libefence.so"; then | 
					
						
							|  |  |  | 			LIBEFENCE="$i/libefence.so" | 
					
						
							| 
									
										
										
										
											2008-09-15 16:23:19 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		fi | 
					
						
							|  |  |  | 	done | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2008-09-15 09:57:02 +00:00
										 |  |  | test -f "$LIBEFENCE" || { echo "*** electric-fence not found, skipping test"; exit 77;} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-06 07:56:41 +00:00
										 |  |  | # use the default EF_ALIGNMENT only for x86/x86_64, and set it to 8 for other | 
					
						
							|  |  |  | # platforms. ia64 needs this for example. | 
					
						
							|  |  |  | (../libtool --config | grep host=x86) || { EF_ALIGNMENT=8; export EF_ALIGNMENT; } | 
					
						
							| 
									
										
										
										
											2008-09-15 16:23:19 +00:00
										 |  |  | EF_DISABLE_BANNER=1 | 
					
						
							| 
									
										
										
										
											2008-09-15 09:57:02 +00:00
										 |  |  | EF_FREE_WIPES=1 | 
					
						
							|  |  |  | LIBPRELOAD="$LIBEFENCE" | 
					
						
							| 
									
										
										
										
											2008-09-15 16:23:19 +00:00
										 |  |  | export EF_FREE_WIPES LIBPRELOAD EF_DISABLE_BANNER | 
					
						
							| 
									
										
										
										
											2008-09-15 09:57:02 +00:00
										 |  |  | VALGRIND=`which ${VALGRIND-valgrind}` | 
					
						
							| 
									
										
										
										
											2008-09-22 11:03:55 +00:00
										 |  |  | if test ! -n "$VALGRIND" || test ! -x "$VALGRIND"; then | 
					
						
							| 
									
										
										
										
											2008-09-15 09:57:02 +00:00
										 |  |  | 	# run check_clamav under efence only if we don't have valgrind installed | 
					
						
							|  |  |  | 	echo "--- Running check_clamav under electric-fence" | 
					
						
							| 
									
										
										
										
											2008-09-16 10:32:25 +00:00
										 |  |  | 	CK_FORK=no ../libtool --mode=execute $abs_srcdir/preload_run.sh ./check_clamav | 
					
						
							| 
									
										
										
										
											2008-10-11 13:56:29 +00:00
										 |  |  | 	if test $? -ne 0; then | 
					
						
							| 
									
										
										
										
											2008-09-15 09:57:02 +00:00
										 |  |  | 		echo "*** Electric-fence has detected errors" | 
					
						
							|  |  |  | 		exit 1 | 
					
						
							|  |  |  | 	fi | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | # we don't run clamd under electric-fence, it always crashes in free(), | 
					
						
							|  |  |  | # probably doesn't work well with libpthread. | 
					
						
							|  |  |  | echo "--- running clamscan under electric-fence to detect overruns" | 
					
						
							| 
									
										
										
										
											2008-09-16 10:32:25 +00:00
										 |  |  | CLAMSCAN_WRAPPER=$abs_srcdir/preload_run.sh $abs_srcdir/check_clamscan.sh | 
					
						
							| 
									
										
										
										
											2009-02-24 09:59:16 +00:00
										 |  |  | if test $? -ne 0; then | 
					
						
							| 
									
										
										
										
											2008-09-15 09:57:02 +00:00
										 |  |  | 	echo "*** Electric-fence has detected errors" | 
					
						
							|  |  |  | 	exit 2 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | EF_PROTECT_BELOW=1 | 
					
						
							|  |  |  | export EF_PROTECT_BELOW | 
					
						
							|  |  |  | echo "--- running clamscan under electric-fence to detect underruns" | 
					
						
							| 
									
										
										
										
											2008-09-16 10:32:25 +00:00
										 |  |  | CLAMSCAN_WRAPPER=$abs_srcdir/preload_run.sh $abs_srcdir/check_clamscan.sh | 
					
						
							| 
									
										
										
										
											2009-02-24 09:59:16 +00:00
										 |  |  | if test $? -ne 0; then | 
					
						
							| 
									
										
										
										
											2008-09-15 09:57:02 +00:00
										 |  |  | 	echo "*** Electric-fence has detected errors" | 
					
						
							|  |  |  | 	exit 3 | 
					
						
							|  |  |  | fi |