Browse Source

Add --no-daemon option to AESM

Application container runtimes, e.g. Docker and RKT, do not provide a
program manager, e.g. systemd, inside the container, and so attempting
to run AESM as a daemon will fail.   Add --no-daemon to allow running
the AESM in a container as a normal process, i.e. do not call daemon().

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Sean Christopherson 7 years ago
parent
commit
e7f0743812
1 changed files with 10 additions and 2 deletions
  1. 10 2
      psw/ae/aesm_service/source/aesm/application/main.cpp

+ 10 - 2
psw/ae/aesm_service/source/aesm/application/main.cpp

@@ -73,8 +73,16 @@ void signal_handler(int sig)
     }
 }
 
-int main() {
-    if(daemon(0, 0) < 0)
+int main(int argc, char *argv[]) {
+    // The only command line option that is supported is --no-daemon.
+    bool noDaemon = argc == 2 && (strcmp(argv[1], "--no-daemon") == 0);
+    if ((argc > 2) || (argc == 2 && !noDaemon)) {
+        AESM_LOG_INIT();
+        AESM_LOG_FATAL("Invalid command line.");
+        AESM_LOG_FINI();
+        exit(1);
+    }
+    if(!noDaemon && daemon(0, 0) < 0)
     {
         AESM_LOG_INIT();
         AESM_LOG_FATAL("Fail to set daemon.");