[Release] wrt-installer_0.1.39
[framework/web/wrt-installer.git] / src / jobs / widget_install / task_install_ospsvc.cpp
index 3d1b901..7909c26 100644 (file)
@@ -28,6 +28,7 @@
 #include <dpl/errno_string.h>
 #include <dpl/foreach.h>
 #include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/utils/bash_utils.h>
 
 #include <widget_install/job_widget_install.h>
 #include <widget_install/widget_install_context.h>
@@ -54,7 +55,8 @@ void TaskInstallOspsvc::StepInstallOspService()
     LogInfo("Step: installation for osp service");
 
     std::ostringstream commStr;
-    commStr << OSP_INSTALL_STR << m_context.locations->getPackageInstallationDir();
+    commStr << OSP_INSTALL_STR << BashUtils::escape_arg(
+        m_context.locations->getPackageInstallationDir());
     //commStr << " 2>&1";
     LogDebug("osp install command : " << commStr.str());
 
@@ -63,15 +65,25 @@ void TaskInstallOspsvc::StepInstallOspService()
     fd = popen(commStr.str().c_str(), "r");
     if (NULL == fd) {
         LogError("Failed to installtion osp service");
-        ThrowMsg(Exceptions::InstallOspsvcFailed, "Error occurs during\
+        ThrowMsg(Exceptions::InstallOspsvcFailed,
+                 "Error occurs during\
+                install osp service");
+    }
+
+    if (fgets(readBuf, MAX_BUF_SIZE, fd) == NULL)
+    {
+        LogError("Failed to installtion osp service.\
+                Inability of reading file.");
+        ThrowMsg(Exceptions::InstallOspsvcFailed,
+                "Error occurs during\
                 install osp service");
     }
-    fgets(readBuf, MAX_BUF_SIZE, fd);
     LogDebug("return value : " << readBuf);
 
     int result = atoi(readBuf);
     if (0 != result) {
-        ThrowMsg(Exceptions::InstallOspsvcFailed, "Error occurs during\
+        ThrowMsg(Exceptions::InstallOspsvcFailed,
+                 "Error occurs during\
                 install osp service");
     }