~ubuntu-branches/ubuntu/karmic/nss/karmic-updates

« back to all changes in this revision

Viewing changes to mozilla/security/nss/cmd/selfserv/selfserv.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack, Fabien Tassin, Alexander Sack
  • Date: 2009-01-11 15:06:17 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090111150617-iz4lw05qgy2odorl
Tags: 3.12.2~rc1-0ubuntu1
* New upstream snapshot: 3.12.2 RC1

[ Fabien Tassin <fta@ubuntu.com> ]
* Remove patch applied upstream:
  - drop debian/patches/80_security_tools.patch
  - update debian/patches/series
* Update diverged patches:
  - update debian/patches/38_kbsd.patch
  - update debian/patches/38_mips64_build.patch
* Add new symbols to symbols file
  - update debian/libnss3-1d.symbols

[ Alexander Sack <asac@ubuntu.com> ]
* disable soname patch to become binary compatible with upstream
  - update debian/patches/series
* flip links: libnss3.so <- libnss3.so.1d (before: libnss3.so ->
  libnss3.so.1d); same link flipping was done for all other previously
  soname patched libs: libnssutil3.so, libsmime3.so.1d, libssl3.so.1d
  - update debian/libnss3-1d.links
  - update debian/libnss3-1d.symbols
* properly transition links in preinst and postrm; also cover abort-
  cases in the other maintainer scripts
  - add debian/libnss3-1d.postinst
  - add debian/libnss3-1d.postrm
  - add debian/libnss3-1d.preinst
  - add debian/libnss3-1d.prerm
* remove hack from debian/rules that debian uses to recreate
  libsoftokn3.so with a versioned SONAME
  - update debian/rules
* install the unversioned .so binaries
  - update debian/rules
* only install the 4 main libraries into /usr/lib; all the others
  go to pkglibdir
  - update debian/rules
* higher bar for libnspr4 Build-Depend to >= 4.7.3~, which is
  the version where the soname droppage is going to happen
  - update debian/control
* explitily pass libraries to be used for dpkg-gensymbols run of
  dh_makeshlibs
  - update debian/rules
* fix lintian complain about no-shlibs-control-file
  - update debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
163
163
 
164
164
static PRLogModuleInfo *lm;
165
165
 
166
 
/* Add custom password handler because SECU_GetModulePassword 
167
 
 * makes automation of this program next to impossible.
168
 
 */
169
 
 
170
 
char *
171
 
ownPasswd(PK11SlotInfo *info, PRBool retry, void *arg)
172
 
{
173
 
        char * passwd = NULL;
174
 
 
175
 
        if ( (!retry) && arg ) {
176
 
                passwd = PL_strdup((char *)arg);
177
 
        }
178
 
 
179
 
        return passwd;
180
 
}
181
 
 
182
166
#define PRINTF  if (verbose)  printf
183
167
#define FPRINTF if (verbose) fprintf
184
168
#define FLUSH   if (verbose) { fflush(stdout); fflush(stderr); }
191
175
 
192
176
"Usage: %s -n rsa_nickname -p port [-3BDENRSTbjlmrsuvx] [-w password]\n"
193
177
"         [-t threads] [-i pid_file] [-c ciphers] [-d dbdir] [-g numblocks]\n"
194
 
"         [-f fortezza_nickname] [-L [seconds]] [-M maxProcs] [-P dbprefix]\n"
 
178
"         [-f password_file] [-L [seconds]] [-M maxProcs] [-P dbprefix]\n"
195
179
#ifdef NSS_ENABLE_ECC
196
180
"         [-C SSLCacheEntries] [-e ec_nickname]\n"
197
181
#else
1782
1766
    exit(0);
1783
1767
}
1784
1768
 
1785
 
#ifdef DEBUG_nelsonb
1786
 
 
1787
 
#if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS)
1788
 
#define SSL_GETPID getpid
1789
 
#elif defined(_WIN32_WCE)
1790
 
#define SSL_GETPID GetCurrentProcessId
1791
 
#elif defined(WIN32)
1792
 
extern int __cdecl _getpid(void);
1793
 
#define SSL_GETPID _getpid
1794
 
#else
1795
 
#define SSL_GETPID() 0   
1796
 
#endif
1797
 
 
1798
 
void
1799
 
