Giter Club home page Giter Club logo

sailjail-permissions's Introduction

Sailfish OS application sandboxing and permissions

Sailfish OS application sandboxing and permissions system is build on top of Firejail. The Firejail documentation can be found from here.

The Sailfish OS application permissions are applicable only to sandboxed applications. Target is to have application sandboxing enforced to all applications but currently we are not there yet. Note that permission system is only available for 1st and 2nd party application developers.

Application launch happens via standard desktop file that has been augmented so that it contains necessary metadata (such as a list of requested permissions) and Sailjail launcher is used to execute the application binary.

Permissions that an application can request are defined in this package, in terms of files containing standard Firejail directives and Sailfish OS specific metadata.

Enable sandboxing for an application

There are few changes needed for an application in order to run it in a sandbox.

Desktop file changes

Let's go through needed changes via an example.

[Desktop Entry]
Type=Application
Name=MyApplication
Icon=my-app-icon
Exec=/usr/bin/sailjail -p org.foobar.myapp.desktop /usr/bin/org.foobar.myapp
[X-Sailjail]
Permissions=Internet;Pictures
OrganizationName=org.foobar
ApplicationName=myapp

For Exec line use sailjail to start the application, pass the file name of the desktop file, and refer to the application binary with the full path.

To declare permissions and data directories you need to add X-Sailjail section to the desktop file. Under the X-Sailjail section add

Keyword Description
Permissions Semi-colon separated list of requested permissions
OrganizationName Application development organization
ApplicationName Application data folder

Permissions are listed later in the document. They grant access to certain data paths, D-Bus interfaces, socket types and application binaries. Currently applications must define all needed permissions in desktop file and all of them are granted at launch.

OrganizationName and ApplicationName is used for granting for the application write access to

  1. $HOME/.local/share/<OrganizationName>/<ApplicationName>
  2. $HOME/.cache/<OrganizationName>/<ApplicationName>
  3. $HOME/.config/<OrganizationName>/<ApplicationName>

Access above directories from the application through QStandardPaths

  1. Application data location - QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)
  2. Application cache location - QStandardPaths::writableLocation(QStandardPaths::CacheLocation)
  3. Application config location - QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)

Only these directories can be used for storing application specific data that needs to persist over application restarts.

Use correct application data directories

Modify Qt application main function by setting the organization and application name to match the declaration added to the desktop file.

QScopedPointer<QGuiApplication> app(Sailfish::createApplication(argc, argv));
...
app->setOrganizationName(QStringLiteral("org.foobar"));
app->setApplicationName(QStringLiteral("myapp"));
...

When Sailfish App library (libsailfishapp) is used these values are set automatically to the values set in desktop file.

Files shared with other applications

Directories under user home such as Documents, Downloads, Music, Pictures and Videos contain files that are available for applications with respective permissions. Those directories must be used when the data needs to be accessible by other applications.

If application doesn't have a permission for a directory, all data in that directory will be hidden and the application sees only an empty read-only directory in that path. This allows to regular file access checks to function in expected way.

Permissions

Permissions that applications may use (names are subject to change):

Permission Description
Accounts Using accounts, including editing them. Syncing accounts.
Ambience Set and edit ambiences.
AppLaunch Launching and stopping systemd services. This is usually needed for background tasks.
ApplicationInstallation Installing and uninstalling applications.
Audio Playing and recording audio (since Pulseaudio streams cannot be separated both are enabled with this, but it is subject to change), changing audio configuration and showing audio controls on lockscreen.
Bluetooth Connecting to and using Bluetooth hardware.
Calendar Display and editing of calendar events.
CallRecordings Access recorded calls.
Camera Access to camera hardware to take photos or video.
CommunicationHistory Access call and message history.
Contacts Display and editing of contacts data. Access to contact cards.
Documents Access to Documents directory.
Downloads Access to Downloads directory.
Email Reading and sending emails. Access to email attachments.
Internet Using data connection and connecting to internet.
Location Use GPS and positioning.
MediaIndexing Access to Tracker to list files on device. If you have access to a data directory, you may want to use also this.
Messages Access to message data and to send SMS messages.
Microphone Record audio with microphone. Use Audio permission for playback of the recorded audio (but since Pulseaudio streams cannot be separated this enables also audio playback, which is subject to change).
Music Access to Music directory, playlists and coverart cache.
NFC Connecting to and using NFC hardware.
Phone Make Phone calls, either directly or through system voice call UI.
Pictures Access to Pictures directory and thumbnails.
PublicDir  Access to Public directory.
RemovableMedia Use memory cards and USB sticks.
Sharing Use of sharing pages in the application to share data via Bluetooth, email or other accounts.
Synchronization Access to synchronization framework.
UserDirs Access to Documents, Downloads, Music, Pictures, Public and Video directories.
Videos Access to Videos directory and thumbnails.
WebView If you use Gecko based WebView you need this.

Internal permissions that applications generally should not use directly:

Permission Description
Base Base set of permissions that every application is granted implicitly.
CaptivePortal
Connman
GnuPG
FingerprintSensor
Notifications
PinQuery
Sensors
Thumbnails
UDisks Permissions to call UDisks functions, includes UDisksListen.
UDisksListen Permissions to listen signals and property changes on UDisks2 interfaces.

Permission metadata format

The metadata is used to generate translations build time and to display useful information on UI about the permissions.

Permission files have metadata in their comments. Each metadata line begins with comment character '#' and key that begins with x-sailjail- followed by '=' character and the value. Below you can find the keys that permissions should define.

Keyword Description
x-sailjail-translation-catalog This key defines Qt translation catalog name which translations for the metadata should be retrieved from
x-sailjail-translation-key-description This key defines translation key for short description
x-sailjail-description This key defines engineering english text for short description
x-sailjail-translation-key-long-description This key defines translation key for long description
x-sailjail-long-description This key defines engineering english text for long description.

sailjail-permissions's People

Contributors

tomin1 avatar rainemak avatar pvuorela avatar laakkonenjussi avatar spiiroin avatar abranson avatar llewelld avatar adenexter avatar blammit avatar mkenttala avatar mlehtima avatar notkit avatar dcaliste avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.