[Title] In the case of RDS, the partial directories's permision was changed to "app...
authorGun Kim <gune.kim@samsung.com>
Wed, 6 Feb 2013 05:27:18 +0000 (14:27 +0900)
committerGun Kim <gune.kim@samsung.com>
Thu, 7 Feb 2013 05:41:29 +0000 (14:41 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: I2cb5bb61d4dfca30b346c06cb7d85167b14a8ef2

org.tizen.common/src/org/tizen/common/TizenPlatformConstants.java
org.tizen.common/src/org/tizen/common/rds/RdsDeployer.java

index 1959269..ea0ad13 100644 (file)
@@ -72,6 +72,10 @@ public class TizenPlatformConstants {
     public static final String PKG_TOOL_RUNNING_CHECK_COMMAND = PKG_TOOL + " -C -t %s -n %s";
     public static final String PKG_TOOL_TERMINATE_COMMAND = PKG_TOOL + " -k -t %s -n %s";
     public static final String PKG_TOOL_INSTALL_PATH_COMMAND = PKG_TOOL + " -a";
+    
+    // Definitions for RDS
+    public static final String RDS_PUSH_DIRECTORY_COMMAND = "mkdir -p -m 755 \"%s\""+ TizenPlatformConstants.CMD_SUFFIX;
+    public static final String RDS_CHANGE_OWNER_COMMAND = "chown -R app:app \"%s\"" + TizenPlatformConstants.CMD_SUFFIX;
 
     // Definitions for launching
     public static final String LAUNCH_CMD = "launch_app %s";
index 53e8058..3a4974f 100644 (file)
@@ -30,7 +30,9 @@ import java.io.Closeable;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.CoreException;
@@ -62,7 +64,8 @@ public abstract class RdsDeployer implements Closeable{
     protected ISdbCommandHelper tizenCommand;
     protected List<DeltaResourceInfo> interestList = new ArrayList<DeltaResourceInfo>();
     private SyncService syncService;
-    
+    private final static String[] needAppOwnerArray = new String[] {"/data", "/shared/data", "/shared/trusted", "/setting"};
+
     /**
      * Prints progress information.
      *
@@ -91,6 +94,7 @@ public abstract class RdsDeployer implements Closeable{
         this.pkgType = pkgType;
         this.strAppInstallPath = getAppInstallPath();
         deltaDetector = new RdsDeltaDetector(device, project, strAppInstallPath);
+        
     }
     
     public void setInterestList( List<DeltaResourceInfo> list) {
@@ -103,6 +107,8 @@ public abstract class RdsDeployer implements Closeable{
         String strRemotePath = null;
         String command = null;
         boolean isInteresting = false;
+        Set<String> needAppOwnerSet = new HashSet<String>();
+        
         for ( DeltaResourceInfo node : deltaInfoList ) {
             isInteresting = false;
             for ( DeltaResourceInfo interest : interestList ) {
@@ -114,6 +120,7 @@ public abstract class RdsDeployer implements Closeable{
                     else {
                         strRemotePath = strAppInstallPath + node.getFullPath().replaceFirst(strProjectPath + interest.getFullPath(), interest.getRemotePath());
                     }
+                    
                     if ( DeltaResourceInfo.TYPE_INSTALL.equals(interest.getType()) ) {
                         isNeededInstall = true;
                     }
@@ -127,7 +134,7 @@ public abstract class RdsDeployer implements Closeable{
                 try {
                     command = RdsDeployer.makeRdsLog(NLS.bind(RdsMessages.RDS_PUSH_LOG, node.getFullPath(), strRemotePath));
                     if ( new File(node.getFullPath()).isDirectory() ) {
-                        tizenCommand.runCommand( "mkdir -p -m 755 " + strRemotePath + TizenPlatformConstants.CMD_SUFFIX , true, null);
+                        tizenCommand.runCommand( String.format(TizenPlatformConstants.RDS_PUSH_DIRECTORY_COMMAND, strRemotePath), true, TizenPlatformConstants.CMD_SUCCESS);
                     }
                     else {
                         SyncResult result = getSyncService().pushFile(node.getFullPath(), strRemotePath, SyncService.getNullProgressMonitor());
@@ -135,8 +142,16 @@ public abstract class RdsDeployer implements Closeable{
                             throw new IOException(command);
                         }
                     }
-                    
                     printInfo( command );
+                    
+                    // TODO: The code is removed, if 'pkgcmd' is used to change owner.
+                    for ( String needAppOwnerPath : needAppOwnerArray) {
+                        String needAppOwnerFullPath = strAppInstallPath + needAppOwnerPath;
+                        if ( strRemotePath.startsWith( needAppOwnerFullPath ) ) {
+                            needAppOwnerSet.add(needAppOwnerFullPath);
+                            break;
+                        }
+                    }
                 } catch (Exception e) {
                     newCoreException(RdsDeployer.makeRdsLog(RdsMessages.RDS_PUSH_ERROR), e);
                 }
@@ -151,11 +166,20 @@ public abstract class RdsDeployer implements Closeable{
             }
         }
         
+        // TODO: It should be replaced to 'pkgcmd'
+        for ( String needAppOwnerPath : needAppOwnerSet ) {
+            try {
+                tizenCommand.runCommand( String.format(TizenPlatformConstants.RDS_CHANGE_OWNER_COMMAND, needAppOwnerPath) , true, TizenPlatformConstants.CMD_SUCCESS);
+            } catch (Exception e) {
+                newCoreException(RdsDeployer.makeRdsLog(RdsMessages.RDS_PUSH_ERROR), e);
+            }
+        }
+        
         if ( isNeededInstall ) {
             postInstall();
         }
     }
-    
+
     protected List<DeltaResourceInfo> getDelta() {
         return deltaDetector.getDelta(null, null);
     }