Subject: lbu overlays kept in the /tmp directory

From: Jerome Marc <[email-masked]>
Date: Fri, 5 Sep 2025 16:34:06 +0200

Hello,

I run 3.22.1 on a RPI and I use a dedicated partition for lbu and apk cache.
I noticed that every time I run 'lbu ci' the overlay file is created in a
temporary folder but it's not removed automatically.
I don't see any evidence of error : files are copied into the partition and
there is no error message in the log files

Is that a normal behaviour ?

Thank you

---

From: Stefan Hartmann SH <[email-masked]>
Date: Fri, 5 Sep 2025 20:05:12 +0200

On 05/09/2025 16:34, Jerome Marc wrote:
> I noticed that every time I run 'lbu ci' the overlay file is created in 
> a temporary folder but it's not removed automatically.
> I don't see any evidence of error : files are copied into the partition 
> and there is no error message in the log files
> 

Recently I noticed the same behaviour.

I am running many Alpine systems with persistent disk and use lbu pkg to 
create a staged backup, so there are a lot of annoying lbu-* dirs in 
/tmp on long running systems. Eventually also a security impact in some 
bad circumstances.

I made a workaround for me but havent got time now to commit the changes 
at the appropriate place.

It could be as follow:

#1 in the shell script or better in the sourced libalpine.sh
clean_tmpdir() {
	if [ -n "$1" ] && [ "$( dirname "$1" )" = '/tmp' ] && basename "$1" | 
grep -Eq "^$PROGRAM-.+"; then
		rm -r "$1"  ||
			eecho "failed to clean tmpdir"
	fi
}

#2 in cmd_package(), cmd_status(), cmd_diff()
...
clean_tmpdir "${tmpdir}" or clean_tmpdir "${tmp}"

Also I have a second improvement with
RUN_LBU_PRE_POST_PACKAGE="true"		# dont run pre-post-backup on 
cmd_status, cmd_diff

-- 
Stefan Hartmann - ib.hafenthal.de