Mercurial > trustbridge
annotate cinst/mozilla.c @ 228:19de529ce7fb
Moved debug prefix to macro and added component specific prefix.
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Thu, 27 Mar 2014 18:31:26 +0100 |
parents | 29467940b07b |
children | e99e39d72af2 |
rev | line source |
---|---|
121
4bb5f295987b
Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents:
119
diff
changeset
|
1 /** |
4bb5f295987b
Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents:
119
diff
changeset
|
2 * @file |
4bb5f295987b
Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents:
119
diff
changeset
|
3 * @brief Mozilla installation process |
99
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
4 * |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
5 * Reads from stdin a list of instructions in the form: |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
6 * |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
7 * I:<base64 DER econded certificate>\r\n |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
8 * R:<base64 DER econded certificate>\r\n |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
9 * ... |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
10 * |
130
ffb20e76e7d0
Fix max line length documentation
Andre Heinecke <aheinecke@intevation.de>
parents:
121
diff
changeset
|
11 * The maximum size of an input line is 9999 characters |
99
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
12 * (including the \r\n) at the end of the line. |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
13 * |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
14 * Certificates marked with I: will be installed and the ones |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
15 * marked with R: will be searched and if available removed from |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
16 * the databases. |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
17 * |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
18 * This tool tries to find all NSS databases the user has |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
19 * access to and to execute the instructions on all of them. |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
20 * |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
21 * If there are other processes accessing the databases the caller |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
22 * has to ensure that those are terminated before this process is |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
23 * executed. |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
24 * |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
25 * Returns 0 on success (Even when no stores where found) an error value |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
26 * as defined in errorcodes.h otherwise. |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
27 * |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
28 * Success messages are written to stdout. Errors to stderr. For logging |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
29 * purposes each installation / removal of a certificate will be reported |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
30 * with the profile name that it modified. |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
31 * |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
32 */ |
bc1e6732f43c
Add specification and some cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
44
diff
changeset
|
33 |
44
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
34 /* @brief IniParser for mozilla profiles.ini |
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
35 * |
110 | 36 * Parse data to find values formed in |
44
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
37 * |
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
38 * [Profile99] |
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
39 * IsRelative=1 |
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
40 * Path=Profiles/fooo.bar |
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
41 * |
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
42 * or |
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
43 * [Profile0] |
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
44 * IsRelative=0 |
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
45 * Path=c:\foo\bar\baz |
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
46 * |
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
47 * Mozilla also accepts the ini file on Windows even if it is UTF-16 |
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
48 * encoded. |
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
49 * */ |
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
50 |
173
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
51 #include <dirent.h> |
224
689b94dd89a9
Wrote FindNSS to build against nss without pkg-config support (Windows).
Sascha Wilde <wilde@intevation.de>
parents:
223
diff
changeset
|
52 #include <cert.h> |
689b94dd89a9
Wrote FindNSS to build against nss without pkg-config support (Windows).
Sascha Wilde <wilde@intevation.de>
parents:
223
diff
changeset
|
53 #include <certt.h> |
689b94dd89a9
Wrote FindNSS to build against nss without pkg-config support (Windows).
Sascha Wilde <wilde@intevation.de>
parents:
223
diff
changeset
|
54 #include <nss.h> |
689b94dd89a9
Wrote FindNSS to build against nss without pkg-config support (Windows).
Sascha Wilde <wilde@intevation.de>
parents:
223
diff
changeset
|
55 #include <pk11pub.h> |
119
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
56 #include <stdbool.h> |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
57 #include <stdio.h> |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
58 #include <stdlib.h> |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
59 #include <string.h> |
173
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
60 #include <sys/types.h> |
119
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
61 |
226
d7788db3bdde
Make locale includes distinguishable from system includes.
Sascha Wilde <wilde@intevation.de>
parents:
224
diff
changeset
|
62 #include "debug.h" |
d7788db3bdde
Make locale includes distinguishable from system includes.
Sascha Wilde <wilde@intevation.de>
parents:
224
diff
changeset
|
63 #include "errorcodes.h" |
d7788db3bdde
Make locale includes distinguishable from system includes.
Sascha Wilde <wilde@intevation.de>
parents:
224
diff
changeset
|
64 #include "portpath.h" |
d7788db3bdde
Make locale includes distinguishable from system includes.
Sascha Wilde <wilde@intevation.de>
parents:
224
diff
changeset
|
65 #include "strhelp.h" |
113
02ad0922c01f
Start over (only leave comments).
Sascha Wilde <wilde@intevation.de>
parents:
110
diff
changeset
|
66 |
228
19de529ce7fb
Moved debug prefix to macro and added component specific prefix.
Sascha Wilde <wilde@intevation.de>
parents:
227
diff
changeset
|
67 #define DEBUGPREFIX "MOZ-" |
19de529ce7fb
Moved debug prefix to macro and added component specific prefix.
Sascha Wilde <wilde@intevation.de>
parents:
227
diff
changeset
|
68 |
113
02ad0922c01f
Start over (only leave comments).
Sascha Wilde <wilde@intevation.de>
parents:
110
diff
changeset
|
69 #ifndef _WIN32 |
197
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
70 #define CONFDIRS ".mozilla", ".thunderbird" |
223
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
71 #define TARGET_LINUX 1 |
113
02ad0922c01f
Start over (only leave comments).
Sascha Wilde <wilde@intevation.de>
parents:
110
diff
changeset
|
72 #else |
197
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
73 #define CONFDIRS "Mozilla", "Thunderbird" |
223
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
74 #define TARGET_LINUX 0 |
113
02ad0922c01f
Start over (only leave comments).
Sascha Wilde <wilde@intevation.de>
parents:
110
diff
changeset
|
75 #endif |
02ad0922c01f
Start over (only leave comments).
Sascha Wilde <wilde@intevation.de>
parents:
110
diff
changeset
|
76 |
147
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
77 #define LINEBUFLEN 1000 |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
78 |
119
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
79 /** |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
80 * @brief Global Return Code |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
81 * |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
82 * This will be retuned by the programm and might be set to an |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
83 * error code on fatal errors and to and warning code on non-fatal |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
84 * errors. In case of mor than one warning the warning codes will be |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
85 * ORed together. |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
86 */ |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
87 int return_code = 0; |
44
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
88 |
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
89 /** |
194
d4e97c9b199f
Use %APPDATA% as config bse dir on windows. Much simpler.
Sascha Wilde <wilde@intevation.de>
parents:
181
diff
changeset
|
90 * @brief Return configuration base directory. |
d4e97c9b199f
Use %APPDATA% as config bse dir on windows. Much simpler.
Sascha Wilde <wilde@intevation.de>
parents:
181
diff
changeset
|
91 * @returns A pointer to a string containing the path to the base |
d4e97c9b199f
Use %APPDATA% as config bse dir on windows. Much simpler.
Sascha Wilde <wilde@intevation.de>
parents:
181
diff
changeset
|
92 * directory holding the configuration directories for e.g. mozilla |
d4e97c9b199f
Use %APPDATA% as config bse dir on windows. Much simpler.
Sascha Wilde <wilde@intevation.de>
parents:
181
diff
changeset
|
93 * and thunderbird. |
180
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
94 */ |
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
95 static char * |
194
d4e97c9b199f
Use %APPDATA% as config bse dir on windows. Much simpler.
Sascha Wilde <wilde@intevation.de>
parents:
181
diff
changeset
|
96 get_conf_basedir() |
180
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
97 { |
194
d4e97c9b199f
Use %APPDATA% as config bse dir on windows. Much simpler.
Sascha Wilde <wilde@intevation.de>
parents:
181
diff
changeset
|
98 char *cdir, *envvar; |
180
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
99 |
223
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
100 if (TARGET_LINUX) |
194
d4e97c9b199f
Use %APPDATA% as config bse dir on windows. Much simpler.
Sascha Wilde <wilde@intevation.de>
parents:
181
diff
changeset
|
101 envvar = "HOME" ; |
180
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
102 else |
194
d4e97c9b199f
Use %APPDATA% as config bse dir on windows. Much simpler.
Sascha Wilde <wilde@intevation.de>
parents:
181
diff
changeset
|
103 envvar = "APPDATA"; |
180
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
104 |
194
d4e97c9b199f
Use %APPDATA% as config bse dir on windows. Much simpler.
Sascha Wilde <wilde@intevation.de>
parents:
181
diff
changeset
|
105 if ((cdir = getenv(envvar)) != NULL) |
d4e97c9b199f
Use %APPDATA% as config bse dir on windows. Much simpler.
Sascha Wilde <wilde@intevation.de>
parents:
181
diff
changeset
|
106 return cdir; |
d4e97c9b199f
Use %APPDATA% as config bse dir on windows. Much simpler.
Sascha Wilde <wilde@intevation.de>
parents:
181
diff
changeset
|
107 else |
180
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
108 { |
228
19de529ce7fb
Moved debug prefix to macro and added component specific prefix.
Sascha Wilde <wilde@intevation.de>
parents:
227
diff
changeset
|
109 DEBUGPRINTF("FATAL! No %s in environment.\n", envvar); |
180
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
110 exit(ERR_MOZ_HOMELESS); |
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
111 } |
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
112 } |
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
113 |
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
114 /** |
119
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
115 * @brief Get a list of all mozilla profile directories |
44
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
116 * |
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
117 * Read the profiles.ini and extract all profile paths from that. |
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
118 * |
121
4bb5f295987b
Fix doxygen documentation.
Sascha Wilde <wilde@intevation.de>
parents:
119
diff
changeset
|
119 * @param[in] inifile_name path of the profile.ini to read. |
44
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
120 * @return NULL terminated array of strings containing containing the |
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
121 * absolute path of the profile directories. The array needs to |
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
122 * be freed by the caller. |
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
123 */ |
119
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
124 static char ** |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
125 get_profile_dirs (char *inifile_name) |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
126 { |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
127 char **dirs = NULL; |
147
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
128 char *inifile_dirname; |
119
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
129 FILE *inifile; |
147
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
130 char line[LINEBUFLEN]; |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
131 char *key; |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
132 char *value; |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
133 char path[LINEBUFLEN]; |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
134 char *fqpath; |
119
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
135 bool inprofile = false; |
147
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
136 bool relative_path = false; |
44
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
137 |
119
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
138 if ((inifile = fopen(inifile_name, "r")) != NULL) |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
139 { |
228
19de529ce7fb
Moved debug prefix to macro and added component specific prefix.
Sascha Wilde <wilde@intevation.de>
parents:
227
diff
changeset
|
140 DEBUGPRINTF("Searching for profile paths in: '%s'\n", inifile_name); |
175
6fa0e12ae1d2
Added more debug output.
Sascha Wilde <wilde@intevation.de>
parents:
174
diff
changeset
|
141 |
147
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
142 inifile_dirname = port_dirname(inifile_name); |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
143 while (fgets(line, LINEBUFLEN, inifile) != NULL) |
119
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
144 { |
147
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
145 /* Determine if we are in an profile section */ |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
146 if (str_starts_with(line, "[Profile")) |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
147 { |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
148 relative_path = false; |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
149 inprofile = true; |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
150 } |
119
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
151 else if (line[0] == '[') |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
152 inprofile = false; |
147
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
153 |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
154 /* If we are in a profile parse path related stuff */ |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
155 if (inprofile) |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
156 { |
157
a46a4b443410
Use strtok instead of strsep for portability.
Sascha Wilde <wilde@intevation.de>
parents:
147
diff
changeset
|
157 key = strtok(line, "="); |
a46a4b443410
Use strtok instead of strsep for portability.
Sascha Wilde <wilde@intevation.de>
parents:
147
diff
changeset
|
158 value = strtok(NULL, "="); |
147
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
159 str_trim(&value); |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
160 if (str_equal(key, "Path")) |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
161 { |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
162 if (relative_path) |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
163 snprintf(path, LINEBUFLEN, "%s/%s", inifile_dirname, value); |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
164 else |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
165 strncpy(path, value, LINEBUFLEN); |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
166 if ((fqpath = port_realpath(path)) != NULL) |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
167 { |
228
19de529ce7fb
Moved debug prefix to macro and added component specific prefix.
Sascha Wilde <wilde@intevation.de>
parents:
227
diff
changeset
|
168 DEBUGPRINTF("Found profile path: '%s'\n", fqpath); |
147
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
169 strv_append(&dirs, fqpath, strlen(fqpath)); |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
170 free (fqpath); |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
171 } |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
172 else |
175
6fa0e12ae1d2
Added more debug output.
Sascha Wilde <wilde@intevation.de>
parents:
174
diff
changeset
|
173 { |
228
19de529ce7fb
Moved debug prefix to macro and added component specific prefix.
Sascha Wilde <wilde@intevation.de>
parents:
227
diff
changeset
|
174 DEBUGPRINTF("WARN! Non existent profile path: '%s'\n", path); |
175
6fa0e12ae1d2
Added more debug output.
Sascha Wilde <wilde@intevation.de>
parents:
174
diff
changeset
|
175 return_code |= WARN_MOZ_PROFILE_DOES_NOT_EXIST; |
6fa0e12ae1d2
Added more debug output.
Sascha Wilde <wilde@intevation.de>
parents:
174
diff
changeset
|
176 } |
147
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
177 } |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
178 else if (str_equal(key, "IsRelative") && |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
179 str_starts_with(value, "1")) |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
180 relative_path = true; |
fc9af77b06b9
Completed profile.ini parser.
Sascha Wilde <wilde@intevation.de>
parents:
130
diff
changeset
|
181 } |
119
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
182 } |
179
8fafd0fc2173
get_profile_dirs(): close filedescriptor again. (found by cppcheck)
Bernhard Reiter <bernhard@intevation.de>
parents:
177
diff
changeset
|
183 fclose(inifile); |
119
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
184 } |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
185 else |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
186 { |
228
19de529ce7fb
Moved debug prefix to macro and added component specific prefix.
Sascha Wilde <wilde@intevation.de>
parents:
227
diff
changeset
|
187 DEBUGPRINTF("WARN! Could not open ini file: '%s'\n", inifile_name); |
119
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
188 return_code |= WARN_MOZ_FAILED_TO_OPEN_INI; |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
189 } |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
190 return dirs; |
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
191 } |
44
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
192 |
173
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
193 /** |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
194 * @brief Search for mozilla profiles.ini files |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
195 * |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
196 * Use well known paths and heuristics to find the current users |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
197 * profiles.ini files on GNU/Linux and Windows systems. |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
198 * |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
199 * @return NULL terminated array of strings containing the absolute |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
200 * path of the profiles.ini files. The array needs to be freed by the |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
201 * caller. |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
202 */ |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
203 static char ** |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
204 get_profile_inis () |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
205 { |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
206 char **inis = NULL; |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
207 char path[LINEBUFLEN]; |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
208 char *fqpath; |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
209 DIR *mozdir; |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
210 struct dirent *mozdirent; |
194
d4e97c9b199f
Use %APPDATA% as config bse dir on windows. Much simpler.
Sascha Wilde <wilde@intevation.de>
parents:
181
diff
changeset
|
211 char *confbase = get_conf_basedir(); |
197
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
212 const char *confdirs[] = { CONFDIRS, NULL }; |
173
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
213 |
197
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
214 for (int i=0; confdirs[i] != NULL; i++) |
173
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
215 { |
197
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
216 snprintf(path, LINEBUFLEN, "%s/%s", |
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
217 confbase, |
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
218 confdirs[i]); |
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
219 if ((mozdir = opendir(path)) != NULL) |
180
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
220 { |
197
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
221 while ((mozdirent = readdir(mozdir)) != NULL) |
180
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
222 { |
197
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
223 snprintf(path, LINEBUFLEN, "%s/%s/%s", |
194
d4e97c9b199f
Use %APPDATA% as config bse dir on windows. Much simpler.
Sascha Wilde <wilde@intevation.de>
parents:
181
diff
changeset
|
224 confbase, |
197
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
225 confdirs[i], |
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
226 mozdirent->d_name); |
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
227 if (port_isdir(path) |
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
228 && (strcmp(mozdirent->d_name, "..") != 0)) |
180
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
229 { |
197
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
230 snprintf(path, LINEBUFLEN, "%s/%s/%s/%s", |
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
231 confbase, |
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
232 confdirs[i], |
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
233 mozdirent->d_name, |
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
234 "profiles.ini"); |
228
19de529ce7fb
Moved debug prefix to macro and added component specific prefix.
Sascha Wilde <wilde@intevation.de>
parents:
227
diff
changeset
|
235 DEBUGPRINTF("checking for %s...\n", path); |
197
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
236 if ((fqpath = port_realpath(path)) != NULL) |
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
237 { |
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
238 strv_append(&inis, fqpath, strlen(fqpath)); |
228
19de529ce7fb
Moved debug prefix to macro and added component specific prefix.
Sascha Wilde <wilde@intevation.de>
parents:
227
diff
changeset
|
239 DEBUGPRINTF("Found mozilla ini file: '%s'\n", fqpath); |
197
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
240 free(fqpath); |
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
241 } |
180
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
242 } |
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
243 } |
197
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
244 closedir(mozdir); |
180
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
245 } |
197
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
246 else |
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
247 { |
228
19de529ce7fb
Moved debug prefix to macro and added component specific prefix.
Sascha Wilde <wilde@intevation.de>
parents:
227
diff
changeset
|
248 DEBUGPRINTF("Could not open %s/%s\n", confbase, confdirs[i]); |
197
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
249 } |
180
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
250 } |
197
5d380b662198
Search for thunderbird profiles, too.
Sascha Wilde <wilde@intevation.de>
parents:
195
diff
changeset
|
251 if (inis == NULL) |
180
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
252 { |
228
19de529ce7fb
Moved debug prefix to macro and added component specific prefix.
Sascha Wilde <wilde@intevation.de>
parents:
227
diff
changeset
|
253 DEBUGPRINTF("No ini files found - will do nothing!\n"); |
180
344b8a79ad2e
Implemented detection profile paths for Windows Vista/7.
Sascha Wilde <wilde@intevation.de>
parents:
177
diff
changeset
|
254 exit(WARN_MOZ_NO_PROFILES); |
173
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
255 } |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
256 return inis; |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
257 } |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
258 |
223
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
259 /** |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
260 * @brief list certificates from nss certificate store |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
261 * @param[in] confdir the directory with the certificate store |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
262 */ |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
263 static void |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
264 nss_list_certs (char *confdir) |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
265 { |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
266 CERTCertList *list; |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
267 CERTCertListNode *node; |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
268 char *name; |
224
689b94dd89a9
Wrote FindNSS to build against nss without pkg-config support (Windows).
Sascha Wilde <wilde@intevation.de>
parents:
223
diff
changeset
|
269 |
223
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
270 if (NSS_Initialize(confdir, "", "", "secmod.db", NSS_INIT_READONLY) |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
271 == SECSuccess) |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
272 { |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
273 list = PK11_ListCerts(PK11CertListAll, NULL); |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
274 for (node = CERT_LIST_HEAD(list); !CERT_LIST_END(node, list); |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
275 node = CERT_LIST_NEXT(node)) { |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
276 name = node->appData; |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
277 |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
278 printf ("Found certificate \"%s\"\n", name); |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
279 } |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
280 CERT_DestroyCertList(list); |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
281 NSS_Shutdown(); |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
282 } |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
283 else |
227
29467940b07b
Fixed naming of debugging print macro.
Sascha Wilde <wilde@intevation.de>
parents:
226
diff
changeset
|
284 DEBUGPRINTF("Could not open nss cer store in %s!", confdir); |
223
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
285 } |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
286 |
173
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
287 |
113
02ad0922c01f
Start over (only leave comments).
Sascha Wilde <wilde@intevation.de>
parents:
110
diff
changeset
|
288 int |
173
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
289 main () |
113
02ad0922c01f
Start over (only leave comments).
Sascha Wilde <wilde@intevation.de>
parents:
110
diff
changeset
|
290 { |
173
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
291 int y = 0; |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
292 char **mozinis, **pdirs; |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
293 if ((mozinis = get_profile_inis()) != NULL) |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
294 while (mozinis[y] != NULL) |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
295 { |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
296 pdirs = |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
297 get_profile_dirs(mozinis[y++]); |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
298 if (pdirs != NULL) |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
299 { |
223
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
300 for (int x=0; pdirs[x] != NULL; x++) |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
301 { |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
302 puts(pdirs[x]); |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
303 nss_list_certs(pdirs[x]); |
d29997e09177
NSS first Blood. Added code to list certs in found stores.
Sascha Wilde <wilde@intevation.de>
parents:
197
diff
changeset
|
304 } |
173
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
305 strv_free(pdirs); |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
306 } |
a9e4454dee97
Implemented searching $HOME/.mozilla for profiles.ini on Linux.
Sascha Wilde <wilde@intevation.de>
parents:
157
diff
changeset
|
307 } |
119
24ca8e2ceecf
First step of simple mozilla ini parser
Sascha Wilde <wilde@intevation.de>
parents:
113
diff
changeset
|
308 exit(return_code); |
44
b3e8e047bc2c
Commit first scratch of mozilla installer
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
309 } |