]> git.ipfire.org Git - people/arne_f/ipfire-3.x.git/blob - nss/patches/0001-Bug-695011-PEM-logging.patch
Merge remote-tracking branch 'arne_f/autoconf'
[people/arne_f/ipfire-3.x.git] / nss / patches / 0001-Bug-695011-PEM-logging.patch
1 From 5c61cdba435096ee6e65cee4dc9a473430643c07 Mon Sep 17 00:00:00 2001
2 From: Elio Maldonado <emaldona@redhat.com>
3 Date: Tue, 12 Apr 2011 09:31:48 -0700
4 Subject: [PATCH] Bug 695011 PEM logging
5
6 Use NSPR logging facilities for PEM logging to fix a segmenation violation
7 caused when user cannot for write a log file created by root
8 ---
9 mozilla/security/nss/lib/ckfw/pem/ckpem.h | 7 ++++-
10 mozilla/security/nss/lib/ckfw/pem/util.c | 30 ++++++++++++++++------------
11 2 files changed, 22 insertions(+), 15 deletions(-)
12
13 diff --git a/mozilla/security/nss/lib/ckfw/pem/ckpem.h b/mozilla/security/nss/lib/ckfw/pem/ckpem.h
14 index 839d40b..720525e 100644
15 --- a/mozilla/security/nss/lib/ckfw/pem/ckpem.h
16 +++ b/mozilla/security/nss/lib/ckfw/pem/ckpem.h
17 @@ -1,3 +1,6 @@
18 +#ifndef CKPEM_H
19 +#define CKPEM_H
20 +
21 #include "nssckmdt.h"
22 #include "nssckfw.h"
23 #include "ckfwtm.h"
24 @@ -254,8 +257,8 @@ unsigned int pem_PrivateModulusLen(pemLOWKEYPrivateKey *privk);
25 /* ptoken.c */
26 NSSCKMDToken * pem_NewToken(NSSCKFWInstance *fwInstance, CK_RV *pError);
27
28 +/* util.c */
29 void open_log();
30 -void close_log();
31 void plog(const char *fmt, ...);
32
33 -#define PEM_H 1
34 +#endif /* CKPEM_H */
35 diff --git a/mozilla/security/nss/lib/ckfw/pem/util.c b/mozilla/security/nss/lib/ckfw/pem/util.c
36 index 853f418..fafb924 100644
37 --- a/mozilla/security/nss/lib/ckfw/pem/util.c
38 +++ b/mozilla/security/nss/lib/ckfw/pem/util.c
39 @@ -41,6 +41,7 @@
40 #include "prtime.h"
41 #include "prlong.h"
42 #include "prerror.h"
43 +#include "prlog.h"
44 #include "prprf.h"
45 #include "plgetopt.h"
46 #include "prenv.h"
47 @@ -51,6 +52,9 @@
48 #include "cryptohi.h"
49 #include "secpkcs7.h"
50 #include "secerr.h"
51 +
52 +#include "ckpem.h"
53 +
54 #include <stdarg.h>
55
56 #define CHUNK_SIZE 512
57 @@ -267,34 +271,34 @@ ReadDERFromFile(SECItem *** derlist, char *filename, PRBool ascii,
58 return -1;
59 }
60
61 -FILE *plogfile;
62 +#ifdef DEBUG
63 +#define LOGGING_BUFFER_SIZE 400
64 +#define PEM_DEFAULT_LOG_FILE "/tmp/pkcs11.log"
65 +static const char *pemLogModuleName = "PEM";
66 +static PRLogModuleInfo* pemLogModule;
67 +#endif
68
69 void open_log()
70 {
71 #ifdef DEBUG
72 - plogfile = fopen("/tmp/pkcs11.log", "a");
73 -#endif
74 + const char *nsprLogFile = PR_GetEnv("NSPR_LOG_FILE");
75
76 - return;
77 -}
78 + pemLogModule = PR_NewLogModule(pemLogModuleName);
79
80 -void close_log()
81 -{
82 -#ifdef DEBUG
83 - fclose(plogfile);
84 + (void) PR_SetLogFile(nsprLogFile ? nsprLogFile : PEM_DEFAULT_LOG_FILE);
85 + /* If false, the log file will remain what it was before */
86 #endif
87 - return;
88 }
89
90 void plog(const char *fmt, ...)
91 {
92 #ifdef DEBUG
93 + char buf[LOGGING_BUFFER_SIZE];
94 va_list ap;
95
96 va_start(ap, fmt);
97 - vfprintf(plogfile, fmt, ap);
98 + PR_vsnprintf(buf, sizeof(buf), fmt, ap);
99 va_end(ap);
100 -
101 - fflush(plogfile);
102 + PR_LOG(pemLogModule, PR_LOG_DEBUG, ("%s", buf));
103 #endif
104 }
105 --
106 1.7.4.2
107