main: Warn when unsafe mode is toggled

MetaContext:unsafe-mode was added as a debugging tool to temporarily
remove restrictions on privileged APIs. But as it turns out, there
are now extensions that toggle the property permanently. Right now
none of them are malicious (as far as I can see), but it's still a
bad idea and should be discouraged.

Do this with a notification that warns the user when unsafe mode is
enabled non-interactively (i.e. via looking glass), and hopefully
also clarifies what the weird lock icon in the top bar is about.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4798

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2050>
This commit is contained in:
Florian Müllner 2021-11-23 20:19:14 +01:00 committed by Marge Bot
parent 254b0ca2ad
commit aba0d0bb1b

View File

@ -247,6 +247,23 @@ function _initializeUI() {
global.display.connect('gl-video-memory-purged', loadTheme);
global.context.connect('notify::unsafe-mode', () => {
if (!global.context.unsafe_mode)
return; // we're safe
if (lookingGlass?.isOpen)
return; // assume user action
const source = new MessageTray.SystemNotificationSource();
messageTray.add(source);
const notification = new MessageTray.Notification(source,
_('System was put in unsafe mode'),
_('Applications now have unrestricted access'));
notification.addAction(_('Undo'),
() => (global.context.unsafe_mode = false));
notification.setTransient(true);
source.showNotification(notification);
});
// Provide the bus object for gnome-session to
// initiate logouts.
EndSessionDialog.init();