Skip to content

Fix open-as-root crash#3801

Open
Cognomines wants to merge 1 commit into
linuxmint:masterfrom
Cognomines:fix/open-as-root
Open

Fix open-as-root crash#3801
Cognomines wants to merge 1 commit into
linuxmint:masterfrom
Cognomines:fix/open-as-root

Conversation

@Cognomines

Copy link
Copy Markdown

Fix crash when using Open as Root

Cause

On Wayland, nemo-desktop uses the open_as_admin() code path. This function called nemo_window_slot_open_location() using view->details->slot, which ultimately resolves to slot->pane->window. In the desktop view context this window pointer is NULL, causing an assertion failure in nemo-window-manage-views.c.

Additionally, open_as_admin() constructed an invalid admin URI using g_uri_build(), producing admin:/path instead of the expected admin:///path. Several code paths also assumed that nemo_view_get_uri(), nemo_file_get_path(), and g_file_get_path() could never return NULL.

Solution

This patch changes open_as_admin() to launch a new nemo process with a correctly constructed admin:// URI, matching the behavior of the non-Wayland open_as_root() implementation. This avoids dereferencing the desktop view's window entirely.

It also adds NULL checks for URI and path retrieval functions so invalid or non-native paths are handled gracefully instead of crashing.

Testing

Tested on Hyprland using nemo-git built with meson -Dgtk_layer_shell=true. After applying this patch, selecting Open as Root from both the desktop icon context menu and the desktop background context menu no longer causes nemo-desktop to crash.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a crash when invoking Open as Root from the desktop on Wayland by avoiding the desktop view’s NULL window/slot path and by hardening URI/path handling against NULL returns.

Changes:

  • Reworks the Wayland open-as-admin path to spawn a new nemo process with an admin:// URI instead of opening via the current view’s slot/window.
  • Adds NULL checks around selection/view URI → path conversion to prevent crashes on non-native/invalid locations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/nemo-view.c
Comment on lines +7203 to +7210
gchar *argv[3];
argv[0] = "nemo";
argv[1] = uri;
argv[2] = NULL;
GPid pid;
g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
NULL, NULL, &pid, NULL);
g_child_watch_add (pid, (GChildWatchFunc) cb_open_as_root_watch, NULL);
@mtwebster

Copy link
Copy Markdown
Member

I get using spawn for nemo-desktop, but there's no need for it from the windowed nemo process - the original nemo_window_slot_open_location() works fine.

I think we should maybe also gate this on NEMO_IS_DESKTOP_DIRECTORY()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants