Mercurial > trustbridge
annotate cinst/main.c @ 169:701b7036c5dc
Windows implementation of port_realpath: NULL if file does not exist.
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Tue, 25 Mar 2014 13:20:23 +0100 |
parents | 8cfcd38a9bb3 |
children | 4a20bab3f806 |
rev | line source |
---|---|
137
4904fe01055d
Factor out windows specific parts
Andre Heinecke <aheinecke@intevation.de>
parents:
126
diff
changeset
|
1 /** |
4904fe01055d
Factor out windows specific parts
Andre Heinecke <aheinecke@intevation.de>
parents:
126
diff
changeset
|
2 * @file main.c |
4904fe01055d
Factor out windows specific parts
Andre Heinecke <aheinecke@intevation.de>
parents:
126
diff
changeset
|
3 * @brief Main entry point for the cinst process. |
25
92108a2120f1
Move certificatelist to common. Add cinst directory
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
4 * |
92108a2120f1
Move certificatelist to common. Add cinst directory
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
5 * The cinst process may or may not be run with elevated |
92108a2120f1
Move certificatelist to common. Add cinst directory
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
6 * privileges. When run with elevated privileges this |
92108a2120f1
Move certificatelist to common. Add cinst directory
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
7 * process will modify system wide certificate stores. |
92108a2120f1
Move certificatelist to common. Add cinst directory
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
8 * Otherwise only the users certificate stores are modified. |
92108a2120f1
Move certificatelist to common. Add cinst directory
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
9 * |
59
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
10 * It expects a certificatelist on stdin enclosed in a |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
11 * -----BEGIN CERTIFICATE LIST----- |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
12 * ... |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
13 * -----END CERTIFICATE LIST----- |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
14 * |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
15 * Followed by additional instruction lines of: |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
16 * I:<certificate> |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
17 * R:<certificate> |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
18 * |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
19 * It will only execute the instructions if the |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
20 * I and R instructions are also part of the signed |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
21 * certificate list. The signature is validated with the |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
22 * built in key. |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
23 * |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
24 * The special instruction "UNINSTALL" will cause the installer |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
25 * to remove all certificates (Even those marked with I) that |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
26 * are part of the list to be removed. |
25
92108a2120f1
Move certificatelist to common. Add cinst directory
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
27 * |
92108a2120f1
Move certificatelist to common. Add cinst directory
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
28 **/ |
92108a2120f1
Move certificatelist to common. Add cinst directory
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
29 #include <stdio.h> |
64
fb9f78f7ab2f
Improve error handling free memory before exiting. Include line endings in Marker lines
Andre Heinecke <aheinecke@intevation.de>
parents:
60
diff
changeset
|
30 #include <stdlib.h> |
59
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
31 #include <string.h> |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
32 #include <assert.h> |
148
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
33 #include <stdbool.h> |
59
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
34 |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
35 #include "strhelp.h" |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
36 #include "listutil.h" |
60
6acb1dae6185
Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents:
59
diff
changeset
|
37 #include "errorcodes.h" |
137
4904fe01055d
Factor out windows specific parts
Andre Heinecke <aheinecke@intevation.de>
parents:
126
diff
changeset
|
38 #include "windowsstore.h" |
125
24fb90ef8f6a
Fix install_certificates_win.
Andre Heinecke <aheinecke@intevation.de>
parents:
116
diff
changeset
|
39 |
68
8ffbb48528ae
Add certificate installation for windows
Andre Heinecke <aheinecke@intevation.de>
parents:
65
diff
changeset
|
40 /* The certificate list + instructions may only be so long as |
8ffbb48528ae
Add certificate installation for windows
Andre Heinecke <aheinecke@intevation.de>
parents:
65
diff
changeset
|
41 * twice the accepted certificatelist size */ |
8ffbb48528ae
Add certificate installation for windows
Andre Heinecke <aheinecke@intevation.de>
parents:
65
diff
changeset
|
42 #define MAX_INPUT_SIZE MAX_LINE_LENGTH * MAX_LINES * 2 |
8ffbb48528ae
Add certificate installation for windows
Andre Heinecke <aheinecke@intevation.de>
parents:
65
diff
changeset
|
43 |
59
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
44 /* @brief Read stdin into data structures. |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
45 * |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
46 * Reads from stdin and sorts the input into the respective |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
47 * variables. The pointers returned need to be freed by the caller. |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
48 * Terminates in OOM conditions. |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
49 * |
60
6acb1dae6185
Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents:
59
diff
changeset
|
50 * The caller needs to free the memory allocated by this function |
6acb1dae6185
Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents:
59
diff
changeset
|
51 * even when an error is returned. |
6acb1dae6185
Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents:
59
diff
changeset
|
52 * |
148
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
53 * Uninstall certificates are all certificates that are pa |
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
54 * |
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
55 * @param[out] certificate_list the parsed certificate list |
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
56 * @param[out] to_install strv of installation instructions or NULL |
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
57 * @param[out] to_remove strv of remove instructions or NULL |
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
58 * @param[out] all_certs strv of uninstallation instructions or NULL |
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
59 * |
60
6acb1dae6185
Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents:
59
diff
changeset
|
60 * @returns: 0 on success. An error code otherwise. |
59
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
61 */ |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
62 int |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
63 readInput (char **certificate_list, char ***to_install, |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
64 char ***to_remove, char ***all_certs) |
59
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
65 { |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
66 int lines_read = 0; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
67 int readingList = 0; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
68 size_t list_size = 0; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
69 char buf[MAX_LINE_LENGTH + 2]; |
59
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
70 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
71 if (*certificate_list || *to_install || *to_remove) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
72 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
73 printf ("Error invalid parameters\n"); |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
74 return -1; |
90
899fcddb92d0
Check parameters in readInput
Andre Heinecke <aheinecke@intevation.de>
parents:
68
diff
changeset
|
75 } |
899fcddb92d0
Check parameters in readInput
Andre Heinecke <aheinecke@intevation.de>
parents:
68
diff
changeset
|
76 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
77 while (fgets (buf, MAX_LINE_LENGTH + 1, stdin) ) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
78 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
79 size_t len = strlen (buf); /* fgets ensures buf is terminated */ |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
80 if (len <= 3) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
81 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
82 printf ("Line too short.\n"); |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
83 return ERR_INVALID_INPUT; |
91
80ab2168760f
Also add output size handling to str_append_str
Andre Heinecke <aheinecke@intevation.de>
parents:
90
diff
changeset
|
84 } |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
85 if (lines_read++ > MAX_LINES) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
86 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
87 printf ("Too many lines\n"); |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
88 return ERR_TOO_MUCH_INPUT; |
59
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
89 } |
126
898446d9d23e
Normalize input if neccessary
Andre Heinecke <aheinecke@intevation.de>
parents:
125
diff
changeset
|
90 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
91 if (buf[len - 2] != '\r') |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
92 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
93 if (buf[len - 1] != '\n') |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
94 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
95 printf ("Line too long.\n"); |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
96 return ERR_INVALID_INPUT; |
126
898446d9d23e
Normalize input if neccessary
Andre Heinecke <aheinecke@intevation.de>
parents:
125
diff
changeset
|
97 } |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
98 buf[len - 1] = '\r'; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
99 buf[len] = '\n'; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
100 buf[len + 1] = '\0'; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
101 len++; |
126
898446d9d23e
Normalize input if neccessary
Andre Heinecke <aheinecke@intevation.de>
parents:
125
diff
changeset
|
102 } |
898446d9d23e
Normalize input if neccessary
Andre Heinecke <aheinecke@intevation.de>
parents:
125
diff
changeset
|
103 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
104 if (strcmp ("-----BEGIN CERTIFICATE LIST-----\r\n", buf) == 0) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
105 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
106 readingList = 1; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
107 continue; |
59
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
108 } |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
109 if (strcmp ("-----END CERTIFICATE LIST-----\r\n", buf) == 0) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
110 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
111 readingList = 0; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
112 continue; |
59
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
113 } |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
114 if (readingList) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
115 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
116 str_append_str (certificate_list, &list_size, buf, len); |
59
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
117 } |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
118 else if (strcmp ("UNINSTALL\r\n", buf) == 0) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
119 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
120 /* Remove trailing \r\n */ |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
121 strv_append (to_remove, buf, len - 2); |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
122 continue; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
123 } |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
124 if (*buf == 'I') |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
125 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
126 /* Remove leading I: and trailing \r\n */ |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
127 strv_append (readingList ? all_certs : to_install, |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
128 buf + 2, len - 4); |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
129 continue; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
130 } |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
131 if (*buf == 'R') |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
132 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
133 /* Remove leading R: and trailing \r\n */ |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
134 strv_append (readingList ? all_certs : to_remove, buf + 2, len - 4); |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
135 continue; |
59
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
136 } |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
137 } |
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
138 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
139 return 0; |
59
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
140 } |
148
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
141 |
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
142 /** @brief Check that the insturctions match to the list |
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
143 * |
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
144 * Only certificates part of the certificate_list are allowed |
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
145 * for installation. |
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
146 * |
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
147 * @param[in] all_certs strv of all valid certificates in a list |
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
148 * @param[in] to_validate strv of instructions |
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
149 * |
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
150 * @returns 0 on success, an error otherwise |
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
151 */ |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
152 int |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
153 validate_instructions (char **all_certs, char **to_validate) |
64
fb9f78f7ab2f
Improve error handling free memory before exiting. Include line endings in Marker lines
Andre Heinecke <aheinecke@intevation.de>
parents:
60
diff
changeset
|
154 { |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
155 int i = 0, j = 0; |
148
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
156 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
157 if (!all_certs || strv_length (all_certs) < 1) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
158 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
159 /* Invalid parameters */ |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
160 return -1; |
148
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
161 } |
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
162 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
163 if (to_validate == NULL) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
164 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
165 /* Nothing is valid */ |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
166 return 0; |
148
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
167 } |
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
168 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
169 for (i = 0; to_validate[i]; i++) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
170 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
171 bool found = false; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
172 for (j = 0; all_certs[j]; j++) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
173 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
174 if (strncmp (to_validate[i], all_certs[j], MAX_LINE_LENGTH - 2) == |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
175 0) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
176 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
177 found = true; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
178 break; |
148
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
179 } |
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
180 } |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
181 if (!found) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
182 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
183 printf ("Install instruction with invalid certificate\n."); |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
184 return ERR_INVALID_INSTRUCTIONS; |
148
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
185 } |
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
186 } |
65
e4088afd5281
Comment out validate instructions for now to avoid unused warnings
Andre Heinecke <aheinecke@intevation.de>
parents:
64
diff
changeset
|
187 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
188 return 0; |
64
fb9f78f7ab2f
Improve error handling free memory before exiting. Include line endings in Marker lines
Andre Heinecke <aheinecke@intevation.de>
parents:
60
diff
changeset
|
189 } |
148
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
190 |
68
8ffbb48528ae
Add certificate installation for windows
Andre Heinecke <aheinecke@intevation.de>
parents:
65
diff
changeset
|
191 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
192 int |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
193 main () |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
194 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
195 char **to_install = NULL; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
196 char **to_remove = NULL; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
197 char **all_certs = NULL; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
198 char *certificate_list = NULL; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
199 size_t list_len = 0; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
200 int ret = -1; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
201 bool uninstall = false; |
60
6acb1dae6185
Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents:
59
diff
changeset
|
202 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
203 ret = readInput (&certificate_list, &to_install, &to_remove, &all_certs); |
148
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
204 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
205 if (ret) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
206 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
207 return ret; |
60
6acb1dae6185
Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents:
59
diff
changeset
|
208 } |
6acb1dae6185
Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents:
59
diff
changeset
|
209 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
210 if (!certificate_list) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
211 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
212 return ERR_INVALID_INPUT_NO_LIST; |
60
6acb1dae6185
Use strn functions and improve error handling.
Andre Heinecke <aheinecke@intevation.de>
parents:
59
diff
changeset
|
213 } |
59
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
214 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
215 list_len = strnlen (certificate_list, MAX_INPUT_SIZE); |
59
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
216 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
217 ret = verify_list (certificate_list, list_len); |
64
fb9f78f7ab2f
Improve error handling free memory before exiting. Include line endings in Marker lines
Andre Heinecke <aheinecke@intevation.de>
parents:
60
diff
changeset
|
218 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
219 if (ret) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
220 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
221 return ERR_INVALID_SIGNATURE; |
64
fb9f78f7ab2f
Improve error handling free memory before exiting. Include line endings in Marker lines
Andre Heinecke <aheinecke@intevation.de>
parents:
60
diff
changeset
|
222 } |
fb9f78f7ab2f
Improve error handling free memory before exiting. Include line endings in Marker lines
Andre Heinecke <aheinecke@intevation.de>
parents:
60
diff
changeset
|
223 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
224 if (!strv_length (to_install) && !strv_length (to_remove) ) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
225 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
226 return ERR_NO_INSTRUCTIONS; |
64
fb9f78f7ab2f
Improve error handling free memory before exiting. Include line endings in Marker lines
Andre Heinecke <aheinecke@intevation.de>
parents:
60
diff
changeset
|
227 } |
fb9f78f7ab2f
Improve error handling free memory before exiting. Include line endings in Marker lines
Andre Heinecke <aheinecke@intevation.de>
parents:
60
diff
changeset
|
228 |
68
8ffbb48528ae
Add certificate installation for windows
Andre Heinecke <aheinecke@intevation.de>
parents:
65
diff
changeset
|
229 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
230 /* Check that the instructions are ok to execute */ |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
231 if (to_install) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
232 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
233 ret = validate_instructions (all_certs, to_install); |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
234 if (ret) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
235 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
236 return ret; |
148
095d0e7f8ed4
Add instruction verification and handle uninstall command in input
Andre Heinecke <aheinecke@intevation.de>
parents:
137
diff
changeset
|
237 } |
64
fb9f78f7ab2f
Improve error handling free memory before exiting. Include line endings in Marker lines
Andre Heinecke <aheinecke@intevation.de>
parents:
60
diff
changeset
|
238 } |
68
8ffbb48528ae
Add certificate installation for windows
Andre Heinecke <aheinecke@intevation.de>
parents:
65
diff
changeset
|
239 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
240 if (to_remove) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
241 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
242 if (to_remove[0] |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
243 && strncmp ("UNINSTALL", to_remove[0], MAX_LINE_LENGTH) == 0) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
244 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
245 uninstall = true; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
246 strv_free (to_remove); |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
247 to_remove = NULL; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
248 } |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
249 else |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
250 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
251 ret = validate_instructions (all_certs, to_remove); |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
252 if (ret) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
253 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
254 return ret; |
68
8ffbb48528ae
Add certificate installation for windows
Andre Heinecke <aheinecke@intevation.de>
parents:
65
diff
changeset
|
255 } |
8ffbb48528ae
Add certificate installation for windows
Andre Heinecke <aheinecke@intevation.de>
parents:
65
diff
changeset
|
256 } |
8ffbb48528ae
Add certificate installation for windows
Andre Heinecke <aheinecke@intevation.de>
parents:
65
diff
changeset
|
257 } |
8ffbb48528ae
Add certificate installation for windows
Andre Heinecke <aheinecke@intevation.de>
parents:
65
diff
changeset
|
258 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
259 if (uninstall) |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
260 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
261 /* To uninstall does not have to be verified as it part of the |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
262 * signed list.*/ |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
263 to_remove = all_certs; |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
264 } |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
265 else |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
266 { |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
267 strv_free (all_certs); |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
268 all_certs = NULL; |
68
8ffbb48528ae
Add certificate installation for windows
Andre Heinecke <aheinecke@intevation.de>
parents:
65
diff
changeset
|
269 } |
8ffbb48528ae
Add certificate installation for windows
Andre Heinecke <aheinecke@intevation.de>
parents:
65
diff
changeset
|
270 |
8ffbb48528ae
Add certificate installation for windows
Andre Heinecke <aheinecke@intevation.de>
parents:
65
diff
changeset
|
271 #ifdef WIN32 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
272 return write_stores_win (to_install, to_remove, true); |
68
8ffbb48528ae
Add certificate installation for windows
Andre Heinecke <aheinecke@intevation.de>
parents:
65
diff
changeset
|
273 #endif |
8ffbb48528ae
Add certificate installation for windows
Andre Heinecke <aheinecke@intevation.de>
parents:
65
diff
changeset
|
274 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
275 /* Make valgrind happy */ |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
276 strv_free (to_install); |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
277 strv_free (to_remove); |
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
278 free (certificate_list); |
59
3f6378647371
Start work on cinst. Strhelp new helpers to work with C String
Andre Heinecke <aheinecke@intevation.de>
parents:
26
diff
changeset
|
279 |
163
8cfcd38a9bb3
Change coding style for cinst main / windowsstore to GNU
Andre Heinecke <aheinecke@intevation.de>
parents:
161
diff
changeset
|
280 return 0; |
25
92108a2120f1
Move certificatelist to common. Add cinst directory
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
281 } |