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

Minimize snap staging and restricted fallback editors (5.0-edge) #251

Merged

Conversation

simondeziel
Copy link
Member

@simondeziel simondeziel commented Dec 15, 2023

Backport of #224, #237, #245 (follow-up fix) and #252 (not yet merged in latest-edge).

This ensures vim is provided by the core20 base and also shrinks the snap size from 112MiB to 86MiB due to the additional stripping. Most of the size saving is due to stripping QEMU bits:

# 24322 is 5.0/stable on amd64
root@c2d:/snap/lxd# ll -h 24322/bin/qemu-* x1/bin/qemu-*
-rwxr-xr-x 1 root root  14M Jan 17  2023 24322/bin/qemu-img*
-rwxr-xr-x 1 root root  82M Jan 17  2023 24322/bin/qemu-system-x86_64*
-rwxr-xr-x 1 root root 1.9M Dec 15 21:43 x1/bin/qemu-img*
-rwxr-xr-x 1 root root  18M Dec 15 21:43 x1/bin/qemu-system-x86_64*

This also supersedes #248.

The locally built snap worked fine.

Also add logic to both nano (builtin) and vim.tiny (from
the base coreXX) to ignore any unreadable rc file.

Signed-off-by: Simon Deziel <[email protected]>
…lbacks

While this is a weak security guard rail, it prevents the user from using
the builtin editor to enter the snap's confined environment:

```
$ EDITOR=foo lxc config edit  # causes the fallback to vim.tiny from core
!bash     # gives shell access inside the snap confined env
```

From the outside it would look like:

```
root 6784  0.3  1.6 1538936 16908 pts/0 Sl 18:09 0:00 \_ /snap/lxd/x1/bin/lxc config edit
root 6808  0.1  0.4   6112  4448 pts/0  S  18:09 0:00     \_ vim.tiny /tmp/lxd_editor_3106750297.yaml
root 6816  0.0  0.3   5044  3904 pts/0  S+ 18:09 0:00         \_ bash
```

With the restricted mode, vim would refuse to shell out with:
> E145: Shell commands and some functionality not allowed in rvim

Similarly with nano (make sure there is no nano in the host):

```
$ lxc config edit
Ctrl-t + ps faux
```

In restricted mode, nano would refuse with:
> [ This function is disabled in restricted mode ]

Signed-off-by: Simon Deziel <[email protected]>
It contained include headers and other files from spice.

Signed-off-by: Simon Deziel <[email protected]>
@simondeziel simondeziel force-pushed the minimize-snap-stage-5.0-edge branch from 8e96314 to bac2f47 Compare December 15, 2023 22:17
@simondeziel simondeziel marked this pull request as ready for review December 15, 2023 22:30
@tomponline tomponline merged commit e36db82 into canonical:5.0-edge Jan 2, 2024
1 check passed
@simondeziel simondeziel deleted the minimize-snap-stage-5.0-edge branch January 2, 2024 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants