Classic confinement request for wazzapp

This is a snap for an unofficial whatsapp client that has an option to show persistent notifications on new messages ("requestinteracton " is not currenty supported by electron BrowserWindow in Linux, so I used this workaround). This needs access to dbus and uses dbus-native. The option is disabled by default on installation and it’s up to the user to decide if he/she wants to have persistent notifications or not.

Full code for this available at https://github.com/diospiroverde/WazzApp

All the best.

Hey @el_pombo,

Could you please explain exactly why your snap needs classic confinement? Have you check the Process for reviewing classic confinement snaps ?

You can use the dbus interface as well as any other supported interface as needed while keeping your snap under strict confinement.

Thanks!

1 Like

Hi @emitorino,

Thank you very much for your reply.

I have an electron application that uses node-dbus (dbus protocol client and server) to communicate with the desktop notification service org.freedesktop.Notifications over dbus.

If I run it with strict confinement I get an error in this part of the code…

var dbus = require('dbus-native');
                var sessionBus = dbus.sessionBus();
                sessionBus.getService('org.freedesktop.Notifications').getInterface(
                '/org/freedesktop/Notifications',
                'org.freedesktop.Notifications', function(err, notifications) {                                 
                    notifications.on('ActionInvoked', function() {          
                        if(arguments[0] == notificationid &&  arguments[1] == 'default')                          
                            self.win.show();                      
                    });

                    notifications.on('NotificationClosed', function() {  
                        if(arguments[0] == notificationid)   
                            notificationid = 0;                                         
                    });
                });

The notifications variable is set as undefined. This doesn’t happen if I use classic confinement.

From the documentation I can only see snaps communicating with other snaps over dbus and I haven’t yet found a way to communicate with org.freedesktop.Notifications. I have defined a plug in my configuration file but I don’t see how I can use snap connect to achieve this.

I’m sorry if I’m wasting your time by asking this, this is my first snap and I may be missing something very obvious, but is it possible what I’m trying to do with strict confinement?

All the best.

Access to the notifications dbus API is provided via the desktop interface in snapd - so you should simply ensure your snap plugs: [desktop] and it should then be able to access this.

2 Likes

Hi, @alexmurray

Thank you very much for you reply. That’s valuable information.

I already had plugs: ["desktop", "desktop-legacy", "home", "x11", "unity7", "browser-support", "network", "gsettings", "pulseaudio", "opengl"], but I always get the same error when using strict confinement.

My guess is that node-dbus is internally doing something that’s not allowed under that level of confinment. I’ll check node-dbus code.

All the best.

@emitorino, @alexmurray,

Thank you both for your help.

I got this working by using the low level API of node-dbus (node-dbus-next will also work). I can now show “sticky” notifications with strict confinement.

All the best.

2 Likes

Hi, All.

I ran into another problem. When I send a notification I need to know when the notification has been closed ( NotificationClosed signal) or clicked on (ActionInvoked signal). To achieve this I monitor the signals on dbus, and this works great with classic confinement. But if I change it to strict, when I try to use AddMatch with this code

  let methodCall = new Message({
                destination: 'org.freedesktop.DBus',
                path: '/org/freedesktop/DBus',                           
                member: 'AddMatch',
                signature: 's',
                body: ["type='signal',member='NotificationClosed',path='/org/freedesktop/Notifications',interface='org.freedesktop.Notifications'"]
            });

            await bus.call(methodCall);

I get this error

 type: 'org.freedesktop.DBus.Error.AccessDenied',
  text: 'An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.1823" (uid=1000 pid=40771 comm="WazzApp                               " label="snap.wazzapp.wazzapp (enforce)") interface="(unset)" member="AddMatch" error name="(unset)" requested_reply="0" destination="org.freedesktop.DBus" (bus)',

I can see this in the Desktop Interface

dbus (receive)
    bus=session
    path=/org/freedesktop/Notifications
    interface=org.freedesktop.Notifications
    member={ActionInvoked,NotificationClosed,NotificationReplied}
    peer=(label=unconfined),

This looks promising, but to receive the signals I need to use AddMatch with org.freedesktop.DBus, unless there’s another way to do this that’s allowed with strict confinement.

Do you know if it’s possible what I’m trying to do with strict confinement?

All the best.