diff --git a/usr/bin/mintupdate-automation b/usr/bin/mintupdate-automation index d9a7cb31..75809885 100755 --- a/usr/bin/mintupdate-automation +++ b/usr/bin/mintupdate-automation @@ -55,14 +55,15 @@ def do_disable(_automation_id): print("%s %s removed." % (name, filename)) def add_user_blacklist(outfile): - import tempfile + # The user's blacklist arrives on stdin. Never read it from a shared + # location such as /tmp: another user could swap the file for a symlink + # while the authentication dialog is open. + if sys.stdin is None or sys.stdin.isatty(): + return try: - infile = os.path.join(tempfile.gettempdir(), "mintUpdate/blacklist") - with open(infile, "r") as export: - with open(outfile, "a") as f: - for line in export: - f.write(line) - os.remove(infile) + with open(outfile, "a") as f: + for line in sys.stdin: + f.write(line) print("User blacklist exported.") except: pass diff --git a/usr/lib/linuxmint/mintUpdate/__pycache__/preferences.cpython-314.pyc b/usr/lib/linuxmint/mintUpdate/__pycache__/preferences.cpython-314.pyc new file mode 100644 index 00000000..59697732 Binary files /dev/null and b/usr/lib/linuxmint/mintUpdate/__pycache__/preferences.cpython-314.pyc differ diff --git a/usr/lib/linuxmint/mintUpdate/preferences.py b/usr/lib/linuxmint/mintUpdate/preferences.py index 9f96a550..4c64da5d 100644 --- a/usr/lib/linuxmint/mintUpdate/preferences.py +++ b/usr/lib/linuxmint/mintUpdate/preferences.py @@ -5,7 +5,6 @@ import json import os import subprocess -import tempfile import gi gi.require_version('Gtk', '3.0') @@ -215,11 +214,9 @@ def _build_automation(self, builder): section.add_row(switch) def _export_blacklist(self, widget): - filename = os.path.join(tempfile.gettempdir(), "mintUpdate/blacklist") blacklist = self.settings.get_strv("blacklisted-packages") - with open(filename, "w") as f: - f.write("\n".join(blacklist) + "\n") - subprocess.run(["pkexec", "/usr/bin/mintupdate-automation", "blacklist", "enable"]) + subprocess.run(["pkexec", "/usr/bin/mintupdate-automation", "blacklist", "enable"], + input="\n".join(blacklist) + "\n", text=True) def _set_auto_upgrade(self, widget, param): self._toggle_automation(widget, "upgrade")