add User execute label for wrt-loader
authorCho Woong Suk <ws77.cho@samsung.com>
Mon, 25 Jul 2016 07:46:58 +0000 (16:46 +0900)
committerJongHeon Choi <j-h.choi@samsung.com>
Mon, 25 Jul 2016 10:12:31 +0000 (19:12 +0900)
Change-Id: Ifb239cf3818e844501dc73a04d0a11443e975612

loader/loader.gyp [new file with mode: 0644]
loader/wrt_loader.cc [new file with mode: 0644]
packaging/crosswalk-tizen.manifest
packaging/crosswalk-tizen.spec
runtime/browser/runtime_process.cc
runtime/runtime.gyp
xwalk_tizen.gyp

diff --git a/loader/loader.gyp b/loader/loader.gyp
new file mode 100644 (file)
index 0000000..baa7456
--- /dev/null
@@ -0,0 +1,22 @@
+{
+  'includes':[
+    '../build/common.gypi',
+  ],
+  'targets': [
+    {
+      'target_name': 'wrt-loader',
+      'type': 'executable',
+      'sources': [
+        'wrt_loader.cc',
+      ],
+      'variables': {
+        'packages': [
+          'dlog',
+        ],
+      },
+      'libraries' : [
+        '-ldl',
+      ],      
+    }, # end of target 'wrt-loader'
+  ],
+}
diff --git a/loader/wrt_loader.cc b/loader/wrt_loader.cc
new file mode 100644 (file)
index 0000000..6696498
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+#include <dlfcn.h>
+#include <dlog.h>
+
+// loader file must have "User" execute label, because launchpad daemon runs 
+// with "System::Privileged" label.
+int main(int argc, char* argv[]) {
+  void* handle = dlopen("/usr/bin/xwalk_runtime", RTLD_LAZY);
+  if (!handle) {
+    dlog_print(DLOG_DEBUG, "XWALK", "Error loading xwalk_runtime");
+    return false;
+  }
+
+  typedef int (*MAIN_FUNC)(int argc, char* argv[]);
+
+  MAIN_FUNC real_main = reinterpret_cast<MAIN_FUNC>(dlsym(handle, "main"));
+  if (!real_main) {
+    dlog_print(DLOG_DEBUG, "XWALK", "Error loading real_main");
+    return false;      
+  }
+
+  int ret = real_main(argc, argv);
+  dlclose(handle);
+
+  return ret;
+}
index 75b0fa5..87c6236 100644 (file)
@@ -2,4 +2,7 @@
     <request>
         <domain name="_"/>
     </request>
+    <assign>
+        <filesystem path="/usr/bin/wrt-loader" exec_label="User" />
+    </assign>
 </manifest>
index 523d7da..a0f33f6 100755 (executable)
@@ -154,7 +154,6 @@ install -p -m 644 out/Default/gen/splash_screen.json %{buildroot}%{extension_pat
 # xwalk_runtime
 install -p -m 755 out/Default/xwalk_runtime %{buildroot}%{_bindir}
 ln -s %{_bindir}/xwalk_runtime %{buildroot}%{_bindir}/wrt
-ln -s %{_bindir}/xwalk_runtime %{buildroot}%{_bindir}/wrt-loader
 
 # xwalk extension shared
 install -p -m 644 out/Default/lib/libxwalk_extension_shared.so %{buildroot}%{_libdir}
@@ -168,6 +167,9 @@ install -p -m 644 out/Default/gen/*.edj %{buildroot}%{_datadir}/edje/xwalk
 # xwalk_injected_bundle
 install -p -m 755 out/Default/lib/libxwalk_injected_bundle.so %{buildroot}%{_libdir}
 
+# wrt-loader
+install -p -m 755 out/Default/wrt-loader %{buildroot}%{_bindir}
+
 %clean
 rm -fr %{buildroot}
 
index fd63a6c..b92a23f 100755 (executable)
@@ -136,6 +136,7 @@ int real_main(int argc, char* argv[]) {
   return EXIT_SUCCESS;
 }
 
+__attribute__((visibility("default")))
 int main(int argc, char* argv[]) {
   if (strcmp(argv[0], "/usr/bin/wrt-loader") == 0) {
     elm_init(argc, argv);
index d3a2299..3802152 100755 (executable)
@@ -46,6 +46,9 @@
         'browser/preload_manager.h',
         'browser/preload_manager.cc',
       ],
+      'ldflags': [
+        '-pie',
+      ],
       'variables': {
         'packages': [
           'capi-appfw-application',
index caf8a2c..4c6f3a9 100644 (file)
@@ -7,6 +7,7 @@
         'common/common.gyp:*',
         'extensions/extensions.gyp:*',
         'runtime/runtime.gyp:*',
+        'loader/loader.gyp:*',
       ],
     }, # end of target 'xwalk_tizen'
   ], # end of targets