Change not to failed when kernel has no audit features 53/176453/2
authorSungbae Yoo <sungbae.yoo@samsung.com>
Thu, 19 Apr 2018 09:20:00 +0000 (18:20 +0900)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Tue, 24 Apr 2018 14:59:48 +0000 (14:59 +0000)
When an initialization of audit socket failed,
Just not initialize all functions of daemon.

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Change-Id: I6e3cde3adaddbf59050f1e0d4c2683f7a8daff6c

lib/client.cpp
server/server.cpp

index b6d879ee19ff50eebe3a2d6edc4cda551b444a0a..620053dd91870f014163a98d1593fb4f619a81e5 100644 (file)
@@ -62,7 +62,6 @@ int AuditTrailContext::subscribeNotification(const std::string& name,
                return client->subscribe<std::string, int>
                                                        (SUBSCRIBER_REGISTER, name, listener);
        } catch (runtime::Exception& e) {
-               std::cout << e.what() << std::endl;
                return -1;
        }
 }
index d4202a3ccc9342037876b572a57cc565b69e5e81..a1e50cfc71046fd5597d00e47096de4c291b1b10 100644 (file)
@@ -43,6 +43,15 @@ Server::Server() :
 
        service->setPrivilegeChecker(std::bind(&Server::checkPeerPrivilege, this, _1, _2));
 
+       try {
+               audit.reset(new Audit());
+       } catch (runtime::Exception &e) {
+               std::cout << "Kernel has no audit feature the follows" << std::endl;
+               std::cout << " - CONFIG_AUDIT, CONFIG_AUDITSYSCALL" << std::endl;
+               // Just not initialize classes and methods if kernel has no feature
+               return;
+       }
+
        service->expose(this, "", (runtime::FileDescriptor)(Server::registerNotificationSubscriber)(std::string));
        service->expose(this, "", (int)(Server::unregisterNotificationSubscriber)(std::string, int));
 
@@ -59,8 +68,6 @@ Server::Server() :
                return true;
        });
 
-       audit.reset(new Audit());
-
        audit->setEnabled(1);
        audit->setPID(::getpid());