diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-08-24 23:00:13 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-09-03 18:59:05 -0700 |
commit | a5c3034fa7089ae680b3b95da33936870f7b493f (patch) | |
tree | 917a3b816dfb73a8d61a2647bae5d586d647f6b9 /src | |
parent | 024f268d634159849e642e7005871739c428524d (diff) |
swap: refuse start/stop of swaps in container
Diffstat (limited to 'src')
-rw-r--r-- | src/core/swap.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/core/swap.c b/src/core/swap.c index cd4d9ab3d7..41ece2708f 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -39,6 +39,7 @@ #include "exit-status.h" #include "def.h" #include "path-util.h" +#include "virt.h" static const UnitActiveState state_translation_table[_SWAP_STATE_MAX] = { [SWAP_DEAD] = UNIT_INACTIVE, @@ -797,6 +798,9 @@ static int swap_start(Unit *u) { assert(s->state == SWAP_DEAD || s->state == SWAP_FAILED); + if (detect_container(NULL) > 0) + return -EPERM; + s->result = SWAP_SUCCESS; swap_enter_activating(s); return 0; @@ -817,6 +821,9 @@ static int swap_stop(Unit *u) { assert(s->state == SWAP_ACTIVATING || s->state == SWAP_ACTIVE); + if (detect_container(NULL) > 0) + return -EPERM; + swap_enter_deactivating(s); return 0; } |