tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit ad2c07b35ec9ac10030b63aa9e896538fad5ebd3
parent 762d3c004b9e0c1bede309adbdf56a0310c74140
Author: Alex Hochheiden <ahochheiden@mozilla.com>
Date:   Mon,  5 Jan 2026 15:28:34 +0000

Bug 2007062 - Improve `./mach doctor` lastaccess warning and fix failure messages r=firefox-build-system-reviewers,glandium

Differential Revision: https://phabricator.services.mozilla.com/D277226

Diffstat:
Mpython/mozbuild/mozbuild/doctor.py | 40+++++++++++++++++++++++++++++++++-------
1 file changed, 33 insertions(+), 7 deletions(-)

diff --git a/python/mozbuild/mozbuild/doctor.py b/python/mozbuild/mozbuild/doctor.py @@ -2,8 +2,10 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, # You can obtain one at http://mozilla.org/MPL/2.0/. +import ctypes import enum import os +import shutil import socket import subprocess import sys @@ -217,16 +219,37 @@ def storage_freespace(topsrcdir: str, topobjdir: str, **kwargs) -> list[DoctorCh def fix_lastaccess_win(): """Run `fsutil` to fix lastaccess behaviour.""" + print("Disabling filesystem lastaccess") + + cmd_args = ["behavior", "set", "disablelastaccess", "1"] try: - print("Disabling filesystem lastaccess") + subprocess.check_output(["fsutil"] + cmd_args, stderr=subprocess.STDOUT) + print("Filesystem lastaccess disabled.") + return + except subprocess.CalledProcessError as e: + output = e.output.decode("utf-8", errors="replace") if e.output else "" + is_privilege_error = ( + "Access is denied" in output + or "requires elevation" in output.lower() + or e.returncode == 1 + ) - command = ["fsutil", "behavior", "set", "disablelastaccess", "1"] - subprocess.check_output(command) + if not is_privilege_error: + print(f"Could not disable filesystem lastaccess: {output}") + return - print("Filesystem lastaccess disabled.") + print("Retrying with elevated privileges...") + print("Note: This will trigger a UAC prompt.") + + fsutil_exe = shutil.which("fsutil") + if not fsutil_exe: + print("Could not find fsutil executable.") + return - except subprocess.CalledProcessError: - print("Could not disable filesystem lastaccess.") + ctypes.windll.shell32.ShellExecuteW( + None, "runas", fsutil_exe, " ".join(cmd_args), None, 0 + ) + print("Re-run `./mach doctor` to verify the change was applied.") @check @@ -259,7 +282,10 @@ def fs_lastaccess( return DoctorCheck( name="lastaccess", status=CheckStatus.WARNING, - display_text=["lastaccess enabled"], + display_text=[ + "lastaccess enabled", + DISABLE_LASTACCESS_WIN.strip(), + ], fix=fix_lastaccess_win, )