Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to connect to user bus: Permission denied #257

Closed
Sunderland93 opened this issue Apr 11, 2020 · 16 comments
Closed

Failed to connect to user bus: Permission denied #257

Sunderland93 opened this issue Apr 11, 2020 · 16 comments

Comments

@Sunderland93
Copy link

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

@luispabon
Copy link

luispabon commented Apr 24, 2020

I'm having the same problem on Ubuntu 20.04. I reckon it's an ubuntu problem, and recent - I had my notifications working until recently (I upgraded to 20.04 a month ago). Any idea what to look for debugging this @emersion ? Might have to report it to ubuntu itself.

I've tried with Ubuntu's package and also compiled my own, with the same problem. I'm also getting this with my config file:

Unable to open /home/luis/.config/mako/config for readingFailed to parse config

This config has been working fine forever. Removing the file results in the failed to connect to bus error.

@luispabon
Copy link

@Sunderland93 I discovered I had mate-notification-daemon running for some weird reason (I don't recall installing any mate components) which was preventing mako from working. After uninstalling it and logging back in mako started working again.

@DanSnow
Copy link

DanSnow commented Apr 27, 2020

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

@luitzifa
Copy link

I can confirm its related to AppArmor in Ubuntu 20.04 .

@emersion
Copy link
Owner

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

@stevenengler
Copy link

Just as a note for 20.04: the apparmor error for the mako message Failed to connect to user bus: Permission denied is:

audit: type=1400 audit([snip]): apparmor="DENIED" operation="connect" profile="fr.emersion.Mako" name="/run/user/1000/bus" pid=1737548 comm="mako" requested_mask="wr" denied_mask="wr" fsuid=1000 ouid=1000

I added the line /run/user/*/bus rw, to local/fr.emersion.Mako, but this is not quite enough to fix the problem since after reloading the profile, the new error is Failed to acquire service name: Permission denied. This time apparmor does not log any errors, but disabling the apparmor profile for mako altogether fixes the problem.

@BNolet
Copy link

BNolet commented Sep 27, 2020

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

@fbo25
Copy link

fbo25 commented Dec 14, 2020

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

@apiraino
Copy link

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

@fbo25
Copy link

fbo25 commented Dec 29, 2020

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},

@x10an14
Copy link

x10an14 commented Jan 29, 2021

@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 #257 (comment) 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 #257 (comment) 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).

@SuperBo
Copy link

SuperBo commented Apr 19, 2021

Thank @fbo25. His approach and https://github.com/emersion/mako/tree/master/contrib/apparmor works for me on Ubuntu 20.04.

@karlmdavis
Copy link

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!

@wjdp
Copy link

wjdp commented Mar 9, 2023

Tried the above from @karlmdavis on Ubuntu 22.04 and sadly seems no longer working. I've no experience with apparmour so struggling to know where to start. Have reverted to the aa-disable method for now.

Error I'm getting with profile enforced is

Unable to open /home/will/.config/mako/config for reading
Failed to parse config

wjdp added a commit to wjdp/dotfiles that referenced this issue Mar 9, 2023
@gerardparareda
Copy link

I am also facing this same issue on Ubuntu 22.04.

@xe2io
Copy link

xe2io commented Jul 17, 2023

For those using Ubuntu 22.04 (I also ran into this issue :P)- 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 (#378 (comment)).

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 #257 (comment) and #378 (comment) 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!

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

No branches or pull requests