mako: Failed to connect to user bus: Permission denied

Hello. I’m running Sway 1.4 on Kubuntu 20.04. I put exec mako in Sway’s config, but it doesn’t work. When I manually start Mako, it gives an error Failed to connect to user bus: Permission denied

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 16 (1 by maintainers)

Commits related to this issue

Most upvoted comments

I’m having the same problem on Ubuntu 20.04. And this seems an issue related to AppArmor. I just disable the rule for mako and it’s working.

$ sudo aa-disable /etc/apparmor.d/fr.emersion.Mako

Just a tip for some, if you get sudo: aa-disable: command not found, install apparmor-utils with sudo apt install apparmor-utils

For those using Ubuntu 22.04 (I also ran into this issue 😛)- the issue is that the packaged mako-notifier version (1.6-2 at time of writing) still contains the apparmor profile, even though it was removed (https://github.com/emersion/mako/issues/378#issuecomment-1136003563).

Two options:

add local config to /etc/apparmor.d/local/fr.emerson.Mako

This file is sourced by the packaged profile, and you’ll need to add a combination of https://github.com/emersion/mako/issues/257#issuecomment-1049087860 and https://github.com/emersion/mako/issues/378#issuecomment-1077932960 to workaround the Failed to acquire service name: Permission denied dbus error and to allow your symlinked config path.

Reload the profile:

sudo apparmor_parser -r /etc/apparmor.d/fr.emerson.Mako

Disable the fr.emerson.Mako apparmor profile

Unload the mako profile:

sudo apparmor_parser -R /etc/apparmor.d/fr.emersion.Mako

symlink fr.emerson.Mako to the disable folder for persistence:

sudo ln -s /etc/apparmor.d/fr.emersion.Mako /etc/apparmor.d/disable/

(I’m not that familiar with apparmor- you may be able to just delete the profile so it’s never loaded instead of symlinking it to the disable folder, but it looks like one needs to at least unload with apparmor_parser -R regardless of stopping/restarting the apparmor service.)

Hope this helps anyone running into the same issue!

Ubuntu 20.10 workaround

  1. Uncomment line 22 in /etc/apparmor.d/fr.emersion.Mako : include if exists <local/fr.emersion.Mako>

  2. Create file /etc/apparmor.d/local/fr.emersion.Mako

  3. …and add the following lines :

  owner @{run}/user/[0-9]*/bus rw,
  dbus send
       bus=session
       path=/org/freedesktop/DBus
       interface=org.freedesktop.DBus
       member={Hello,RequestName}
       peer=(name=org.freedesktop.DBus),
  dbus (receive)
       bus=session
       path=/org/freedesktop/Notifications
       interface=org.freedesktop.Notifications
       member={Notify,NotificationClosed,GetServerInformation,GetCapabilities},
  1. Restart apparmor service : sudo systemctl restart apparmor

This line failed for me, on Ubuntu 20.04:

  owner @{run}/user/[0-9]*/bus rw,

Produced this error when trying to reload/apply the profile:

$ sudo apparmor_parser -r /etc/apparmor.d/fr.emersion.Mako 
Found reference to variable run, but is never declared

Instead, I left the /etc/apparmor.d/fr.emersion.Mako file alone (the # doesn’t comment out the include, it’s part of the #include directive) and just created /etc/apparmor.d/local/fr.emersion.Mako with the following contents:

  owner /run/user/[0-9]*/bus rw,
  dbus send
       bus=session
       path=/org/freedesktop/DBus
       interface=org.freedesktop.DBus
       member={Hello,RequestName}
       peer=(name=org.freedesktop.DBus),
  dbus (send)
       bus=session
       path=/org/freedesktop/Notifications
       interface=org.freedesktop.Notifications
       member=NotificationClosed,
  dbus (receive)
       bus=session
       path=/org/freedesktop/Notifications
       interface=org.freedesktop.Notifications
       member={Notify,NotificationClosed,GetServerInformation,GetCapabilities,CloseNotification},

This takes mako from failing with this error:

$ mako
Failed to connect to user bus: Permission denied

To instead working as expected. Yay!

I am also facing this same issue on Ubuntu 22.04.

@emersion: Closing because this is a distribution issue. We already have an AppArmor file: https://github.com/emersion/mako/tree/master/contrib/apparmor

Replacing /etc/apparmor.d/fr.emersion.Mako with the one referenced in this repo didn’t make it work for me. Copy-pasting the lines from https://github.com/emersion/mako/issues/257#issuecomment-752066251 into the existing file /etc/apparmor.d/fr.emersion.Mako however, worked for me.

I’m running Linux Mint 20.1 - based of off Ubuntu 20.04, and installed the original file with the apparmor-profiles-extra package. (I couldn’t get the instructions https://github.com/emersion/mako/issues/257#issuecomment-744311184 to work, most likely because I don’t know how to make apparmor accept the local file - I guess I don’t know the correct format to input the given lines into).

Quick update of the workaround, because the notifications were not closed automatically by the sender :

  dbus send
       bus=session
       path=/org/freedesktop/DBus
       interface=org.freedesktop.DBus
       member={Hello,RequestName}
       peer=(name=org.freedesktop.DBus),
  dbus (send)
       bus=session
       path=/org/freedesktop/Notifications
       interface=org.freedesktop.Notifications
       member=NotificationClosed,
  dbus (receive)
       bus=session
       path=/org/freedesktop/Notifications
       interface=org.freedesktop.Notifications
       member={Notify,NotificationClosed,GetServerInformation,GetCapabilities,CloseNotification},

Same issue on debian bullseye, the workaround works. I’d like to report this to the package maintainer, but I’m confused on what the fix should be on the distribution package. Can anyone clarify this?

thanks