Can't start firefox via sudo

In some circumstance I like to run firefox as an other user. The way I used to do this was:

$ xhost +local: $ sudo -u other-user firefox

However since my latest xubuntu upgrade which made firefox a snap application this no longer works. I get the following diagnostic

/user.slice/user-1003.slice/session-c2.scope is not a snap cgroup

1 Like

That sounds like a problem that potentially affects all snaps, not just firefox. Could you file a bug against snapd and share the link here?

That’s because sudo doesn’t really set up a whole session, thus there’s no session bus, and no way to create a transient scope which is mandatory for application tracking, completing the sandbox and providing refresh app awareness. Especially on a fully cgroup v2 system, the only way device filtering can be implemented without breaking your session is using a separate cgroup (i.e. the transient scope).

perhaps using pkexec instead of sudo could work here (iirc it integrates wit logind so it might spawn enough of a session) ?

pkexec --user <username> <command>

No, that doesn’t work either:

    $ pkexec --user <username> firefox
    `/user.slice/user-1003.slice/session-c2.scope is not a snap cgroup`