Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
tests: add test to run snap inside lxd as a user #4230
Closed
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
1ab5b67
tests: add test to run snap inside lxd as a user
mvo5 7722c04
cmd,packaging: make snap-confine setgid root
zyga c382f9a
cmd/snap-update-ns: address review feedback
zyga 0edd01c
cmd/snap-update-ns: check real_gid too, thanks jdstrand
zyga a733fbc
interfaces: add "refresh-schedule" attribute to snapd-control
mvo5 bd5da06
interfaces/account_control: use /etc/shadow to obtain group informati…
bboozzoo 074af4c
interfaces/builtin/account_control: simplify code in SecCompConnected…
bboozzoo ead87d6
cmd/snap-update-ns: add secureMkfileAll
zyga 0c7027f
interfaces/builtin/account_control: drop group filter from seccomp rules
bboozzoo b8fd197
interfaces/builtin/account_control: add catchall group rule in fchown…
bboozzoo 28150e1
interfaces/account_control: update seccomp rule comments on chown
bboozzoo 8fdffab
interfaces/builtin/account_control: use base 10 when formatting group ID
bboozzoo 285db54
interfaces/account_control: cache seccomp snippet on first successful…
bboozzoo 5999c8d
remove commonInterface.SanitizePlug() again, YAGNI
mvo5 afe7e98
store: add support for flags in ListRefresh()
mvo5 fcae222
intefaces/builtin/account_control: leave a note that the seccomp snip…
bboozzoo 1aba545
interfaces/builtin/account_control: reformat registerIface() call
bboozzoo 7946031
Fix path in snap install
asalminen 5735b9d
snap/validate: extend socket validation tests
albertodonato 7925f2d
cmd/snap-update-ns: detect read only filesystems in SecureMkfileAll
zyga 578fd3a
cmd/snap-update-ns: tweak comment
zyga f45b4b1
cmd/snap-update-ns: add smoke test for behavior of filepath.Clean
zyga fb720e5
tests: add new `fakestore new-snap-{declaration,revision}` helpers
mvo5 633233a
cmd/snap-update-ns: tweak comment
zyga 576faba
cmd/snap-update-ns: fix typo
zyga 1930a82
cmd/snap-update-ns: document secureMkFile
zyga 6e264c2
cmd/snap-update-ns: add splitIntoSegments
zyga 56f6e60
snap/validate: add SocketMode validation and test
albertodonato 0b8a9cd
snap: add test for invalid socket-mode in YAML
albertodonato d9d8e38
cmd/snap-update-ns: tweak changePerform
zyga 554c8a9
interfaces,tests: skip unknown plug/slot interfaces
zyga f0cbb21
snap/validate: add port range validation
albertodonato ff596dd
review comments
albertodonato 612b096
address review feedback
mvo5 0b20676
Remove invalid plugs/slots from SnapInfo on sanitization.
stolowski e04d846
Addressed review feedback
stolowski 8a87db7
snap: use field names when initializing composite literals
bboozzoo 409aa13
snap: use proper helper for constructing revision in validation tests
bboozzoo c2578ab
debian: add missing udev dependency
mvo5 fcf4bfc
use struct with bools instead of bitflags (thanks Chipaca)
mvo5 5e9e0cb
address reivew feedback
mvo5 61d7acf
fakestore: print assertion name in new-snap-{decl,rev}
mvo5 fa59284
cmd/snap-update-ns: re-enable commented-out test
zyga 2497562
less disruptive adaption
pedronis be02838
cmd/snap-update-ns: switch to O_RDONLY
zyga c149809
disabling opensuse until timeout issue is fixed
sergiocazzolato 1e14158
Merge remote-tracking branch 'upstream/master' into lxd-regression-test
mvo5
Jump to file or symbol
Failed to load files and symbols.
Viewing a subset of changes. View all
cmd,packaging: make snap-confine setgid root
This patch makes snap-confine also setgid root (after being setuid-root since forever). This is required to manipulate cgroups inside LXD containers. To limit the scope of the change, snap-confine hides the setgid aspect for most of the code and only restores it for the cgroup manipulation. Forum: https://forum.snapcraft.io/t/snapcraft-adt-failures-with-the-new-core-release/2850 Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
- Loading branch information...
commit 7722c0404b97fa0ac119acb495caa62c3f5ab321
zyga
committed
Nov 16, 2017
| @@ -131,8 +131,28 @@ int main(int argc, char **argv) | ||
| debug("base snap: %s", base_snap_name); | ||
| // Who are we? | ||
| - uid_t real_uid = getuid(); | ||
| - gid_t real_gid = getgid(); | ||
| + uid_t ruid, euid, suid; | ||
| + gid_t rgid, egid, sgid; | ||
| + getresuid(&ruid, &euid, &suid); | ||
| + getresgid(&rgid, &egid, &sgid); | ||
| + debug("ruid: %d, euid: %d, suid: %d", ruid, euid, suid); | ||
| + debug("rgid: %d, egid: %d, sgid: %d", rgid, egid, sgid); | ||
|
|
||
| + | ||
| + // If we are running as group root but the real group id is not zero then | ||
| + // the setgid root permission is in effect. To limit the scope of the | ||
| + // change this is causing for the code temporairly set the effective group | ||
| + // id to the real group id. We will change that again below when we | ||
| + // manipulate the freezer cgroup. | ||
| + // Because LXD uses particular permissions for cgroups we need to be | ||
| + // group-root for that operation to succeed. | ||
| + if (euid == 0 && ruid != 0) { | ||
| + if (setegid(ruid) != 0) { | ||
| + die("cannot set effective group id to %d", ruid); | ||
| + } | ||
| + } | ||
jdstrand
Contributor
|
||
| + | ||
| + uid_t real_uid = ruid; | ||
| + gid_t real_gid = rgid; | ||
| #ifndef CAPS_OVER_SETUID | ||
| // this code always needs to run as root for the cgroup/udev setup, | ||
| @@ -226,7 +246,14 @@ int main(int argc, char **argv) | ||
| // control group. This simplifies testing if any processes | ||
| // belonging to a given snap are still alive. | ||
| // See the documentation of the function for details. | ||
| + if (setegid(0) != 0) { | ||
jdstrand
Contributor
|
||
| + die("cannot set effective group id to root"); | ||
| + } | ||
| sc_cgroup_freezer_join(snap_name, getpid()); | ||
| + if (setegid(rgid) != 0) { | ||
jdstrand
Contributor
|
||
| + die("cannot set effective group id to %d", | ||
| + rgid); | ||
| + } | ||
| sc_unlock(snap_name, snap_lock_fd); | ||
| // Reset path as we cannot rely on the path from the host OS to | ||
These extra variables to real_uid and real_gid reduce clarity. I suggest coding the whole thing like this instead (untested):