bin/104044: [patch] rc.d/cleartmp works incorrectly

Andrey Simonenko simon at comsys.ntu-kpi.kiev.ua
Mon Oct 9 02:10:22 PDT 2006


The following reply was made to PR bin/104044; it has been noted by GNATS.

From: Andrey Simonenko <simon at comsys.ntu-kpi.kiev.ua>
To: bug-followup at FreeBSD.org
Cc:  
Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly
Date: Mon, 9 Oct 2006 12:07:16 +0300

 Updated version of cleartmp:
 
 1.	Change "rm -rf ..." to "rm -rf -- ..."
 
 2.	Remove cleartmp_X() and createtmp_X() functions.
 
 --- cleartmp.orig	Mon Apr 10 16:10:30 2006
 +++ cleartmp	Mon Oct  9 11:53:07 2006
 @@ -14,43 +14,42 @@
  
  start_cmd="${name}_start"
  
 -cleartmp_prestart()
 -{
 -	checkyesno clear_tmp_X || return
 -
 -	local x11_socket_dirs="/tmp/.X11-unix /tmp/.ICE-unix /tmp/.font-unix \
 -	    /tmp/.XIM-unix"
 -
 -	# Remove X lock files, since they will prevent you from restarting X.
 -	rm -f /tmp/.X[0-9]-lock
 -
 -	# Create socket directories with correct permissions to avoid
 -	# security problem.
 -	#
 -	rm -fr ${x11_socket_dirs}
 -	mkdir -m 1777 ${x11_socket_dirs}
 -}
 +x11_socket_dirs="/tmp/.X11-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/.XIM-unix"
  
  cleartmp_start()
  {
  	echo "Clearing /tmp."
 -	#
 -	#	Prune quickly with one rm, then use find to clean up
 -	#	/tmp/[lq]* (this is not needed with mfs /tmp, but
 -	#	doesn't hurt anything).
 -	#
 -	(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
 -	    find -x . ! -name . ! -name lost+found ! -name quota.user \
 -		! -name quota.group ! -name .X11-unix ! -name .ICE-unix \
 -		! -name .font-unix ! -name .XIM-unix \
 +
 +	# Try to remove files with rm, then use find to clean up the rest
 +	# of files, including those, which do not fit in command line
 +	# (this is not needed with mfs /tmp, but doesn't hurt anything).
 +	(cd /tmp && rm -rf -- .[!.] .??* [!lq]* &&
 +	    find -x . ! -name . \
 +		! \( -name lost+found -type d -user root \) \
 +		! \( \( -name quota.user -or -name quota.group \) \
 +			-type f -user root \) \
  		-exec rm -rf -- {} \; -type d -prune)
 +
 +	if checkyesno clear_tmp_X; then
 +		# Create X related directories.
 +		mkdir -m 1777 ${x11_socket_dirs}
 +	fi
  }
  
  load_rc_config $name
  
  # The clear_tmp_X variable should be tested even if clear_tmp_enable is NO
  case "$1" in
 -*start)	cleartmp_prestart ;;
 +*start)
 +	if ! checkyesno ${rcvar} && checkyesno clear_tmp_X; then
 +		# Remove X lock files, since they will prevent you from
 +		# restarting X.  Remove other X related directories and
 +		# create them again.
 +		echo "Clearing /tmp (X related)."
 +		rm -fr /tmp/.X[0-9]-lock ${x11_socket_dirs}
 +		mkdir -m 1777 ${x11_socket_dirs}
 +	fi
 +	;;
  esac
  
  run_rc_command "$1"


More information about the freebsd-rc mailing list