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

« back to all changes in this revision

Viewing changes to mozilla/security/nss/lib/dev/devslot.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:
35
35
 * ***** END LICENSE BLOCK ***** */
36
36
 
37
37
#ifdef DEBUG
38
 
static const char CVS_ID[] = "@(#) $RCSfile: devslot.c,v $ $Revision: 1.23 $ $Date: 2007/11/16 05:29:25 $";
 
38
static const char CVS_ID[] = "@(#) $RCSfile: devslot.c,v $ $Revision: 1.24 $ $Date: 2008/08/09 01:25:58 $";
39
39
#endif /* DEBUG */
40
40
 
41
41
#ifndef NSSCKEPV_H
50
50
#include "ckhelper.h"
51
51
#endif /* CKHELPER_H */
52
52
 
 
53
#include "pk11pub.h"
 
54
 
53
55
/* measured in seconds */
54
56
#define NSSSLOT_TOKEN_DELAY_TIME 1
55
57
 
163
165
    nssSession *session;
164
166
    CK_SLOT_INFO slotInfo;
165
167
    void *epv;
166
 
    /* permanent slots are always present */
 
168
    /* permanent slots are always present unless they're disabled */
167
169
    if (nssSlot_IsPermanent(slot)) {
168
 
        return PR_TRUE;
 
170
        return !PK11_IsDisabled(slot->pk11slot);
169
171
    }
170
172
    /* avoid repeated calls to check token status within set interval */
171
173
    if (within_token_delay_period(slot)) {
172
 
        return (PRBool)((slot->ckFlags & CKF_TOKEN_PRESENT) != 0);
 
174
        return ((slot->ckFlags & CKF_TOKEN_PRESENT) != 0);
173
175
    }
174
176
 
175
177
    /* First obtain the slot info */
188
190
    /* check for the presence of the token */
189
191
    if ((slot->ckFlags & CKF_TOKEN_PRESENT) == 0) {
190
192
        if (!slot->token) {
191
 
            /* token was ne'er present */
 
193
            /* token was never present */
192
194
            return PR_FALSE;
193
195
        }
194
196
        session = nssToken_GetDefaultSession(slot->token);
195
 
        nssSession_EnterMonitor(session);
196
 
        /* token is not present */
197
 
        if (session->handle != CK_INVALID_SESSION) {
198
 
            /* session is valid, close and invalidate it */
199
 
            CKAPI(epv)->C_CloseSession(session->handle);
200
 
            session->handle = CK_INVALID_SESSION;
 
197
        if (session) {
 
198
            nssSession_EnterMonitor(session);
 
199
            /* token is not present */
 
200
            if (session->handle != CK_INVALID_SESSION) {
 
201
                /* session is valid, close and invalidate it */
 
202
                CKAPI(epv)->C_CloseSession(session->handle);
 
203
                session->handle = CK_INVALID_SESSION;
 
204
            }
 
205
            nssSession_ExitMonitor(session);
201
206
        }
202
 
        nssSession_ExitMonitor(session);
203
207
        if (slot->token->base.name[0] != 0) {
204
208
            /* notify the high-level cache that the token is removed */
205
209
            slot->token->base.name[0] = 0; /* XXX */
214
218
     * has been removed and reinserted.
215
219
     */
216
220
    session = nssToken_GetDefaultSession(slot->token);
217
 
    nssSession_EnterMonitor(session);
218
 
    if (session->handle != CK_INVALID_SESSION) {
219
 
        CK_SESSION_INFO sessionInfo;
220
 
        ckrv = CKAPI(epv)->C_GetSessionInfo(session->handle, &sessionInfo);
221
 
        if (ckrv != CKR_OK) {
222
 
            /* session is screwy, close and invalidate it */
223
 
            CKAPI(epv)->C_CloseSession(session->handle);
224
 
            session->handle = CK_INVALID_SESSION;
225
 
        }
226
 
    }
227
 
    nssSession_ExitMonitor(session);
228
 
    /* token not removed, finished */
229
 
    if (session->handle != CK_INVALID_SESSION) {
230
 
        return PR_TRUE;
231
 
    } else {
232
 
        /* the token has been removed, and reinserted, or the slot contains
233
 
         * a token it doesn't recognize. invalidate all the old
234
 
         * information we had on this token, if we can't refresh, clear
235
 
         * the present flag */
236
 
        nssToken_NotifyCertsNotVisible(slot->token);
237
 
        nssToken_Remove(slot->token);
238
 
        /* token has been removed, need to refresh with new session */
239
 
        nssrv = nssSlot_Refresh(slot);
240
 
        if (nssrv != PR_SUCCESS) {
241
 
            slot->token->base.name[0] = 0; /* XXX */
242
 
            slot->ckFlags &= ~CKF_TOKEN_PRESENT;
243
 
            return PR_FALSE;
244
 
        }
245
 
        return PR_TRUE;
246
 
    }
 
221
    if (session) {
 
222
        nssSession_EnterMonitor(session);
 
223
        if (session->handle != CK_INVALID_SESSION) {
 
224
            CK_SESSION_INFO sessionInfo;
 
225
            ckrv = CKAPI(epv)->C_GetSessionInfo(session->handle, &sessionInfo);
 
226
            if (ckrv != CKR_OK) {
 
227
                /* session is screwy, close and invalidate it */
 
228
                CKAPI(epv)->C_CloseSession(session->handle);
 
229
                session->handle = CK_INVALID_SESSION;
 
230
            }
 
231
        }
 
232
        nssSession_ExitMonitor(session);
 
233
        /* token not removed, finished */
 
234
        if (session->handle != CK_INVALID_SESSION)
 
235
            return PR_TRUE;
 
236
    } 
 
237
    /* the token has been removed, and reinserted, or the slot contains
 
238
     * a token it doesn't recognize. invalidate all the old
 
239
     * information we had on this token, if we can't refresh, clear
 
240
     * the present flag */
 
241
    nssToken_NotifyCertsNotVisible(slot->token);
 
242
    nssToken_Remove(slot->token);
 
243
    /* token has been removed, need to refresh with new session */
 
244
    nssrv = nssSlot_Refresh(slot);
 
245
    if (nssrv != PR_SUCCESS) {
 
246
        slot->token->base.name[0] = 0; /* XXX */
 
247
        slot->ckFlags &= ~CKF_TOKEN_PRESENT;
 
248
        return PR_FALSE;
 
249
    }
 
250
    return PR_TRUE;
247
251
}
248
252
 
249
253
NSS_IMPLEMENT void *