Add chmod to change the permission of the file
authorj-h.choi <j-h.choi@samsung.com>
Tue, 26 Oct 2021 06:57:10 +0000 (15:57 +0900)
committer조웅석/Common Platform Lab(SR)/Principal Engineer/삼성전자 <ws77.cho@samsung.com>
Mon, 15 Nov 2021 00:43:14 +0000 (09:43 +0900)
Change-Id: I56efe62379496138d2d197d24e8b061f8ea2f91a

NativeLauncher/util/utils.cc

index fe50c38..6958529 100644 (file)
@@ -424,10 +424,12 @@ void copySmackAndOwnership(const std::string& fromPath, const std::string& toPat
                        free(label);
                }
 
-               // change owner and groups for symbolic link.
+               // change owner, groups and mode for symbolic link.
                if (!lstat(fromPath.c_str(), &info)) {
                        if (lchown(toPath.c_str(), info.st_uid, info.st_gid) == -1)
                                _SERR("Failed to change owner and group name");
+                       if (lchmod(toPath.c_str(), info.st_mode) == -1)
+                               _SERR("Failed to change mode");
                }
        } else {
                // change smack label
@@ -438,10 +440,12 @@ void copySmackAndOwnership(const std::string& fromPath, const std::string& toPat
                        free(label);
                }
 
-               // change owner and groups for generated ni file.
+               // change owner, groups and mode for generated ni file.
                if (!stat(fromPath.c_str(), &info)) {
                        if (chown(toPath.c_str(), info.st_uid, info.st_gid) == -1)
                                _SERR("Failed to change owner and group name");
+                       if (chmod(toPath.c_str(), info.st_mode) == -1)
+                               _SERR("Failed to change mode");
                }
        }
 }