Add more warning logs for performance analysis on release builds 86/314186/2
authorTomasz Swierczek <t.swierczek@samsung.com>
Mon, 8 Jul 2024 07:40:50 +0000 (09:40 +0200)
committerTomasz Swierczek <t.swierczek@samsung.com>
Mon, 8 Jul 2024 09:26:02 +0000 (11:26 +0200)
Change-Id: Ie83e2768d4da2208e1e4666b2c1969b2c38e2a6a

src/common/service_impl.cpp

index 71e748c35299aa63b35dabcdaf4b617f69988278..9c8ae492a12a91a73b5561b06aa2483f42962506 100644 (file)
@@ -361,11 +361,13 @@ int ServiceImpl::labelPaths(const pkg_paths &paths,
             return ret;
         }
 
+        LogWarning("Determinig if paths are legal");
         // check if paths are inside of legal directories
         if (!pathsCheck(paths, pkgLegalBaseDirs))
             return SECURITY_MANAGER_ERROR_NOT_PATH_OWNER;
 
         if (isSharedRO) {
+            LogWarning("Labeling shared_ro paths");
             // Label shared_ro base paths for bind mounting
             labelSharedPaths(homePath, pkgName);
             // If there are corresponding paths in skel, label them too
@@ -373,12 +375,14 @@ int ServiceImpl::labelPaths(const pkg_paths &paths,
                 labelSharedPaths(skelDir, pkgName);
         }
         // register paths
+        LogWarning("Labeling other paths");
         for (const auto &pkgPath : paths) {
             const std::string &path = pkgPath.first;
             app_install_path_type pathType = static_cast<app_install_path_type>(pkgPath.second);
             SmackLabels::setupPath(pkgName, path, pathType, authorHash);
         }
 
+        LogWarning("Labeling base paths");
         for (const auto &basePath : pkgLegalBaseDirs) {
             if (containSubDir(basePath, paths)) {
                 SmackLabels::setupPkgBasePath(basePath);
@@ -568,6 +572,7 @@ int ServiceImpl::appInstall(const Credentials &creds, app_inst_req &req)
 
     try {
         // initial checks
+        LogWarning("appInstall started for pkg " <<  req.pkgName << ", checking package in DB started...");
         ret = appInstallInitialChecks(creds, req);
         if (ret != SECURITY_MANAGER_SUCCESS)
             return ret;
@@ -594,12 +599,15 @@ int ServiceImpl::appInstall(const Credentials &creds, app_inst_req &req)
 
         for (auto &app : req.apps) {
             // [db] add app
+            LogWarning("Adding privileges for app " << app.appName << " into security-manager's db");
             appInstallPrivileges(app, req, ih);
             // [cynara] update app policy
+            LogWarning("Configuring privileges for app " << app.appName << " in cynara");
             appInstallCynaraPolicies(app, req, ih);
         }
 
         // [db] update shared ro
+        LogWarning("Configuring SharedRO status");
         bool isAppSharedRO = isSharedRO(req.pkgPaths);
         if (isAppSharedRO)
             m_privilegeDb.SetSharedROPackage(req.pkgName);
@@ -608,6 +616,7 @@ int ServiceImpl::appInstall(const Credentials &creds, app_inst_req &req)
         trans.commit();
         LogDebug("Application installation commited to database");
 
+        LogWarning("Configuring permissible file");
         Smack::Labels newLabels;
         getPkgLabels(req.pkgName, newLabels);
 
@@ -615,6 +624,7 @@ int ServiceImpl::appInstall(const Credentials &creds, app_inst_req &req)
         tryUpdatePermissibleFile(req.uid, req.installationType, newLabels, oldLabels);
 
         // label paths
+        LogWarning("Configuring package paths");
         ret = labelPaths(req.pkgPaths,
                          req.pkgName,
                          static_cast<app_install_type>(req.installationType),
@@ -624,7 +634,9 @@ int ServiceImpl::appInstall(const Credentials &creds, app_inst_req &req)
             return ret;
 
         // apply and merge Smack rules for apps and pkg
+        LogWarning("Configuring smack rules for package");
         ret = appInstallSmackRules(req, ih);
+        LogWarning("End of app registration in security-manager (server side)");
         return ret;
     } catch (const PrivilegeDb::Exception::IOError &e) {
         LogError("Cannot access application database: " << e.DumpToString());
@@ -664,6 +676,7 @@ int ServiceImpl::appUpdate(const Credentials &creds, app_inst_req &req)
 
     try {
         // initial checks
+        LogWarning("appUpdate started for pkg " <<  req.pkgName << ", checking package in DB started...");
         ret = appInstallInitialChecks(creds, req);
         if (ret != SECURITY_MANAGER_SUCCESS)
             return ret;
@@ -675,6 +688,7 @@ int ServiceImpl::appUpdate(const Credentials &creds, app_inst_req &req)
         Smack::Labels oldLabels;
 
         if (ih.isUserPkgInstalled) {
+            LogWarning("Package already installed, need to remove some packages");
             getPkgLabels(req.pkgName, oldLabels);
             // search for installed apps in the request
             std::vector<std::string> requestedApps;
@@ -701,6 +715,7 @@ int ServiceImpl::appUpdate(const Credentials &creds, app_inst_req &req)
                     app_inst_req::app tmpApp;
                     tmpApp.appName = appName;
                     reqUninstall.apps.push_back(tmpApp);
+                    LogWarning("app to uninstall: " << appName);
                 }
                 appUninstall(creds, reqUninstall);
             }
@@ -711,12 +726,15 @@ int ServiceImpl::appUpdate(const Credentials &creds, app_inst_req &req)
 
         for (auto &app : req.apps) {
             // [db] add app
+            LogWarning("Adding privileges for app " << app.appName << " into security-manager's db");
             appInstallPrivileges(app, req, ih);
             // [cynara] update app policy
+            LogWarning("Configuring privileges for app " << app.appName << " in cynara");
             appInstallCynaraPolicies(app, req, ih);
         }
 
         // [db] update shared ro
+        LogWarning("Configuring SharedRO status");
         bool isAppSharedRO = isSharedRO(req.pkgPaths);
         m_privilegeDb.SetSharedROPackage(req.pkgName, isAppSharedRO);
 
@@ -729,9 +747,11 @@ int ServiceImpl::appUpdate(const Credentials &creds, app_inst_req &req)
         getPkgLabels(req.pkgName, newLabels);
 
         // update permissible set
+        LogWarning("Configuring permissible file");
         tryUpdatePermissibleFile(req.uid, req.installationType, newLabels, oldLabels);
 
         // label paths
+        LogWarning("Configuring package paths");
         ret = labelPaths(req.pkgPaths,
                          req.pkgName,
                          static_cast<app_install_type>(req.installationType),
@@ -741,7 +761,9 @@ int ServiceImpl::appUpdate(const Credentials &creds, app_inst_req &req)
             return ret;
 
         // apply and merge Smack rules for apps and pkg
+        LogWarning("Configuring smack rules for package");
         ret = appInstallSmackRules(req, ih);
+        LogWarning("End of app registration in security-manager (server side)");
         return ret;
     } catch (const PrivilegeDb::Exception::IOError &e) {
         LogError("Cannot access application database: " << e.DumpToString());