Requesting classic confinement for buttermanager


#1

Hi everyone!

I have just pushed to the store a new snap package that I think should have classic confinement. It is called buttermanager and it is a GUI tool coded in Python 3 and QT5 for managing BTRFS filesystems. It allows to create BTRFS snapshots (something similar to snapper tool), balance filesystems and upgrade the system safetly.

The application needs to check all the filesystems, and it depends on command line programs such as btrfs, findnmt or apt, zypper, dnf, pacman or yaourt for example (it supports Debian, Ubuntu and derivatives, OpenSUSE, Fedora and Arch Linux).

ButterManager is in GitHub: https://github.com/egara/buttermanager and it is published in AUR too https://aur.archlinux.org/packages/buttermanager/

This is my second snap package. The first one is WallpaperDownloader

Thank you very much for your time :slight_smile:

Best,

Eloy


#2

Have you tried the block-devices interface? The block-devices interface (new in 2.37.1)


#3

Hi Jamie (@jdstrand ), and thank you for the answer.

I have changed the confinment and added the block-devices interface. This is the snapcraft.yaml file:

name: buttermanager
version: "1.1"
summary: Graphical tool to manage BTRFS filesystems
description: Manage a BTRFS filesystem with this easy to use Graphical User Interface application programmed in Python and QT5. Create BTRFS snapshots, balance filesystems and upgrade the system safetly.
type: app
grade: stable
confinement: strict

apps:
  buttermanager:
    command: bin/buttermanager.sh
    plugs:
     - x11
     - desktop
     - desktop-legacy
     - wayland
     - unity7
     - home
     - block-devices 

parts:
  # Pulls the code from the original source (master branch)
  # desktop-qt5 is a snapcraft part (snapcraft-desktop-helpers) from the Wiki: https://wiki.ubuntu.com/snapcraft/parts
  # It enables desktop integration for QT5 applications
  # Github repository for snapcraft-desktop-helpers: https://github.com/ubuntu/snapcraft-desktop-helpers
  buttermanager:
    plugin: python
    python-version: python3
    source: ../
    # python3-pyqt5 is necessary for the application to run because PyQT5 has been used to code ButterManager
    # The rest of the python dependencies are not necessary because they will be included
    # when setup.py is executed by python snapcraft plugin
    stage-packages:
      - btrfs-tools
      - python3-pyqt5
    after: [desktop-qt5]

  # It will copy all the Python code needed for running the application
  # into buttermanager directory
  structure:
    plugin: dump
    source: ../buttermanager
    organize:
      '*': buttermanager/

  # It will copy buttermanager script into /bin/
  # This script contains all the commands needed to execute the application
  wrapper:
    plugin: dump
    source: scripts

I have rebuilt the snap package and installed on Ubuntu 19.10 with a BTRFS filesystem. After installing the snap, I have connected the plug and slot:

snap connect buttermanager:block-devices :block-devices

And I have run the application. Nevertheless, the next error is thrown:



Traceback (most recent call last):
File “buttermanager.py”, line 103, in load_main_window
ButtermanagerMainWindow(self)
File “buttermanager.py”, line 131, in init
self.init_ui()
File “buttermanager.py”, line 184, in init_ui
uuid_filesystems = filesystem.filesystem.get_btrfs_filesystems()
File “/snap/buttermanager/x1/buttermanager/filesystem/filesystem.py”, line 298, in get_btrfs_filesystems
commandline_output = util.utils.execute_command(command, root=True)
File “/snap/buttermanager/x1/buttermanager/util/utils.py”, line 181, in execute_command
if exist_program(single_command, root=root):
File “/snap/buttermanager/x1/buttermanager/util/utils.py”, line 301, in exist_program
result = subprocess.Popen(command.split(), stdin=echo.stdout, stdout=subprocess.PIPE)
File “/snap/buttermanager/x1/usr/lib/python3.5/subprocess.py”, line 947, in init
restore_signals, start_new_session)
File “/snap/buttermanager/x1/usr/lib/python3.5/subprocess.py”, line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied
Aborted (core dumped)

As you can see, there is a permission denied error, and I think it is caused in line 298 of filesystem.sy python module. It is trying to execute “sudo -S btrfs filesystem show” command and it fails. I think this is the problem. This application needs to execute several commands (basically it is a GUI wrapper for commands you can use to manage and display BTRFS filesystems). Is there any interface I can do for achieving this or the only solution is classic confinement?

Thank you very much!