1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
14 * The Original Code is the Netscape security libraries.
16 * The Initial Developer of the Original Code is
17 * Netscape Communications Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 1994-2000
19 * the Initial Developer. All Rights Reserved.
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the MPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the MPL, the GPL or the LGPL.
35 * ***** END LICENSE BLOCK ***** */
45 /* These are installation functions that make calls to the security library.
46 * We don't want to include security include files in the C++ code too much.
49 static char* PR_fgets(char *buf
, int size
, PRFileDesc
*file
);
51 /***************************************************************************
53 * P k 1 1 I n s t a l l _ A d d N e w M o d u l e
56 Pk11Install_AddNewModule(char* moduleName
, char* dllPath
,
57 unsigned long defaultMechanismFlags
,
58 unsigned long cipherEnableFlags
)
60 return (SECMOD_AddNewModule(moduleName
, dllPath
,
61 SECMOD_PubMechFlagstoInternal(defaultMechanismFlags
),
62 SECMOD_PubCipherFlagstoInternal(cipherEnableFlags
))
63 == SECSuccess
) ? 0 : -1;
66 /*************************************************************************
68 * P k 1 1 I n s t a l l _ U s e r V e r i f y J a r
70 * Gives the user feedback on the signatures of a JAR files, asks them
71 * whether they actually want to continue.
72 * Assumes the jar structure has already been created and is valid.
73 * Returns 0 if the user wants to continue the installation, nonzero
74 * if the user wishes to abort.
77 Pk11Install_UserVerifyJar(JAR
*jar
, PRFileDesc
*out
, PRBool query
)
85 CERTCertificate
*cert
, *prev
=NULL
;
87 PR_fprintf(out
, "\nThis installation JAR file was signed by:\n");
89 ctx
= JAR_find(jar
, NULL
, jarTypeSign
);
91 while(JAR_find_next(ctx
, &item
) >= 0 ) {
92 fing
= (JAR_Cert
*) item
->data
;
99 PR_fprintf(out
, "----------------------------------------------\n");
102 PR_fprintf(out
, "**NICKNAME**\n%s\n", cert
->nickname
);
104 if(cert
->subjectName
) {
105 PR_fprintf(out
, "**SUBJECT NAME**\n%s\n", cert
->subjectName
); }
106 if(cert
->issuerName
) {
107 PR_fprintf(out
, "**ISSUER NAME**\n%s\n", cert
->issuerName
);
110 PR_fprintf(out
, "No matching certificate could be found.\n");
112 PR_fprintf(out
, "----------------------------------------------\n\n");
120 PR_fprintf(out
, "No signatures found: JAR FILE IS UNSIGNED.\n");
125 "Do you wish to continue this installation? (y/n) ");
127 if(PR_fgets(stdinbuf
, 80, PR_STDIN
) != NULL
) {
130 if( (response
=strtok(stdinbuf
, " \t\n\r")) ) {
131 if( !PL_strcasecmp(response
, "y") ||
132 !PL_strcasecmp(response
, "yes") ) {
142 /**************************************************************************
146 * fgets implemented with NSPR.
149 PR_fgets(char *buf
, int size
, PRFileDesc
*file
)
157 status
= PR_Read(file
, (void*) &c
, 1);
160 } else if(status
==0) {
173 /**************************************************************************
175 * m y S E C U _ E r r o r S t r i n g
178 const char* mySECU_ErrorString(int16 errnum
)
180 return SECU_Strerror(errnum
);