WaitForDebugger(void)
1800
 
{
1801
 
 
1802
 
    int waiting       = 12;
1803
 
    int myPid         = SSL_GETPID();
1804
 
    PRIntervalTime    nrval = PR_SecondsToInterval(5);
1805
 
 
1806
 
    while (waiting) {
1807
 
        printf("child %d is waiting to be debugged!\n", myPid);
1808
 
        PR_Sleep(nrval); 
1809
 
        --waiting;
1810
 
    }
1811
 
}
1812
 
#endif
1813
 
 
1814
1769
#define HEXCHAR_TO_INT(c, i) \
1815
1770
    if (((c) >= '0') && ((c) <= '9')) { \
1816
1771
        i = (c) - '0'; \
1834
1789
#ifdef NSS_ENABLE_ECC
1835
1790
    char *               ecNickName   = NULL;
1836
1791
#endif
1837
 
    char *               fNickName   = NULL;
1838
1792
    const char *         fileName    = NULL;
1839
1793
    char *               cipherString= NULL;
1840
1794
    const char *         dir         = ".";
1841
1795
    char *               passwd      = NULL;
 
1796
    char *               pwfile      = NULL;
1842
1797
    const char *         pidFile     = NULL;
1843
1798
    char *               tmp;
1844
1799
    char *               envString;
1862
1817
    PRUint32             protos = 0;
1863
1818
    SSL3Statistics      *ssl3stats;
1864
1819
    PRUint32             i;
 
1820
    secuPWData  pwdata = { PW_NONE, 0 };
1865
1821
 
1866
1822
    tmp = strrchr(argv[0], '/');
1867
1823
    tmp = tmp ? tmp + 1 : argv[0];
1923
1879
        case 'e': ecNickName = PORT_Strdup(optstate->value); break;
1924
1880
#endif /* NSS_ENABLE_ECC */
1925
1881
 
1926
 
        case 'f': fNickName = PORT_Strdup(optstate->value); break;
 
1882
        case 'f':
 
1883
            pwdata.source = PW_FROMFILE;
 
1884
            pwdata.data = pwfile = PORT_Strdup(optstate->value);
 
1885
            break;
1927
1886
 
1928
1887
        case 'g': 
1929
1888
            testBulk = PR_TRUE;
1967
1926
 
1968
1927
        case 'v': verbose++; break;
1969
1928
 
1970
 
        case 'w': passwd = PORT_Strdup(optstate->value); break;
 
1929
        case 'w':
 
1930
            pwdata.source = PW_PLAINTEXT;
 
1931
            pwdata.data = passwd = PORT_Strdup(optstate->value);
 
1932
            break;
1971
1933
 
1972
1934
        case 'x': useExportPolicy = PR_TRUE; break;
1973
1935
 
2007
1969
        exit(0);
2008
1970
    }
2009
1971
 
