1 // Copyright (c) 2013 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // On Tizen installing applications requires super-user powers primarily because
6 // some pieces of information of the application are put on globally accessible
7 // locations. This helper will run with super-user powers (via suid) and will
8 // be called by Crosswalk (now running as a normal user) so all the activities
9 // that required 'root' access are done by a small code base.
11 #include "base/files/file_path.h"
12 #include "base/file_util.h"
13 #include "xwalk/application/tools/tizen/xwalk_pkg_installer.h"
17 int usage(const char* program) {
18 fprintf(stdout, "%s - Crosswalk Tizen Application Installation helper\n\n",
20 fprintf(stdout, "Usage: \n"
21 "\t%s --install <appid> <xml> <icon>\n"
22 "\t%s --uninstall <appid>\n",
29 int main(int argc, char *argv[]) {
33 return usage(argv[0]);
35 // When installing an application on Tizen, the libraries used require
36 // some steps to be run as root (UID 0) and fail otherwise, so we force
37 // this tool to assume the root UID.
39 fprintf(stderr, "Make sure '%s' is set-user-ID-root\n", argv[0]);
43 PkgInstaller installer(argv[2]);
44 if (!strcmp(argv[1], "--install")) {
46 return usage(argv[0]);
48 result = installer.InstallApplication(argv[3], argv[4]);
49 } else if (!strcmp(argv[1], "--uninstall")) {
51 return usage(argv[0]);
53 result = installer.UninstallApplication();
55 return usage(argv[0]);
58 // Convetion is to return 0 on success.
59 return result ? 0 : 1;