[arch-projects] [initscripts][PATCH 1/5] arch-tmpfiles: don't truncate directories on --create

Dave Reisner d at falconindy.com
Sun Dec 25 13:27:12 EST 2011


arch-tmpfiles should not truncate directories when invoked with
--create. This matches behavior from systemd's tmpfiles binary.

Signed-off-by: Dave Reisner <dreisner at archlinux.org>
---
Pointed out to me on IRC when someone asked if it was safe to run
arch-tmpfiles --create on installation of a package. This makes it
safe.

 arch-tmpfiles |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch-tmpfiles b/arch-tmpfiles
index f133a40..73c4328 100755
--- a/arch-tmpfiles
+++ b/arch-tmpfiles
@@ -87,17 +87,18 @@ _D() {
 	# Create or empty a directory
 	local path=$1 mode=$2 uid=$3 gid=$4
 
-	(( CREATE )) || return 0
-
 	if ! checkparams 4 "$@"; then
 		warninvalid
 		return
 	fi
 
-	if [[ -d $path ]]; then
+	if [[ -d $path ]] && (( REMOVE )); then
 		find "$path" -mindepth 1 -maxdepth 1 -xdev -print0 | xargs -r0 rm -rf
 	fi
-	install -d -m"$mode" -o"$uid" -g"$gid" "$path"
+
+	if (( CREATE )); then
+		install -d -m"$mode" -o"$uid" -g"$gid" "$path"
+	fi
 }
 
 _p() {
-- 
1.7.8.1



More information about the arch-projects mailing list