Skip to content

Commit

Permalink
snap-confine: advise the user to check the snapd.apparmor service
Browse files Browse the repository at this point in the history
If the AppArmor profiles for snap-confine or snap-update-ns are not
loaded, there's a chance that this is due to the snapd.apparmor systemd
unit being disabled. Provide this information as a hint to the user.
  • Loading branch information
mardy committed Jun 6, 2022
1 parent 48ca2e1 commit 3f6b247
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 8 additions & 1 deletion cmd/libsnap-confine-private/apparmor-support.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,14 @@ sc_maybe_aa_change_onexec(struct sc_apparmor *apparmor, const char *profile)
int aa_change_onexec_errno = errno;
if (secure_getenv("SNAPPY_LAUNCHER_INSIDE_TESTS") == NULL) {
errno = aa_change_onexec_errno;
die("cannot change profile for the next exec call");
if (errno == ENOENT) {
fprintf(stderr, "missing profile %s.\n"
"Please make sure that the snapd.apparmor service is enabled\n",
profile);
exit(1);
} else {
die("cannot change profile for the next exec call");
}
}
}
#endif // ifdef HAVE_APPARMOR
Expand Down
4 changes: 3 additions & 1 deletion cmd/snap-confine/snap-confine.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,11 @@ int main(int argc, char **argv)
// id is non-root. This protects against, for example, unprivileged
// users trying to leverage the snap-confine in the core snap to
// escalate privileges.
errno = 0; // errno is insignificant here
die("snap-confine has elevated permissions and is not confined"
" but should be. Refusing to continue to avoid"
" permission escalation attacks");
" permission escalation attacks\n"
"Please make sure that the snapd.apparmor service is enabled.");
}

log_startup_stage("snap-confine mount namespace start");
Expand Down

0 comments on commit 3f6b247

Please sign in to comment.