Skip to content
New issue

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

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

Already on GitHub? # to your account

Add apparmor profile #8635

Closed
xmedeko opened this issue Oct 26, 2024 · 9 comments · Fixed by #8636
Closed

Add apparmor profile #8635

xmedeko opened this issue Oct 26, 2024 · 9 comments · Fixed by #8636

Comments

@xmedeko
Copy link

xmedeko commented Oct 26, 2024

  • Electron-Builder Version: 25.1.8
  • Node Version: 22
  • Electron Version: 32.2.1
  • Electron Type (current, beta, nightly): current
  • Target: Linux

Ubuntu 24 installation requires AppArmor profile to be configured for the app, see

Solution is to detect OS with AppArmor and create a file in /etc/apparmor.d/<exe-name>:

# This profile allows everything and only exists to give the
# application a name instead of having the label "unconfined"

abi <abi/4.0>,
include <tunables/global>

profile <exe-name> "/opt/<install-path>/<exe-name>" flags=(unconfined) {
  userns,

  # Site-specific additions and overrides. See local/README for details.
  include if exists <local/<exe-name>
}

Note: remove this file when the app is uninstalled.

See also:

@mmaietta
Copy link
Collaborator

I can definitely get this feature implemented. Quick Q. What is this doing?

  # Site-specific additions and overrides. See local/README for details.
  include if exists <local/reqview-beta>

Do we need this line for the base AppArmor profile supplied by electron-builder?

I'll also create a configuration param appArmorProfile: string that you can use for providing your own profile.

@xmedeko
Copy link
Author

xmedeko commented Oct 27, 2024

Sorry, I put some concrete names instead of placeholder <exe-name> in the first post, I've updated it. This part should be:

include if exists <local/<exe-name>>

So, if the executable is e.g. custom-app then this line would include file /etc/apparmor.d/local/custom-app if any. So as admin of machine can put own, local AppArmor rules for the app. (You can see this pattern in many profilesshiiped with Ubuntu 24 in /etc/apparmor.d/)

Also note parentheses around path "/opt//" - is used without parentheses then spaces (and maybe some other chars) has to be escaped.

Param appArmorProfile: string is very good idea.

@shadow-light
Copy link

This won't help distributing by AppImage though right? Any idea what the path forward for AppImage is?

@Fuseteam
Copy link

@shadow-light might be idea to voice that concern here: https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/2046844

@mmaietta
Copy link
Collaborator

@shadow-light, unfortunately, due to the ephemeral nature of AppImage's being executable (and updateable) from any location presents difficulty in creating (and removal) of the apparmor-profile file. AFAIK, there are not any hooks for appimages being mounted that would allow the automatic creation of the profile file.

I'll only be able to support this on FPM-based targets

@mmaietta
Copy link
Collaborator

mmaietta commented Nov 7, 2024

This was implemented for FPM-based distributions in electron-builder v26.0.0-alpha.6

Can you please give it a test and report back if it also resolves the issue for you? (particularly helpful for confirmation since we're in an alpha release version)

@xmedeko
Copy link
Author

xmedeko commented Nov 8, 2024

👍 Works well on Ubuntu 24 (installs AppArmor profile) and Ubuntu 22 (does not install AppArmor profile) too.

@Sytten
Copy link

Sytten commented Nov 27, 2024

AFAIK this is not fixed for AppImage right?

@Fuseteam
Copy link

@Sytten indeed, as mentioned here: #8635 (comment)

mnvr added a commit to ente-io/ente that referenced this issue Jan 22, 2025
In particular,

* Electron 34 is needed to fix the Flatpak file picker issue -
  "Fixed file chooser dialogs for flaptak applications. #44681"
  electron/electron#44681

* Electron builder 26 is needed for the FPM app armour profiles
  electron-userland/electron-builder#8635 (comment)
mnvr added a commit to ente-io/ente that referenced this issue Jan 22, 2025
In particular,

* Electron 34 is needed to fix the Flatpak file picker issue -
  "Fixed file chooser dialogs for flaptak applications. #44681"
  electron/electron#44681

* Electron builder 26 is needed for the FPM app armour profiles

electron-userland/electron-builder#8635 (comment)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
5 participants