Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add AppArmor profile for Connect #43595

Merged
merged 2 commits into from
Jun 28, 2024
Merged

Add AppArmor profile for Connect #43595

merged 2 commits into from
Jun 28, 2024

Conversation

ravicious
Copy link
Member

@ravicious ravicious commented Jun 27, 2024

Fixes #43168.

There's been a breaking change in Ubuntu 24 which requires apps that construct their own sandboxes (such as Chromium) to provide a profile allowing the use of unprivileged user namespaces.

The profile I added is based on the profile for VSCode that ships with Ubuntu 24 in /etc/apparmor.d/code. It looks like this:

VSCode's profile
# 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 vscode /usr/share/code{/bin,}/code flags=(unconfined) {
  userns,

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

Tested in a VM on Ubuntu 24 and Fedora 37 (which doesn't use AppArmor). Tag build 17.0.0-dev.ravicious.1 is in progress, after which I'll test it on an actual device running Linux.

changelog: Fixed startup crash of Teleport Connect on Ubuntu 24.04 by adding an AppArmor profile

This comment was marked as outdated.

@ravicious
Copy link
Member Author

Confirmed that it works on a real device with Ubuntu 24.04. Changes to install scripts don't cause problems when uninstalling and upgrading.

@ravicious ravicious enabled auto-merge June 28, 2024 08:39
@ravicious ravicious removed the request for review from avatus June 28, 2024 08:39
Copy link
Contributor

@gzdunek gzdunek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, upgrading the app on Ubuntu 22.04 prints a following error:

$ sudo dpkg -i teleport-connect_17.0.0-dev.ravicious.1_amd64.deb 
(Reading database ... 207812 files and directories currently installed.)
Preparing to unpack teleport-connect_17.0.0-dev.ravicious.1_amd64.deb ...
Unpacking teleport-connect (17.0.0~dev.ravicious.1) over (15.4.5) ...
teleport-connect: Upgrade detected, skipping symlink operations
Setting up teleport-connect (17.0.0~dev.ravicious.1) ...
update-alternatives is /usr/bin/update-alternatives
teleport-connect: Skipping symlinking /usr/local/bin/tsh to /opt/Teleport Connect/resources/bin/tsh because /usr/local/bin/tsh already exists and it isn't a symlink.
AppArmor parser error for /etc/apparmor.d/teleport-connect in profile /etc/apparmor.d/teleport-connect at line 1: Could not open 'abi/4.0': No such file or directory
dpkg: error processing package teleport-connect (--install):
 installed teleport-connect package post-installation script subprocess returned error exit status 1
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for mailcap (3.70+nmu1ubuntu1) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu3) ...
Processing triggers for desktop-file-utils (0.26-1ubuntu3) ...
Errors were encountered while processing:
 teleport-connect

However, the new version has been installed.

@@ -0,0 +1,9 @@
abi <abi/4.0>,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There doesn't appear to be a way to write a backwards-compatible apparmor profile.

The answer to that Ask Ubuntu question links to an example from the Ubuntu Pro Client which uses a jinja template and modifies the profile based on which Ubuntu version is running. I don't think we can do that since our app isn't meant for Ubuntu only.

What we could do is first check if the given version of apparmor_parser can handle our profile (maybe with -preprocess or --skip-kernel-load --debug?) and only then copy it to apparmor.d and load it.

If apparmor_parser runs into an error when checking the profile, we don't copy the profile and emit a warning. This should let users on Ubuntu 22.04 use Connect. If there's another breaking change to AppArmor in the future, we'll notice that by the app not working due to a lack of profile.

How does that sound @gzdunek?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I can retest. Are you going to run another build? If no, then I will set up a dev environment on Ubuntu :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think testing this particular conditional branch in a VM should be enough. I already set up 20.04 myself.

@ravicious ravicious force-pushed the r7s/apparmor branch 2 times, most recently from eaa0823 to 9efcdac Compare June 28, 2024 13:49
@ravicious ravicious added this pull request to the merge queue Jun 28, 2024
@ravicious ravicious removed this pull request from the merge queue due to a manual request Jun 28, 2024
@ravicious ravicious enabled auto-merge June 28, 2024 13:57
@ravicious ravicious added this pull request to the merge queue Jun 28, 2024
Merged via the queue into master with commit 32a916c Jun 28, 2024
37 checks passed
@ravicious ravicious deleted the r7s/apparmor branch June 28, 2024 14:16
@public-teleport-github-review-bot

@ravicious See the table below for backport results.

Branch Result
branch/v14 Create PR
branch/v15 Create PR
branch/v16 Create PR

@GuillaumeCisco
Copy link

Does a release with this new version exist on the official website download page?
Thank you,

@ravicious
Copy link
Member Author

@GuillaumeCisco Not yet unfortunately. 16.0.4 and 15.4.7 will have it. 16.0.3 and 15.4.6 do have an updated Electron version though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AppArmor policy on ubuntu 24.04 + SegFault
4 participants