Signature configuration on
authorDongeup Ham <dongeup.ham@samsung.com>
Sat, 29 Jun 2013 07:32:49 +0000 (16:32 +0900)
committerDongeup Ham <dongeup.ham@samsung.com>
Sat, 29 Jun 2013 07:32:49 +0000 (16:32 +0900)
Change-Id: I232838f7c7eb96b91ce3f312901f519de2d191d1
Signed-off-by: Dongeup Ham <dongeup.ham@samsung.com>
inc/InstallerDefs.h
src/Step/SignatureStep.cpp
src/Step/UnpackStep.cpp
src/Util/InstallerUtil.cpp
src/Util/InstallerUtil.h

index cdf00e0..3d8dad8 100755 (executable)
@@ -23,7 +23,7 @@
 
 #include "InstallerUtil.h"
 
-#define OSP_INSTALLER_VERSION "version=[20130628.1]"
+#define OSP_INSTALLER_VERSION "version=[20130629.1]"
 
 #define DIR_BIN                                L"/bin"
 #define DIR_INFO                       L"/info"
index 4d3e87d..1ca3c40 100755 (executable)
@@ -135,9 +135,9 @@ SignatureStep::OnStateSignerInit(void)
 
        if (res == true)
        {
-               res = __pSignatureManager->ValidatePartialReferences();
-               AppLog("  ## __pSignatureManager->ValidatePartialReferences() result = [%s]", res?"true":"false");
-               fprintf(stderr, "  ## __pSignatureManager->ValidatePartialReferences() result = [%s]\n", res?"true":"false");
+//             res = __pSignatureManager->ValidatePartialReferences();
+//             AppLog("  ## __pSignatureManager->ValidatePartialReferences() result = [%s]", res?"true":"false");
+//             fprintf(stderr, "  ## __pSignatureManager->ValidatePartialReferences() result = [%s]\n", res?"true":"false");
        }
        else
        {
@@ -154,8 +154,16 @@ SignatureStep::OnStateSignerInit(void)
        }
        else
        {
-               AppLog("_pSignatureManager->ValidateSignatures() does not be passed, using another validator.");
-               GoNextState();
+               if (InstallerUtil::IsSignatureVerificationEnabled() == true)
+               {
+                       AppLog("_pSignatureManager->ValidateSignatures() is failed.");
+                       error = INSTALLER_ERROR_SIGNATURE_VERIFICATION_FAILED;
+               }
+               else
+               {
+                       AppLog("_pSignatureManager->ValidateSignatures() does not be passed, using another validator.");
+                       GoNextState();
+               }
        }
 
        return error;
index 2a50236..40c33e1 100755 (executable)
@@ -363,7 +363,7 @@ UnpackStep::RemoveRoDirectory(const String& rootPath)
                }
                else if (entryName == L"data")
                {
-                       AppLog("skip - directory[%ls]", srcEntryDir.GetPointer());
+                       AppLog("skip, directory=[%ls]", srcEntryDir.GetPointer());
                        continue;
                }
                else if (entryName == L"shared")
@@ -405,7 +405,7 @@ UnpackStep::RemoveSharedDirectory(const String& sharedPath)
                }
                else if (entryName == L"data" || entryName == L"trusted")
                {
-                       AppLog("skip - directory[%ls]", srcEntryDir.GetPointer());
+                       AppLog("skip, directory=[%ls]", srcEntryDir.GetPointer());
                        continue;
                }
 
index e07ee81..291b652 100755 (executable)
@@ -30,6 +30,7 @@
 #include <FBaseErrorDefine.h>
 #include <FIoFile.h>
 #include <FIoDirectory.h>
+#include <FIoRegistry.h>
 #include <FAppPkgPackageAppInfo.h>
 #include <FAppPkgPackageInfo.h>
 #include <FBase_StringConverter.h>
@@ -73,7 +74,7 @@ InstallerUtil::Remove(const Tizen::Base::String& filePath)
        err = lstat(pFilePath.get(), &fileinfo);
        if (err < 0)
        {
-               AppLog("Remove(): [%s] - %s[errno(%d)]: skip", pFilePath.get(), strerror(errno), errno);
+               AppLog("Remove(): skip, path=[%s][%s](%d)", pFilePath.get(), strerror(errno), errno);
                return true;
        }
 
@@ -245,7 +246,14 @@ InstallerUtil::CreateSymlink(const String& oldPath, const String& newPath, bool
        res = File::IsFileExist(oldPath);
        if (res == false)
        {
-               AppLog("CreateSymlink(): oldPath=[%ls] not found", oldPath.GetPointer());
+               AppLog("CreateSymlink(): oldPath=[%ls] not found.", oldPath.GetPointer());
+               return true;
+       }
+
+       res = File::IsFileExist(newPath);
+       if (res == true)
+       {
+               AppLog("CreateSymlink(): newPath=[%ls] is alreay exist.", oldPath.GetPointer());
                return true;
        }
 
@@ -1167,3 +1175,28 @@ InstallerUtil::IsDefaultExternalStorage()
 
        return false;
 }
+
+bool
+InstallerUtil::IsSignatureVerificationEnabled()
+{
+       result r;
+       Registry reg;
+       String section(L"feature");
+       String entry(L"signature");
+       String value;
+
+       r = reg.Construct(CONFIG_PATH, "r");
+       TryReturn(!IsFailed(r), false, "CONFIG file is not found.");
+
+       r = reg.GetValue(section, entry, value);
+       TryReturn(!IsFailed(r), false, "GetValue is failed. entry = [%ls]", entry.GetPointer());
+
+       AppLog("[%ls is %ls.]", entry.GetPointer(), value.GetPointer());
+
+       if (value == L"on")
+       {
+               return true;
+       }
+
+       return false;
+}
index 82c3d4e..9293210 100755 (executable)
@@ -93,6 +93,7 @@ public:
        static bool IsCscPackage(const Tizen::App::PackageId& packageId, Tizen::Base::String& cscInfo);
 
        static bool IsDefaultExternalStorage();
+       static bool IsSignatureVerificationEnabled();
 
 private:
        static char LogChangeHexToStr(int hex);