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

« back to all changes in this revision

Viewing changes to mozilla/security/nss/lib/softoken/softoken.h

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2009-06-16 13:23:47 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090616132347-311ysb8oep74b98y
Tags: 3.12.3-0ubuntu1
* new upstream release 3.12.3 RTM (NSS_3_12_3_RTM) (LP: #387751)
* adjust patches to changed upstream code base
  - update debian/patches/38_kbsd.patch
* needs nspr >= 4.7.4
  - update debian/control
* update 85_security_load.patch to latest debian version
  - update debian/patches/85_security_load.patch
* add new symbols for 3.12.3
  - update debian/libnss3-1d.symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 * the terms of any one of the MPL, the GPL or the LGPL.
37
37
 *
38
38
 * ***** END LICENSE BLOCK ***** */
39
 
/* $Id: softoken.h,v 1.17 2008/02/05 05:33:37 julien.pierre.boogz%sun.com Exp $ */
 
39
/* $Id: softoken.h,v 1.23 2009/02/26 06:57:15 nelson%bolyard.com Exp $ */
40
40
 
41
41
#ifndef _SOFTOKEN_H_
42
42
#define _SOFTOKEN_H_
189
189
*/
190
190
extern PRBool sftk_audit_enabled;
191
191
 
192
 
extern void sftk_LogAuditMessage(NSSAuditSeverity severity, const char *msg);
 
192
extern void sftk_LogAuditMessage(NSSAuditSeverity severity, 
 
193
                                 NSSAuditType, const char *msg);
193
194
 
194
195
extern void sftk_AuditCreateObject(CK_SESSION_HANDLE hSession,
195
196
                        CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount,
262
263
extern PRBool sftk_fatalError;
263
264
 
264
265
/*
265
 
** macros to check for forked child after C_Initialize
 
266
** macros to check for forked child process after C_Initialize
266
267
*/
267
 
#if defined(XP_UNIX) && !defined(NO_PTHREADS)
268
 
 
269
 
extern PRBool forked;
270
 
 
271
 
extern void ForkedChild(void);
 
268
#if defined(XP_UNIX) && !defined(NO_CHECK_FORK)
 
269
 
 
270
#ifdef DEBUG
 
271
 
 
272
#define FORK_ASSERT() \
 
273
    { \
 
274
        char* forkAssert = getenv("NSS_STRICT_NOFORK"); \
 
275
        if ( (!forkAssert) || (0 == strcmp(forkAssert, "1")) ) { \
 
276
            PORT_Assert(0); \
 
277
        } \
 
278
    }
 
279
 
 
280
#else
 
281
 
 
282
#define FORK_ASSERT()
 
283
 
 
284
#endif
 
285
 
 
286
/* we have 3 methods of implementing the fork checks :
 
287
 * - Solaris "mixed" method
 
288
 * - pthread_atfork method
 
289
 * - getpid method
 
290
 */
 
291
 
 
292
#if !defined (CHECK_FORK_MIXED) && !defined(CHECK_FORK_PTHREAD) && \
 
293
    !defined (CHECK_FORK_GETPID)
 
294
 
 
295
/* Choose fork check method automatically unless specified
 
296
 * This section should be updated as more platforms get pthread fixes
 
297
 * to unregister fork handlers in dlclose.
 
298
 */
 
299
 
 
300
#ifdef SOLARIS
 
301
 
 
302
/* Solaris 8, s9 use PID checks, s10 uses pthread_atfork */
 
303
 
 
304
#define CHECK_FORK_MIXED
 
305
 
 
306
#elif defined(LINUX)
 
307
 
 
308
#define CHECK_FORK_PTHREAD
 
309
 
 
310
#else
 
311
 
 
312
/* Other Unix platforms use only PID checks. Even if pthread_atfork is
 
313
 * available, the behavior of dlclose isn't guaranteed by POSIX to
 
314
 * unregister the fork handler. */
 
315
 
 
316
#define CHECK_FORK_GETPID
 
317
 
 
318
#endif
 
319
 
 
320
#endif
 
321
 
 
322
#if defined(CHECK_FORK_MIXED)
 
323
 
 
324
extern PRBool usePthread_atfork;
 
325
#include <unistd.h>
 
326
extern pid_t myPid;
 
327
extern PRBool forked;
 
328
 
 
329
#define PARENT_FORKED() (usePthread_atfork ? forked : (myPid && myPid != getpid()))
 
330
 
 
331
#elif defined(CHECK_FORK_PTHREAD)
 
332
 
 
333
extern PRBool forked;
 
334
 
 
335
#define PARENT_FORKED() forked
 
336
 
 
337
#elif defined(CHECK_FORK_GETPID)
 
338
 
 
339
#include <unistd.h>
 
340
extern pid_t myPid;
 
341
 
 
342
#define PARENT_FORKED() (myPid && myPid != getpid())
 
343
    
 
344
#endif
 
345
 
 
346
extern PRBool parentForkedAfterC_Initialize;
 
347
extern PRBool sftkForkCheckDisabled;
272
348
 
273
349
#define CHECK_FORK() \
274
 
    do { if (forked) return CKR_DEVICE_ERROR; } while (0)
 
350
    do { \
 
351
        if (!sftkForkCheckDisabled && PARENT_FORKED()) { \
 
352
            FORK_ASSERT(); \
 
353
            return CKR_DEVICE_ERROR; \
 
354
        } \
 
355
    } while (0)
 
356
 
 
357
#define SKIP_AFTER_FORK(x) if (!parentForkedAfterC_Initialize) x
 
358
 
 
359
#define ENABLE_FORK_CHECK() \
 
360
    { \
 
361
        char* doForkCheck = getenv("NSS_STRICT_NOFORK"); \
 
362
        if ( doForkCheck && !strcmp(doForkCheck, "DISABLED") ) { \
 
363
            sftkForkCheckDisabled = PR_TRUE; \
 
364
        } \
 
365
    }
 
366
 
275
367
 
276
368
#else
277
369
 
 
370
/* non-Unix platforms, or fork check disabled */
 
371
 
278
372
#define CHECK_FORK()
279
 
 
280
 
#endif
 
373
#define SKIP_AFTER_FORK(x) x
 
374
#define ENABLE_FORK_CHECK()
 
375
 
 
376
#ifndef NO_FORK_CHECK
 
377
#define NO_FORK_CHECK
 
378
#endif
 
379
 
 
380
#endif
 
381
 
281
382
 
282
383
SEC_END_PROTOS
283
384