/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /* To edit this file, set TABSTOPS to 4 spaces. * This is not the normal NSS convention. */ #include "modutil.h" #include "install.h" #include #include "certdb.h" /* for CERT_DB_FILE_VERSION */ #include "nss.h" static void install_error(char *message); static char* PR_fgets(char *buf, int size, PRFileDesc *file); static char *progName; /* This enum must be kept in sync with the commandNames list */ typedef enum { NO_COMMAND, ADD_COMMAND, CHANGEPW_COMMAND, CREATE_COMMAND, DEFAULT_COMMAND, DELETE_COMMAND, DISABLE_COMMAND, ENABLE_COMMAND, FIPS_COMMAND, JAR_COMMAND, LIST_COMMAND, RAW_LIST_COMMAND, RAW_ADD_COMMAND, CHKFIPS_COMMAND, UNDEFAULT_COMMAND } Command; /* This list must be kept in sync with the Command enum */ static char *commandNames[] = { "(no command)", "-add", "-changepw", "-create", "-default", "-delete", "-disable", "-enable", "-fips", "-jar", "-list", "-rawlist", "-rawadd", "-chkfips", "-undefault" }; /* this enum must be kept in sync with the optionStrings list */ typedef enum { ADD_ARG=0, RAW_ADD_ARG, CHANGEPW_ARG, CIPHERS_ARG, CREATE_ARG, DBDIR_ARG, DBPREFIX_ARG, DEFAULT_ARG, DELETE_ARG, DISABLE_ARG, ENABLE_ARG, FIPS_ARG, FORCE_ARG, JAR_ARG, LIBFILE_ARG, LIST_ARG, RAW_LIST_ARG, MECHANISMS_ARG, NEWPWFILE_ARG, PWFILE_ARG, SLOT_ARG, UNDEFAULT_ARG, INSTALLDIR_ARG, TEMPDIR_ARG, SECMOD_ARG, NOCERTDB_ARG, STRING_ARG, CHKFIPS_ARG, NUM_ARGS /* must be last */ } Arg; /* This list must be kept in sync with the Arg enum */ static char *optionStrings[] = { "-add", "-rawadd", "-changepw", "-ciphers", "-create", "-dbdir", "-dbprefix", "-default", "-delete", "-disable", "-enable", "-fips", "-force", "-jar", "-libfile", "-list", "-rawlist", "-mechanisms", "-newpwfile", "-pwfile", "-slot", "-undefault", "-installdir", "-tempdir", "-secmod", "-nocertdb", "-string", "-chkfips", }; char *msgStrings[] = { "FIPS mode enabled.\n", "FIPS mode disabled.\n", "Using database directory %s...\n", "Creating \"%s\"...", "Module \"%s\" added to database.\n", "Module \"%s\" deleted from database.\n", "Token \"%s\" password changed successfully.\n", "Incorrect password, try again...\n", "Passwords do not match, try again...\n", "done.\n", "Slot \"%s\" %s.\n", "Successfully changed defaults.\n", "Successfully changed defaults.\n", "\nWARNING: Performing this operation while the browser is running could cause" "\ncorruption of your security databases. If the browser is currently running," "\nyou should exit browser before continuing this operation. Type " "\n'q ' to abort, or to continue: ", "\nAborting...\n" }; /* Increment i if doing so would have i still be less than j. If you are able to do this, return 0. Otherwise return 1. */ #define TRY_INC(i,j) ( ((i+1)