Merge pull request #252 from morphis/f/warn-on-cm-start

Print warning if user starts container manager manually
This commit is contained in:
Simon Fels 2017-05-11 18:35:59 +02:00 committed by GitHub
commit a21233cb38
3 changed files with 16 additions and 3 deletions

View file

@ -37,7 +37,8 @@ start() {
exec $AA_EXEC $SNAP/bin/anbox-wrapper.sh container-manager \
--data-path=$DATA_PATH \
--android-image=$ANDROID_IMG
--android-image=$ANDROID_IMG \
--daemon
}
stop() {

View file

@ -48,11 +48,22 @@ anbox::cmds::ContainerManager::ContainerManager()
flag(cli::make_flag(cli::Name{"privileged"},
cli::Description{"Run Android container in privileged mode"},
privileged_));
flag(cli::make_flag(cli::Name{"daemon"},
cli::Description{"Mark service as being started as systemd daemon"},
daemon_));
action([&](const cli::Command::Context&) {
try {
if (getuid() != 0) {
ERROR("You're not running the container-manager as root. Generally you don't");
if (!daemon_) {
WARNING("You are running the container manager manually which is most likely not");
WARNING("what you want. The container manager is normally started by systemd or");
WARNING("another init system. If you still want to run the container-manager");
WARNING("you can get rid of this warning by starting with the --daemon option.");
WARNING("");
}
if (geteuid() != 0) {
ERROR("You are not running the container-manager as root. Generally you don't");
ERROR("want to run the container-manager manually unless you're a developer");
ERROR("as it is started by the init system of your operating system.");
return EXIT_FAILURE;

View file

@ -42,6 +42,7 @@ class ContainerManager : public cli::CommandWithFlagsAndAction {
std::shared_ptr<common::LoopDevice> android_img_loop_dev_;
std::vector<std::shared_ptr<common::MountEntry>> mounts_;
bool privileged_ = false;
bool daemon_ = false;
};
} // namespace cmds
} // namespace anbox