implement upower interface

Bug #1595813 reported by Alex Spataru
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Snappy
Fix Released
Wishlist
Jamie Strandboge

Bug Description

I am developing an application that constantly displays CPU usage and Battery status to the user. For the sake of simplicity, I launch bash (which itself launches other processes such as grep) to obtain the required information.

When I "snap" my application, Snappy's security model does not allow my application to launch bash as an external process. I am using the following programs/processes:

- grep
- awk
- upower
- bash (which launches the other processes with UNIX pipes)

If you need to check the code that I use to obtain CPU usage & battery info, please see:
    https://github.com/WinT-3794/QDriverStation/blob/master/src/utilities.cpp#L44

You may want to check my snapcraft.yaml file:
    https://github.com/WinT-3794/QDriverStation/blob/master/etc/deploy/linux/snapcraft/snapcraft.yaml

Note that I have tried my application with both the "strict" and "devmode" confinements.

Is there any interface specific for my configuration, or must I change something in my snapcraft.yaml?

Thanks for the support!

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Thank you for reporting a bug. The fact that devmode is not working indicates something unrelated to interfaces is not quite working with your snap.

To be clear though, snaps can launch external processes and grep, awk and bash are all allowed in the default policy (upower is not and needs research) but the files they operate on may not be allowed by the security policy. I looked at the source code and see that:
* /proc/stat is currently not allowed. I'll add this to the system-observe interface
* the upower command is not available in the os snap, so your commands cannot succeed

I suspect it is this last point that is blocking you. If you included 'upower' in your stage packages, I suspect this would start to work in devmode.

For strict mode, upowerd is a DBus service that exists on classic systems but not native systems. To allow access to upowerd we'd need to create a new interface.

Based on the above, I'm going to change the title of this bug accordingly.

Note to snappy interfaces team: perhaps upower-observe and upower-control? I've not examined the DBus API to see if this is feasible, but I suspect it is so long as upower-observe can use DBus Get and upower-control can use DBus Set methods.

summary: - Snapped app cannot launch external processes
+ implement upower interface
Changed in snappy:
importance: Undecided → Wishlist
Changed in snappy:
assignee: nobody → Jamie Strandboge (jdstrand)
status: New → In Progress
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

@Alex,

FYI with snapcraft, you can do something like this:

...
parts:
  mypackages:
    plugin: nil
    stage-packages:
    - upower

Then upower is available in your snap.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Implemented as 'upower-observe'.

Changed in snappy:
milestone: none → 2.15
status: In Progress → Fix Committed
Revision history for this message
Andy Whitcroft (apw) wrote : Please test proposed package

Hello Alex, or anyone else affected,

Accepted snapd into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/snapd/2.14.2~16.04 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

tags: added: verification-needed
Revision history for this message
Alex Spataru (alex-spataru) wrote : RE: [Bug 1595813] Re: implement upower interface

Thanks for the support! I will test the package again in the following days.
________________________________
From: Andy Whitcroft<mailto:<email address hidden>>
Sent: ‎9/‎1/‎2016 12:41
To: <email address hidden><mailto:<email address hidden>>
Subject: [Bug 1595813] Re: implement upower interface

Hello Alex, or anyone else affected,

Accepted snapd into xenial-proposed. The package will build now and be
available at https://launchpad.net/ubuntu/+source/snapd/2.14.2~16.04 in
a few hours, and then in the -proposed repository.

Please help us by testing this new package. See
https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to
enable and use -proposed. Your feedback will aid us getting this update
out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug,
mentioning the version of the package you tested, and change the tag
from verification-needed to verification-done. If it does not fix the
bug for you, please add a comment stating that, and change the tag to
verification-failed. In either case, details of your testing will help
us make a better decision.

Further information regarding the verification process can be found at
https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in
advance!

** Tags added: verification-needed

--
You received this bug notification because you are subscribed to the bug
report.
https://bugs.launchpad.net/bugs/1595813

Title:
  implement upower interface

Status in Snappy:
  Fix Committed

Bug description:
  I am developing an application that constantly displays CPU usage and
  Battery status to the user. For the sake of simplicity, I launch bash
  (which itself launches other processes such as grep) to obtain the
  required information.

  When I "snap" my application, Snappy's security model does not allow
  my application to launch bash as an external process. I am using the
  following programs/processes:

  - grep
  - awk
  - upower
  - bash (which launches the other processes with UNIX pipes)

  If you need to check the code that I use to obtain CPU usage & battery info, please see:
      https://github.com/WinT-3794/QDriverStation/blob/master/src/utilities.cpp#L44

  You may want to check my snapcraft.yaml file:
      https://github.com/WinT-3794/QDriverStation/blob/master/etc/deploy/linux/snapcraft/snapcraft.yaml

  Note that I have tried my application with both the "strict" and
  "devmode" confinements.

  Is there any interface specific for my configuration, or must I change
  something in my snapcraft.yaml?

  Thanks for the support!

To manage notifications about this bug go to:
https://bugs.launchpad.net/snappy/+bug/1595813/+subscriptions

Revision history for this message
Federico Gimenez (fgimenez) wrote :

Verification done with a snap created from this snapcraft.yaml file:

name: test-snapd-upower-observe-consumer
version: 1.0
summary: Basic upower-observe consumer snap
description: A basic snap declaring a plug on upower-observe

apps:
    upower:
        command: upower
        plugs: [upower-observe]

parts:
    upower:
        plugin: nil
        stage-packages: [upower]

After installing this is the interfaces list:

fgimenez@innsmouth:~/Downloads/upower-snap$ snap interfaces
Slot Plug
[...]
:upower-observe test-snapd-upower-observe-consumer
[...]

And the upower binary wrapped by the snap works as expected:

fgimenez@innsmouth:~/Downloads/upower-snap$ test-snapd-upower-observe-consumer.upower
fgimenez@innsmouth:~/Downloads/upower-snap$ test-snapd-upower-observe-consumer.upower --help
Usage:
  upower [OPTION...] UPower tool

Help Options:
  -h, --help Show help options

Application Options:
  -e, --enumerate Enumerate objects paths for devices
  -d, --dump Dump all parameters for all objects
  -w, --wakeups Get the wakeup data
  -m, --monitor Monitor activity from the power daemon
  --monitor-detail Monitor with detail
  -i, --show-info Show information about object path
  -v, --version Print version of client and daemon

fgimenez@innsmouth:~/Downloads/upower-snap$ test-snapd-upower-observe-consumer.upower -e
/org/freedesktop/UPower/devices/line_power_ADP1
/org/freedesktop/UPower/devices/battery_BAT1
/org/freedesktop/UPower/devices/DisplayDevice

tags: added: verification-done
removed: verification-needed
Revision history for this message
Steve Langasek (vorlon) wrote : Update Released

The verification of the Stable Release Update for snapd has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

This was fixed in 2.15.

Changed in snappy:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.