2010
 
    if ((nickName == NULL) && (fNickName == NULL) 
 
1972
    if ((nickName == NULL)
2011
1973
 #ifdef NSS_ENABLE_ECC
2012
1974
                                                && (ecNickName == NULL)
2013
1975
 #endif
2070
2032
        if (prStatus != PR_SUCCESS)
2071
2033
            errExit("PR_SetFDInheritable");
2072
2034
#endif
2073
 
#ifdef DEBUG_nelsonb
2074
 
        WaitForDebugger();
2075
 
#endif
2076
2035
        rv = SSL_InheritMPServerSIDCache(envString);
2077
2036
        if (rv != SECSuccess)
2078
2037
            errExit("SSL_InheritMPServerSIDCache");
2107
2066
        readBigFile(fileName);
2108
2067
 
2109
2068
    /* set our password function */
2110
 
    PK11_SetPasswordFunc( passwd ? ownPasswd : SECU_GetModulePassword);
 
2069
    PK11_SetPasswordFunc(SECU_GetModulePassword);
2111
2070
 
2112
 
    /* Call the libsec initialization routines */
 
2071
    /* Call the NSS initialization routines */
2113
2072
    rv = NSS_Initialize(dir, certPrefix, certPrefix, SECMOD_DB, NSS_INIT_READONLY);
2114
2073
    if (rv != SECSuccess) {
2115
2074
        fputs("NSS_Init failed.\n", stderr);
2202
2161
    }
2203
2162
 
2204
2163
    if (nickName) {
2205
 
        cert[kt_rsa] = PK11_FindCertFromNickname(nickName, passwd);
 
2164
        cert[kt_rsa] = PK11_FindCertFromNickname(nickName, &pwdata);
2206
2165
        if (cert[kt_rsa] == NULL) {
2207
2166
            fprintf(stderr, "selfserv: Can't find certificate %s\n", nickName);
2208
2167
            exit(10);
2209
2168
        }
2210
 
        privKey[kt_rsa] = PK11_FindKeyByAnyCert(cert[kt_rsa], passwd);
 
2169
        privKey[kt_rsa] = PK11_FindKeyByAnyCert(cert[kt_rsa], &pwdata);
2211
2170
        if (privKey[kt_rsa] == NULL) {
2212
2171
            fprintf(stderr, "selfserv: Can't find Private Key for cert %s\n", 
2213
2172
                    nickName);
2216
2175
        if (testbypass) {
2217
2176
            PRBool bypassOK;
2218
2177
            if (SSL_CanBypass(cert[kt_rsa], privKey[kt_rsa], protos, cipherlist, 
2219
 
                              nciphers, &bypassOK, passwd) != SECSuccess) {
 
2178
                              nciphers, &bypassOK, &pwdata) != SECSuccess) {
2220
2179
                SECU_PrintError(progName, "Bypass test failed %s\n", nickName);
2221
2180
                exit(14);
2222
2181
            }
2224
2183
                    bypassOK ? "" : "not");
2225
2184
        }
2226
2185
    }
2227
 
    if (fNickName) {
2228
 
        cert[kt_fortezza] = PK11_FindCertFromNickname(fNickName, NULL);
2229
 
        if (cert[kt_fortezza] == NULL) {
2230
 
            fprintf(stderr, "selfserv: Can't find certificate %s\n", fNickName);
2231
 
            exit(12);
2232
 
        }
2233
 
        privKey[kt_fortezza] = PK11_FindKeyByAnyCert(cert[kt_fortezza], NULL);
2234
 
    }
2235
2186
#ifdef NSS_ENABLE_ECC
2236
2187
    if (ecNickName) {
2237
 
        cert[kt_ecdh] = PK11_FindCertFromNickname(ecNickName, passwd);
 
2188
        cert[kt_ecdh] = PK11_FindCertFromNickname(ecNickName, &pwdata);
2238
2189
        if (cert[kt_ecdh] == NULL) {
2239
2190
            fprintf(stderr, "selfserv: Can't find certificate %s\n",
2240
2191
                    ecNickName);
2241
2192
            exit(13);
2242
2193
        }
2243
 
        privKey[kt_ecdh] = PK11_FindKeyByAnyCert(cert[kt_ecdh], passwd);
 
2194
        privKey[kt_ecdh] = PK11_FindKeyByAnyCert(cert[kt_ecdh], &pwdata);
2244
2195
        if (privKey[kt_ecdh] == NULL) {
2245
2196
            fprintf(stderr, "selfserv: Can't find Private Key for cert %s\n", 
2246
2197
                    ecNickName);
2249
2200
        if (testbypass) {
2250
2201
            PRBool bypassOK;
2251
2202
            if (SSL_CanBypass(cert[kt_ecdh], privKey[kt_ecdh], protos, cipherlist,
2252
 
                              nciphers, &bypassOK, passwd) != SECSuccess) {
 
2203
                              nciphers, &bypassOK, &pwdata) != SECSuccess) {
2253
2204
                SECU_PrintError(progName, "Bypass test failed %s\n", ecNickName);
2254
2205
                exit(15);
2255
2206
            }
2312
2263
    if (passwd) {
2313
2264
        PORT_Free(passwd);
2314
2265
    }
 
2266
    if (pwfile) {
 
2267
        PORT_Free(pwfile);
 
2268
    }
2315
2269
    if (certPrefix && certPrefix != emptyString) {                            
2316
2270
        PORT_Free(certPrefix);
2317
2271
    }
2318
 
    if (fNickName) {
2319
 
        PORT_Free(fNickName);
2320
 
    }
2321
2272
 #ifdef NSS_ENABLE_ECC
2322
2273
    if (ecNickName) {
2323
2274
        PORT_Free(ecNickName);