Closed Bug 2065295 Opened 2 months ago Closed 1 month ago

SanitizeOnShutdown (as object) should allow user exceptions when not set by policy

Categories

(Firefox :: Enterprise Policies, enhancement)

Firefox 154
enhancement

Tracking

()

RESOLVED FIXED
158 Branch
Tracking Status
firefox158 --- fixed

People

(Reporter: primexx, Assigned: mkaply)

Details

Attachments

(1 file, 1 external file)

Steps to reproduce:

Currently, when set as an object, if any member of SanitizeOnShutdown is set by policy, the entire "History" section in about:preferences#privacy is greyed out and cannot be configured. Even if a member was not set by policy, it still cannot be configured in the GUI. This is regardless of whether Lock is set or not.

Actual results:

This presents a problem particularly for exceptions starting in Firefox 154 - due to the migration of the exceptions mechanism described under Allow on this page.

It used to be that a policy can set to clear Cookies (among other things) on shutdown, and an exception can be made to preserve cookies for a specific domain in about:preferences#privacy > Browsing data > Manage exceptions and in the Exceptions - Cookies and Site Data dialogue that pops up, entering the domain and clicking Allow. This no longer works in Firefox 154.

Now, those exceptions need to be configured in about:preferences#privacy > History > Choose what you want Firefox to remember > Manage Exceptions, and in the Exceptions - Clear History on Shutdown dialogue that pops up instead.

However, as described above, if any SanitizeOnShutdown member is set, even if the Exceptions member is not set, this entire preference is inaccessible. So it is impossible to configure exceptions in GUI.

Expected results:

If the Exceptions member for SanitizeOnShutdown is not set, the user should be able to configure exceptions in GUI. Not setting Exceptions in policy should be indicative of the intent to allow the user to configure it in the browser.

This should be regardless of whether Lock is set. Lock should only lock values that have been set in policy, not affect those that were left un-configured in policy.

The Bugbug bot thinks this bug should belong to the 'Firefox::Enterprise Policies' component, but is not confident enough to move the bug to that component.

Component: Untriaged → General
Component: General → Enterprise Policies

So the reason I did it this way is for legacy reasons:

https://searchfox.org/firefox-main/source/browser/components/enterprisepolicies/Policies.sys.mjs#3015

but that was in 2020 and I got bit by this exact thing the other day, so I would tend to agree with you.

In all other cases, not specifying "Locked" is unlocked. SanitizeOnShutdown should not be the exception to the rule.

Assignee: nobody → mozilla
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

I'll just add a clarification:

There are two different (but related) questions:

  1. how Locked behaves: if it is not set, then of course nothing should be locked. if it is set, then the next question is relevant.

  2. when Locked is true, what should be locked: I suggest that it should only lock those preferences (members) that have been set by policy. but any that have not been set by policy should still be user-configurable even with Locked set.

I wrote the initial report with respect to Exceptions because that is the one where there was a change in behaviour between 153 -> 154 due to the migration, but I suppose the same idea applies to every other policy preference as well.

Thanks!

The docs say this:

When set as an object, any member omitted is treated as false, taking precedence over user settings for that data type. Accepts one or more of the following members to clear specific data types:

Which I'm now thinking was the wrong call.

I'll fix.

I don't want to just flip the Locked default here.

The object members are stale. They map to the old Clear History dialog, but shutdown only reads privacy.clearOnShutdown_v2.*, and Downloads/Sessions/OfflineApps write v1 prefs nothing looks at anymore. That's bug 2040977.

Making Locked default to false also wouldn't work. A user pref beats a default pref, and Sanitizer.maybeMigratePrefs writes all five v2 prefs to the user branch on the first shutdown clear even for categories the user never touched. So on any profile that's shut down once, an unlocked policy does nothing. Chrome hit this too, ClearBrowsingDataOnExitList is mandatory only.

So I'm adding ClearOnShutdown with one member per real category: BrowsingHistoryAndDownloads, CookiesAndStorage, Cache, FormData, SiteSettings, plus Exceptions and Enabled. No Locked. Naming a category enforces it, anything you don't name stays the user's and stays editable in the dialog. SanitizeOnShutdown doesn't change, so existing configs keep working.

The actual bug filed here is separate and simpler: Manage Exceptions inherits its disabled state from the History dropdown, so locking clear-on-shutdown greys it out even though exceptions aren't a pref and the policy didn't set them. One line fix in the privacy pane, and it fixes this for the current policy without anyone migrating.

SanitizeOnShutdown locks privacy.sanitize.sanitizeOnShutdown, which disables the
"Clear history when Firefox closes" checkbox. Manage Exceptions and the button
that picks which categories to clear were disabled along with it, because both
keyed off alwaysClear.disabled.

Neither of those belongs to the policy. Exceptions are not a pref at all, and
the categories a policy leaves unset are deliberately left unlocked. Both now
key off whether clearing is going to happen, rather than off whether the
checkbox happens to be editable.

thanks for the detailed analysis, they make a lot of sense

The object members are stale. They map to the old Clear History dialog, but shutdown only reads privacy.clearOnShutdown_v2.*, and Downloads/Sessions/OfflineApps write v1 prefs nothing looks at anymore. That's bug 2040977.

since you mention it, i was wondering about this... there are a five series of prefs related to clearing stuff: privacy.clearHistory.*, privacy.clearOnShutdown.*, privacy.clearOnShutdown_v2.*, privacy.clearSiteData.*, privacy.cpd.*

are privacy.clearOnShutdown_v2.* (for deletion on shutdown) and privacy.clearSiteData.* (for manual user deletion) the only two that are still used anymore? it looks that way

Yes, everything has migrated to the new prefs.

There is an r+ patch which didn't land and no activity in this bug for 1 week.
:mkaply, could you have a look please?
If you still have some work to do, you can add an action "Plan Changes" in Phabricator.
For more information, please visit BugBot documentation.

Flags: needinfo?(mstriemer)
Flags: needinfo?(mozilla)

Landing

Flags: needinfo?(mstriemer)
Flags: needinfo?(mozilla)
Pushed by mozilla@kaply.com: https://github.com/mozilla-firefox/firefox/commit/6db1b82dfea7 https://hg.mozilla.org/integration/autoland/rev/e92cb95650aa Do not grey out the clear-on-shutdown sub-settings when a policy locks clearing on. r=mstriemer
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 158 Branch
QA Whiteboard: [qa-triage-done-c159/b158]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: