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

[WIP] many: non-setuid snap-confine, caps v4 #15094

Draft
wants to merge 36 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
12f815c
cmd/snap-confine: update cgroup code to run under an ordinary user
mardy Nov 10, 2022
66ba243
snap-confine: create helper function to set capabilities
mardy Nov 9, 2022
d97d182
libsnap-confine-private: add more capability-related methods
mardy Nov 10, 2022
61b4cc8
cmd/snap-confine: drop setuid and use capabilities instead
mardy Nov 10, 2022
c379864
snap-confine: get the current working directory as a user
mardy Nov 10, 2022
c207b68
cmd/snap-confine: add a few debug checkpoints for capabilities
mardy Nov 10, 2022
af0a3a4
snap-confine: update apparmor profile for capability support
mardy Nov 10, 2022
eeaec37
cmd/snap-update-ns: explicitly specify ownership of mount profile
mardy Nov 10, 2022
9da1bc8
snap-confine: move AppArmor check earlier
mardy Nov 15, 2022
461ae9a
snap-confine: remove calls to sc_set_effective_identity()
mardy Nov 8, 2022
87cd9ae
packaging: set capabilities
Meulengracht Jan 2, 2024
4385c73
cmd/make: setcap capabilities when using 'hack' target
bboozzoo Feb 21, 2025
b4b97b8
cmd/make: install-exec-hook is no longer needed
bboozzoo Feb 21, 2025
b18f4a5
cmd/snap-confine: raise root privileges before creating the cgroup fr…
bboozzoo Jan 23, 2025
0e99a15
snapcraft: set snap-confine capabilities
bboozzoo Jan 24, 2025
51f4099
tests/main/snap-confine-caps: verify snap-confine file capabilities
bboozzoo Feb 18, 2025
382ce05
snapcraft: workaround snap pack xattr support HACK
bboozzoo Feb 18, 2025
34613bd
github: snap-builds: use fakeroot when extracting
bboozzoo Feb 18, 2025
26649d9
cmd/libsnap-confine-private: mkdir(at) & chmod helpers
bboozzoo Feb 19, 2025
e29ebbc
cmd/configure: check whether libcap supports cap_set_ambient
bboozzoo Feb 21, 2025
704b6d2
cmd: provide alternative cap_set_ambient, cap_reset_ambient
bboozzoo Feb 20, 2025
804bcc1
cmd/snap-confine/mount: TODOs
bboozzoo Feb 21, 2025
4d5fc9a
cmd/libsnap-confine-private: nonsetuid TODO
bboozzoo Feb 21, 2025
1e9564e
cmd/snap-confine: consolidate on using libcap and smart capability ha…
bboozzoo Feb 21, 2025
162e8b7
data/selinux: update SELinux policy
bboozzoo Feb 21, 2025
149f4fb
cmd/libsnap-confine-private/tool: do not change identity when switchi…
bboozzoo Feb 25, 2025
ee9ac50
cmd/snap-update-ns/bootstrap: verify capabilities, no uid switching
bboozzoo Feb 25, 2025
91e4949
cmd/snap-confine: drop unnecessary s-u-n caps
bboozzoo Feb 25, 2025
375e233
cmd/libsnap-confine-private/privs: simplify dropping privileges
bboozzoo Feb 25, 2025
6af630a
cmd/snap-discard-ns: asssert process capabilities
bboozzoo Feb 26, 2025
0159d2c
cmd/libsnap-confine-private/tool: no identity change when invokign sn…
bboozzoo Feb 26, 2025
db89a7f
tests/main/progress: collect verbose debug log from socat
bboozzoo Feb 26, 2025
bd9a522
fixup! tests/main/snap-confine-caps: verify snap-confine file capabil…
bboozzoo Feb 26, 2025
cf31fea
fixup! data/selinux: update SELinux policy
bboozzoo Feb 26, 2025
fb92de0
tests/main/snap-quota: explicitly remove all created groups during re…
bboozzoo Feb 26, 2025
c304154
tests/main/snap-confine-undesired-mode-group: fix wording and checks
bboozzoo Feb 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
snap-confine: get the current working directory as a user
Read the process state (for the time being, that's just the current
working directory) as the real user who started the application, because
if we do this operation while we are setuid root, it would fail on some
filesystems (like SSHFS and NFS) which restrict access to the root user.
  • Loading branch information
mardy authored and bboozzoo committed Feb 26, 2025
commit c379864c1a7d328ade19568e7041ea765dc0d39f
10 changes: 5 additions & 5 deletions cmd/snap-confine/snap-confine.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,6 @@ int main(int argc, char **argv) {
args = sc_nonfatal_parse_args(&argc, &argv, &err);
sc_die_on_error(err);

// Remember certain properties of the process that are clobbered by
// snap-confine during execution. Those are restored just before calling
// execv.
sc_preserve_and_sanitize_process_state(&proc_state);

// We've been asked to print the version string so let's just do that.
if (sc_args_is_version_query(args)) {
printf("%s %s\n", PACKAGE, PACKAGE_VERSION);
Expand Down Expand Up @@ -407,6 +402,11 @@ int main(int argc, char **argv) {
sc_set_ambient_capabilities(snap_update_ns_caps);
}

// Remember certain properties of the process that are clobbered by
// snap-confine during execution. Those are restored just before calling
// execv.
sc_preserve_and_sanitize_process_state(&proc_state);

char *snap_context SC_CLEANUP(sc_cleanup_string) = NULL;
// Do no get snap context value if running a hook (we don't want to overwrite hook's SNAP_COOKIE)
if (!sc_is_hook_security_tag(invocation.security_tag)) {
Expand Down