Skip to content

Commit aaf01b3

Browse files
committed
improve safety on tmp dir deletion
1 parent f866e93 commit aaf01b3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

zypperoni

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ from shlex import quote
2929
import xml.etree.ElementTree as ET
3030

3131
# Constants
32-
ZYPPERONI_VERSION = "1.0.7"
32+
ZYPPERONI_VERSION = "1.0.8"
3333
ZYPPER_PID_FILE = "/run/zypp.pid"
3434
ZYPPER_ENV = "ZYPP_CURL2=1 ZYPP_PCK_PRELOAD=1 ZYPP_SINGLE_RPMTRANS=1"
3535

@@ -121,9 +121,12 @@ def recursive_delete(path):
121121
ZYPPERONI_TMP_DIR
122122
except NameError:
123123
return False
124-
if not path.startswith(tempfile.gettempdir()) or not path.startswith(ZYPPERONI_TMP_DIR):
124+
if not path.startswith("/tmp") or not path.startswith(ZYPPERONI_TMP_DIR):
125125
return False
126-
command = f"findmnt {quote(path)} > /dev/null 2>&1 || rm -r {quote(path)} > /dev/null 2>&1"
126+
out, ret = shell_exec("mount -l | grep -c '/tmp/zypperoni_'")
127+
if int(out) > 0:
128+
return False
129+
command = f"rm -r {quote(path)} > /dev/null 2>&1"
127130
os.system(command)
128131
return True
129132

0 commit comments

Comments
 (0)