Fixed the segmentation fault in dotnettool (#437)
[platform/core/dotnet/launcher.git] / NativeLauncher / tool / dotnettool.cc
index 749ad36..4343b49 100644 (file)
@@ -18,6 +18,7 @@
 #include "ni_common.h"
 #include "tac_common.h"
 #include "profile_common.h"
+#include "privilege_common.h"
 #include "multi_target_resolver.h"
 #include "log.h"
 
@@ -54,6 +55,8 @@ void DisplayUsage() {
                "                                   (this option should be run as root)\n"
                "       --rm-all-app-profile      - Remove application profile of all packages for all users\n"
                "                                   (this option should be run as root)\n"
+               "       --check-all-app-privilege - Chcek application privilege of all package\n"
+               "                                   (this option should be run as root)\n"
                "\n"
                "Options:\n"
                "       --mibc                    - Specify Mibc files. Sepatated with ':'.\n"
@@ -70,6 +73,9 @@ void DisplayUsage() {
                "       --print-cmd               - Print command and options\n"
                "       --skip-ro-app             - Skip re-generate NI for apps installed RO area\n"
                "                                   (This option works with --ni-regen-all-app only)\n"
+               "       --rm-origin-after-ni      - Remove original dll after creating native image\n"
+               "                                   Note!: App ATOC options(--ni-pkg, --ni-regen-all-app, --tac-regen-all) cannot be used with --rm-origin-after-ni option.\n"
+               "                                   (Use only for assemblies that will not be AOTed again afterward.)"
                "\n"
                "Usage: dotnettool [options] [command] [arguments]\n"
                "\n"
@@ -128,6 +134,8 @@ int main(int argc, char* argv[])
                        opt->flags |= NI_FLAGS_PRINT_CMD;
                } else if (arg == "--skip-ro-app") {
                        opt->flags |= NI_FLAGS_SKIP_RO_APP;
+               }  else if (arg == "--rm-origin-after-ni") {
+                       opt->flags |= NI_FLAGS_RM_ORIGIN_AFTER_NI;
                } else if (arg == "--mibc") {
                        ++i;
                        if (i >= argc) {
@@ -180,6 +188,12 @@ int main(int argc, char* argv[])
                }
        }
 
+       if (args.size() == 0) {
+               _SERR("The command is missing");
+               DisplayUsage();
+               return -1;
+       }
+
        if (opt->flags & NI_FLAGS_INPUT_BUBBLE_REF && !(opt->flags & NI_FLAGS_INPUT_BUBBLE)) {
                _SERR("--inputbubbleref option should be used with --inputbubble option");
                DisplayUsage();
@@ -233,6 +247,12 @@ int main(int argc, char* argv[])
        }
        //sh-3.2# dotnettool --ni-pkg [pkgId] [pkgId] ...
        else if (cmd == "--ni-pkg") {
+               if (opt->flags & NI_FLAGS_RM_ORIGIN_AFTER_NI) {
+                       _SERR("App AOTC options cannot be used with --rm-origin-after-ni option");
+                       DisplayUsage();
+                       return -1;
+               }
+
                if (args.size() < 1) {
                        _SERR("Package name is missing");
                }
@@ -295,6 +315,12 @@ int main(int argc, char* argv[])
        }
        //sh-3.2# dotnettool --ni-regen-all-app
        else if (cmd == "--ni-regen-all-app") {
+               if (opt->flags & NI_FLAGS_RM_ORIGIN_AFTER_NI) {
+                       _SERR("App AOTC options cannot be used with --rm-origin-after-ni option");
+                       DisplayUsage();
+                       return -1;
+               }
+
                int ret = regenerateAppNI(opt);
                if (ret != NI_ERROR_NONE) {
                        _SERR("Failed to regenerate all app NI");
@@ -302,6 +328,12 @@ int main(int argc, char* argv[])
        }
        //sh-3.2# dotnettool --tac-regen-all
        else if (cmd == "--tac-regen-all") {
+               if (opt->flags & NI_FLAGS_RM_ORIGIN_AFTER_NI) {
+                       _SERR("App AOTC options cannot be used with --rm-origin-after-ni option");
+                       DisplayUsage();
+                       return -1;
+               }
+
                int ret = regenerateTACNI(opt);
                if (ret != NI_ERROR_NONE) {
                        _SERR("Failed to regenerate all TAC");
@@ -372,6 +404,10 @@ int main(int argc, char* argv[])
        else if (cmd == "--rm-all-app-profile") {
                removeAllAppProfileData();
        }
+       //sh-3.2# dotnettool --check-all-app-privilege
+       else if (cmd == "--check-all-app-privilege") {
+               checkAllAppPrivilege();
+       }
        else {
                _SERR("Unknown option [%s]", cmd.c_str());
                DisplayUsage();