From 4ce361d9ba9c6d22131a167d81c4bfd3674bbbe7 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Fri, 14 Feb 2020 17:06:30 +0100 Subject: Issue #1441 - Guard appomni/greomni with UXP_CUSTOM_OMNI env var. This adds an addition to the environment set up for child processes (plugin container) so that it may still be able to pass the omni parameters there as-needed. --- toolkit/xre/nsAppRunner.cpp | 72 ++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 34 deletions(-) (limited to 'toolkit/xre') diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index b27e46697..d8f95c2a8 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -4131,45 +4131,49 @@ XRE_InitCommandLine(int aArgc, char* aArgv[]) delete[] canonArgs; #endif - const char *path = nullptr; - ArgResult ar = CheckArg("greomni", true, &path); - if (ar == ARG_BAD) { - PR_fprintf(PR_STDERR, - "Error: argument --greomni requires a path argument or the " - "--osint argument was specified with the --greomni argument " - "which is invalid.\n"); - return NS_ERROR_FAILURE; - } + if (PR_GetEnv("UXP_CUSTOM_OMNI")) { + // Process CLI parameters for specifying custom omnijars + const char *path = nullptr; + ArgResult ar = CheckArg("greomni", true, &path); + if (ar == ARG_BAD) { + PR_fprintf(PR_STDERR, + "Error: argument --greomni requires a path argument or the " + "--osint argument was specified with the --greomni argument " + "which is invalid.\n"); + return NS_ERROR_FAILURE; + } - if (!path) - return rv; + if (!path) + return rv; - nsCOMPtr greOmni; - rv = XRE_GetFileFromPath(path, getter_AddRefs(greOmni)); - if (NS_FAILED(rv)) { - PR_fprintf(PR_STDERR, "Error: argument --greomni requires a valid path\n"); - return rv; - } + nsCOMPtr greOmni; + rv = XRE_GetFileFromPath(path, getter_AddRefs(greOmni)); + if (NS_FAILED(rv)) { + PR_fprintf(PR_STDERR, "Error: argument --greomni requires a valid path\n"); + return rv; + } - ar = CheckArg("appomni", true, &path); - if (ar == ARG_BAD) { - PR_fprintf(PR_STDERR, - "Error: argument --appomni requires a path argument or the " - "--osint argument was specified with the --appomni argument " - "which is invalid.\n"); - return NS_ERROR_FAILURE; - } + ar = CheckArg("appomni", true, &path); + if (ar == ARG_BAD) { + PR_fprintf(PR_STDERR, + "Error: argument --appomni requires a path argument or the " + "--osint argument was specified with the --appomni argument " + "which is invalid.\n"); + return NS_ERROR_FAILURE; + } - nsCOMPtr appOmni; - if (path) { - rv = XRE_GetFileFromPath(path, getter_AddRefs(appOmni)); - if (NS_FAILED(rv)) { - PR_fprintf(PR_STDERR, "Error: argument --appomni requires a valid path\n"); - return rv; - } - } + nsCOMPtr appOmni; + if (path) { + rv = XRE_GetFileFromPath(path, getter_AddRefs(appOmni)); + if (NS_FAILED(rv)) { + PR_fprintf(PR_STDERR, "Error: argument --appomni requires a valid path\n"); + return rv; + } + } + + mozilla::Omnijar::Init(greOmni, appOmni); + } // UXP_CUSTOM_OMNI - mozilla::Omnijar::Init(greOmni, appOmni); return rv; } -- cgit v1.2.3