Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Oct 2006 08:30:30 GMT
From:      Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua>
To:        freebsd-rc@FreeBSD.org
Subject:   Re: bin/104044: [patch] rc.d/cleartmp works incorrectly
Message-ID:  <200610100830.k9A8UU7r098495@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/104044; it has been noted by GNATS.

From: Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua>
To: Yar Tikhiy <yar@comp.chem.msu.su>
Cc: Florent Thoumie <flz@xbsd.org>, bug-followup@freebsd.org
Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly
Date: Tue, 10 Oct 2006 11:26:38 +0300

 Another updated version:
 
 1.	Everything, what belongs to _start method, was moved to
 	cleartmp_start().
 
 2.	Ignore error code from rm and always run find, that is
 	use "rm ... ; find ..." instead of "rm ... && find ...":
 	one can create many files with long names and rm will not
 	be called because of "Argument list too long" error, so
 	find should do all of the work.
 
 --- /usr/src/etc/rc.d/cleartmp	Mon Apr 10 16:10:30 2006
 +++ cleartmp	Tue Oct 10 10:03:07 2006
 @@ -10,47 +10,37 @@
  . /etc/rc.subr
  
  name="cleartmp"
 -rcvar=`set_rcvar clear_tmp`
 -
 +rcvar1=`set_rcvar clear_tmp`
  start_cmd="${name}_start"
  
 -cleartmp_prestart()
 +cleartmp_start()
  {
 -	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}
 -}
 -
 -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 \
 -		-exec rm -rf -- {} \; -type d -prune)
 +	if checkyesno ${rcvar1}; then
 +		# Remove files with rm, then use find to clean up the rest
 +		# of files (there can be too many files for command line).
 +		# This is not needed with mfs /tmp, but doesn't hurt anything.
 +		echo "Clearing /tmp."
 +		(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; }
 +		)
 +	elif checkyesno clear_tmp_X; then
 +		# Remove X lock files, since they will prevent you from
 +		# restarting X.  Remove other X related directories.
 +		echo "Clearing /tmp (X related)."
 +		rm -rf /tmp/.X[0-9]-lock ${x11_socket_dirs}
 +	fi
 +	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 ;;
 -esac
 -
  run_rc_command "$1"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200610100830.k9A8UU7r098495>