/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* * The contents of this file are subject to the Netscape Public License * Version 1.0 (the "NPL"); you may not use this file except in * compliance with the NPL. You may obtain a copy of the NPL at * http://www.mozilla.org/NPL/ * * Software distributed under the NPL is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL * for the specific language governing rights and limitations under the * NPL. * * The Initial Developer of this code under the NPL is Netscape * Communications Corporation. Portions created by Netscape are * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. */ #include "prlog.h" #include "nsTarget.h" #include "nsPrivilegeManager.h" #include "nsPrincipalManager.h" #include "nsUserTarget.h" #include "nsUserDialogHelper.h" #include "xp.h" #include "xpgetstr.h" #include "plhash.h" /* XXXXXXXX Begin oF HACK */ /* XXX: This array must be kept in sync with the allxpstr.h. * The following is hack until we have a design on removal of allxpstr.h */ char *capsTargetStrings[] = { "low", "medium", "high", "#aaffaa", "#ffffaa", "#ffaaaa", "http://home.netscape.com/eng/mozilla/4.0/handbook/", "Reading files stored in your computer", "Reading any files stored on hard disks or other storage media connected to your computer.", "#FileRead", "Modifying files stored in your computer", "Modifying any files stored on hard disks or other storage media connected to you computer.", "#FileWrite", "Deleting files stored in your computer", "Deletion of any files stored on hard disks or other storage media connected to your computer.", "#FileDelete" "Access to impersonate as another application", "Access to impersonate as another application", "#Impersonator", "Access to browser data", "Access to browser data that may be considered private, such as a list of web sites visited or the contents of web page forms you may have filled in.", "#BrowserRead", "Modifying the browser", "Modifying the browser in a potentially dangerous way, such as creating windows that may look like they belong to another program or positioning windows anywhere on the screen.", "#BrowserWrite", "Reading or modifying browser data", "Reading or modifying browser data that may be considered private, such as a list of web sites visited or the contents of web forms you may have filled in. Modifications may also include creating windows that look like they belong to another program or positioning windowsanywhere on the screen.", "#BrowserAccess", "Reading preferences settings", "Access to read the current settings of your preferences.", "#PrefsRead", "Modifying preferences settings", "Modifying the current settings of your preferences.", "#PrefsWrite", "Sending email messages on your behalf", "Sending email messages on your behalf", "#SendMail", "Access to the vendor's portion of your computer's registry of installed software", "Most computers store information about installed software, such as version numbers, in a registry file. When you install new software, the installation program sometimes needs to read or change entries in the portion of the" "registry that describes the software vendor's products. You should grant " "this form of access only if you are installing new software from a reliable " "vendor. The entity that signs the software can access only that entity's " "portion of the registry.", "#RegPrivate", "Access to shared information in the computer's registry of installed software", "Most computers store information about installed software, such as version " "numbers, in a registry file. This file also includes information shared by " "all programs installed on your computer, including information about the user " "or the system. Programs that have access to shared registry information can " "obtain information about other programs that have the same access. This allows " "programs that work closely together to get information about each other. " "You should grant this form of access only if you know that the program " "requesting it is designed to work with other programs on your hard disk.", "#RegStandard", "Access to any part of your computer's registry of installed software", "Most computers store information about installed software, such as version " "numbers, in a registry file. System administrators sometimes need to change " "entries in the registry for software from a variety of vendors. You should " "grant this form of access only if you are running software provided by your " "system administrator.", "#RegAdmin", "Access required to setup and configure your browser", "Access to, and modification of, browser data, preferences, files, networking " "and modem configuration. This access is commonly granted to the main setup " "program for your browser.", "#AccountSetup", "Access to the site archive file", "Access required to add, modify, or delete site archive files and make " "arbitrary network connections in the process. This form of access is required " "only by netcasting applications such as Netscape Netcaster, which request it " "in combination with several other kinds of access. Applications should not " "normally request this access by itself, and you should not normally grant it.", "#SiteArchive", "Displaying text or graphics anywhere on the screen", "Displaying HTML text or graphics on any part of the screen, without window " "borders, toolbars, or menus. Typically granted to invoke canvas mode, screen " "savers, and so on.", "#CanvasAccess", "Reading, modification, or deletion of any of your files", "This form of access is typically required by a program such as a word " "processor or a debugger that needs to create, read, modify, or delete files " "on hard disks or other storage media connected to your computer.", "#FileAccess", "Uninstall software", "Access required for automatic removal of previously installed software.", "#Uninstall", "Installing and running software on your computer", "Installing software on your computer's hard disk. An installation " "program can also execute or delete any software on your computer. " "You should not grant this form of access unless you are installing or " "updating software from a reliable source.", "#SoftwareInstall", "Installing and running software without warning you", "Installing software on your computer's main hard disk without giving you any " "warning, potentially deleting other files on the hard disk. Any software on the " "hard disk may be executed in the process. This is an extremely dangerous form " "of access. It should be granted by system administrators only.", "#SilentInstall", "Complete access to your computer for java programs", "Complete access required by java programs to your computer, such as Java " "Virtual machine reading, writing, deleting information from your disk, " "and to send receive and send information to any computer on the Internet.", "#AllJavaPermission", "Access to all Privileged JavaScript operations", "Access to all Privileged JavaScript operations.", "#AllJavaScriptPermission", }; typedef enum CAPS_TARGET { CAPS_TARGET_RISK_STR_LOW, CAPS_TARGET_RISK_STR_MEDIUM, CAPS_TARGET_RISK_STR_HIGH, CAPS_TARGET_RISK_COLOR_LOW, CAPS_TARGET_RISK_COLOR_MEDIUM, CAPS_TARGET_RISK_COLOR_HIGH, CAPS_TARGET_HELP_URL, CAPS_TARGET_DESC_FILE_READ, CAPS_TARGET_DETAIL_DESC_FILE_READ, CAPS_TARGET_URL_FILE_READ, CAPS_TARGET_DESC_FILE_WRITE, CAPS_TARGET_DETAIL_DESC_FILE_WRITE, CAPS_TARGET_URL_FILE_WRITE, CAPS_TARGET_DESC_FILE_DELETE, CAPS_TARGET_DETAIL_DESC_FILE_DELETE, CAPS_TARGET_URL_FILE_DELETE, CAPS_TARGET_DESC_IMPERSONATOR, CAPS_TARGET_DETAIL_DESC_IMPERSONATOR, CAPS_TARGET_URL_IMPERSONATOR, CAPS_TARGET_DESC_BROWSER_READ, CAPS_TARGET_DETAIL_DESC_BROWSER_READ, CAPS_TARGET_URL_BROWSER_READ, CAPS_TARGET_DESC_BROWSER_WRITE, CAPS_TARGET_DETAIL_DESC_BROWSER_WRITE, CAPS_TARGET_URL_BROWSER_WRITE, CAPS_TARGET_DESC_BROWSER_ACCESS, CAPS_TARGET_DETAIL_DESC_BROWSER_ACCESS, CAPS_TARGET_URL_BROWSER_ACCESS, CAPS_TARGET_DESC_PREFS_READ, CAPS_TARGET_DETAIL_DESC_PREFS_READ, CAPS_TARGET_URL_PREFS_READ, CAPS_TARGET_DESC_PREFS_WRITE, CAPS_TARGET_DETAIL_DESC_PREFS_WRITE, CAPS_TARGET_URL_PREFS_WRITE, CAPS_TARGET_DESC_SEND_MAIL, CAPS_TARGET_DETAIL_DESC_SEND_MAIL, CAPS_TARGET_URL_SEND_MAIL, CAPS_TARGET_DESC_REG_PRIVATE, CAPS_TARGET_DETAIL_DESC_REG_PRIVATE, // CAPS_TARGET_DETAIL_DESC_REG_PRIVATE_1, CAPS_TARGET_URL_REG_PRIVATE, CAPS_TARGET_DESC_REG_STANDARD, CAPS_TARGET_DETAIL_DESC_REG_STANDARD, // CAPS_TARGET_DETAIL_DESC_REG_STANDARD_1, // CAPS_TARGET_DETAIL_DESC_REG_STANDARD_2, CAPS_TARGET_URL_REG_STANDARD, CAPS_TARGET_DESC_REG_ADMIN, CAPS_TARGET_DETAIL_DESC_REG_ADMIN, // CAPS_TARGET_DETAIL_DESC_REG_ADMIN_1, CAPS_TARGET_URL_REG_ADMIN, CAPS_TARGET_DESC_ACCOUNT_SETUP, CAPS_TARGET_DETAIL_DESC_ACCOUNT_SETUP, CAPS_TARGET_URL_ACCOUNT_SETUP, CAPS_TARGET_DESC_SAR, CAPS_TARGET_DETAIL_DESC_SAR, // CAPS_TARGET_DETAIL_DESC_SAR_1, CAPS_TARGET_URL_SAR, CAPS_TARGET_DESC_CANVAS_ACCESS, CAPS_TARGET_DETAIL_DESC_CANVAS_ACCESS, CAPS_TARGET_URL_CANVAS_ACCESS, CAPS_TARGET_DESC_FILE_ACCESS, CAPS_TARGET_DETAIL_DESC_FILE_ACCESS, CAPS_TARGET_URL_FILE_ACCESS, CAPS_TARGET_DESC_UNINSTALL, CAPS_TARGET_DETAIL_DESC_UNINSTALL, CAPS_TARGET_URL_UNINSTALL, CAPS_TARGET_DESC_SOFTWAREINSTALL, CAPS_TARGET_DETAIL_DESC_SOFTWAREINSTALL, CAPS_TARGET_URL_SOFTWAREINSTALL, CAPS_TARGET_DESC_SILENTINSTALL, CAPS_TARGET_DETAIL_DESC_SILENTINSTALL, CAPS_TARGET_URL_SILENTINSTALL, CAPS_TARGET_DESC_ALL_JAVA_PERMISSION, CAPS_TARGET_DETAIL_DESC_ALL_JAVA_PERMISSION, CAPS_TARGET_URL_ALL_JAVA_PERMISSION, CAPS_TARGET_DESC_ALL_JS_PERMISSION, CAPS_TARGET_DETAIL_DESC_ALL_JS_PERMISSION, CAPS_TARGET_URL_ALL_JS_PERMISSION, CAPS_TARGET_MAXIMUM } CAPS_TARGET; #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ char* capsGetString(int id) { PR_ASSERT(id <= CAPS_TARGET_MAXIMUM); return capsTargetStrings[id]; } #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ #ifdef XXX extern int CAPS_TARGET_RISK_STR_LOW; extern int CAPS_TARGET_RISK_STR_MEDIUM; extern int CAPS_TARGET_RISK_STR_HIGH; extern int CAPS_TARGET_RISK_COLOR_LOW; extern int CAPS_TARGET_RISK_COLOR_MEDIUM; extern int CAPS_TARGET_RISK_COLOR_HIGH; extern int CAPS_TARGET_HELP_URL; extern int CAPS_TARGET_DESC_FILE_READ; extern int CAPS_TARGET_DETAIL_DESC_FILE_READ; extern int CAPS_TARGET_URL_FILE_READ; extern int CAPS_TARGET_DESC_FILE_WRITE; extern int CAPS_TARGET_DETAIL_DESC_FILE_WRITE; extern int CAPS_TARGET_URL_FILE_WRITE; extern int CAPS_TARGET_DESC_FILE_DELETE; extern int CAPS_TARGET_DETAIL_DESC_FILE_DELETE; extern int CAPS_TARGET_URL_FILE_DELETE; extern int CAPS_TARGET_DESC_IMPERSONATOR; extern int CAPS_TARGET_DETAIL_DESC_IMPERSONATOR; extern int CAPS_TARGET_URL_IMPERSONATOR; extern int CAPS_TARGET_DESC_BROWSER_READ; extern int CAPS_TARGET_DETAIL_DESC_BROWSER_READ; extern int CAPS_TARGET_URL_BROWSER_READ; extern int CAPS_TARGET_DESC_BROWSER_WRITE; extern int CAPS_TARGET_DETAIL_DESC_BROWSER_WRITE; extern int CAPS_TARGET_URL_BROWSER_WRITE; extern int CAPS_TARGET_DESC_BROWSER_ACCESS; extern int CAPS_TARGET_DETAIL_DESC_BROWSER_ACCESS; extern int CAPS_TARGET_URL_BROWSER_ACCESS; extern int CAPS_TARGET_DESC_PREFS_READ; extern int CAPS_TARGET_DETAIL_DESC_PREFS_READ; extern int CAPS_TARGET_URL_PREFS_READ; extern int CAPS_TARGET_DESC_PREFS_WRITE; extern int CAPS_TARGET_DETAIL_DESC_PREFS_WRITE; extern int CAPS_TARGET_URL_PREFS_WRITE; extern int CAPS_TARGET_DESC_SEND_MAIL; extern int CAPS_TARGET_DETAIL_DESC_SEND_MAIL; extern int CAPS_TARGET_URL_SEND_MAIL; extern int CAPS_TARGET_DESC_REG_PRIVATE; extern int CAPS_TARGET_DETAIL_DESC_REG_PRIVATE; //extern int CAPS_TARGET_DETAIL_DESC_REG_PRIVATE_1; extern int CAPS_TARGET_URL_REG_PRIVATE; extern int CAPS_TARGET_DESC_REG_STANDARD; extern int CAPS_TARGET_DETAIL_DESC_REG_STANDARD; //extern int CAPS_TARGET_DETAIL_DESC_REG_STANDARD_1; //extern int CAPS_TARGET_DETAIL_DESC_REG_STANDARD_2; extern int CAPS_TARGET_URL_REG_STANDARD; extern int CAPS_TARGET_DESC_REG_ADMIN; extern int CAPS_TARGET_DETAIL_DESC_REG_ADMIN; //extern int CAPS_TARGET_DETAIL_DESC_REG_ADMIN_1; extern int CAPS_TARGET_URL_REG_ADMIN; extern int CAPS_TARGET_DESC_ACCOUNT_SETUP; extern int CAPS_TARGET_DETAIL_DESC_ACCOUNT_SETUP; extern int CAPS_TARGET_URL_ACCOUNT_SETUP; extern int CAPS_TARGET_DESC_SAR; extern int CAPS_TARGET_DETAIL_DESC_SAR; //extern int CAPS_TARGET_DETAIL_DESC_SAR_1; extern int CAPS_TARGET_URL_SAR; extern int CAPS_TARGET_DESC_CANVAS_ACCESS; extern int CAPS_TARGET_DETAIL_DESC_CANVAS_ACCESS; extern int CAPS_TARGET_URL_CANVAS_ACCESS; extern int CAPS_TARGET_DESC_FILE_ACCESS; extern int CAPS_TARGET_DETAIL_DESC_FILE_ACCESS; extern int CAPS_TARGET_URL_FILE_ACCESS; extern int CAPS_TARGET_DESC_UNINSTALL; extern int CAPS_TARGET_DETAIL_DESC_UNINSTALL; extern int CAPS_TARGET_URL_UNINSTALL; extern int CAPS_TARGET_DESC_SOFTWAREINSTALL; extern int CAPS_TARGET_DETAIL_DESC_SOFTWAREINSTALL; extern int CAPS_TARGET_URL_SOFTWAREINSTALL; extern int CAPS_TARGET_DESC_SILENTINSTALL; extern int CAPS_TARGET_DETAIL_DESC_SILENTINSTALL; extern int CAPS_TARGET_URL_SILENTINSTALL; extern int CAPS_TARGET_DESC_ALL_JAVA_PERMISSION; extern int CAPS_TARGET_DETAIL_DESC_ALL_JAVA_PERMISSION; extern int CAPS_TARGET_URL_ALL_JAVA_PERMISSION; extern int CAPS_TARGET_DESC_ALL_JS_PERMISSION; extern int CAPS_TARGET_DETAIL_DESC_ALL_JS_PERMISSION; extern int CAPS_TARGET_URL_ALL_JS_PERMISSION; #endif /* XXX */ /* XXXXXXXX END oF HACK */ #define TARGET_STR " Target: " #define PRIN_STR " Principal: " static nsHashtable * theTargetRegistry = new nsHashtable(); static nsHashtable * theSystemTargetRegistry = new nsHashtable(); static nsHashtable * theDescToTargetRegistry = new nsHashtable(); static PRBool AddToTargetArray(nsHashKey * aKey, void * aData, void * closure); #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #include "jpermission.h" PR_PUBLIC_API(void) java_netscape_security_getTargetDetails(const char * charSetName, char * targetName, char** details, char **risk) { if (!targetName) return; nsITarget * target = nsTarget::GetTargetFromDescription(targetName); target->GetRisk(risk); nsTargetArray * primitiveTargets; target->GetFlattenedTargetArray(& primitiveTargets); /* Count the length of string buffer to allocate */ int len=0; int extra_len = strlen("