diff options
Diffstat (limited to 'src/verify.c')
-rw-r--r-- | src/verify.c | 175 |
1 files changed, 89 insertions, 86 deletions
diff --git a/src/verify.c b/src/verify.c index 1409889..4a108bc 100644 --- a/src/verify.c +++ b/src/verify.c | |||
@@ -202,7 +202,7 @@ uploader_find_frp (struct uploader_info *list, const char *fpr) | |||
202 | } | 202 | } |
203 | 203 | ||
204 | int | 204 | int |
205 | verify_directive_file (struct file_triplet *trp) | 205 | verify_directive_file (struct file_triplet *trp, int noath) |
206 | { | 206 | { |
207 | char *command; | 207 | char *command; |
208 | int rc; | 208 | int rc; |
@@ -220,105 +220,108 @@ verify_directive_file (struct file_triplet *trp) | |||
220 | 220 | ||
221 | if (fill_project_name (trp)) | 221 | if (fill_project_name (trp)) |
222 | return 1; | 222 | return 1; |
223 | |||
224 | md = dictionary_open (dict); | ||
225 | if (!md) | ||
226 | return 1; | ||
227 | |||
228 | command = triplet_expand_dictionary_query (dict, md, trp); | ||
229 | |||
230 | rc = dictionary_lookup (dict, md, command); | ||
231 | free (command); | ||
232 | if (rc) | ||
233 | { | ||
234 | logmsg (LOG_ERR, _("cannot get uploaders for %s"), trp->name); | ||
235 | dictionary_close (dict, md); | ||
236 | return 1; | ||
237 | } | ||
238 | |||
239 | nrows = dictionary_num_rows (dict); | ||
240 | if (nrows == 0) | ||
241 | { | ||
242 | logmsg (LOG_ERR, _("found no uploaders for %s"), trp->name); | ||
243 | dictionary_close (dict, md); | ||
244 | return 1; | ||
245 | } | ||
246 | 223 | ||
247 | ncols = dictionary_num_cols (dict); | 224 | if (!noath) |
248 | if (ncols < 4) | ||
249 | { | 225 | { |
250 | logmsg (LOG_ERR, | 226 | md = dictionary_open (dict); |
251 | _("project-uploader dictionary error: too few columns (%lu)"), | 227 | if (!md) |
252 | (unsigned long) ncols); | 228 | return 1; |
253 | dictionary_close (dict, md); | ||
254 | return 1; | ||
255 | } | ||
256 | 229 | ||
257 | head = tail = NULL; | 230 | command = triplet_expand_dictionary_query (dict, md, trp); |
258 | for (i = 0; i < nrows; i++) | ||
259 | { | ||
260 | const char *p; | ||
261 | struct uploader_info info, *ptr; | ||
262 | 231 | ||
263 | memset (&info, 0, sizeof (info)); | 232 | rc = dictionary_lookup (dict, md, command); |
264 | p = dictionary_result (dict, md, i, 0); | 233 | free (command); |
265 | if (p) | 234 | if (rc) |
266 | info.name = triplet_strdup (trp, p); | 235 | { |
267 | p = dictionary_result (dict, md, i, 1); | 236 | logmsg (LOG_ERR, _("cannot get uploaders for %s"), trp->name); |
268 | if (p) | 237 | dictionary_close (dict, md); |
269 | info.realname = triplet_strdup (trp, p); | 238 | return 1; |
270 | p = dictionary_result (dict, md, i, 2); | 239 | } |
271 | if (p) | ||
272 | info.email = triplet_strdup (trp, p); | ||
273 | p = dictionary_result (dict, md, i, 3); | ||
274 | if (p) | ||
275 | info.gpg_key = triplet_strdup (trp, p); | ||
276 | 240 | ||
277 | if (debug_level > 3) | 241 | nrows = dictionary_num_rows (dict); |
242 | if (nrows == 0) | ||
278 | { | 243 | { |
279 | logmsg (LOG_DEBUG, _("name: %s"), SP (info.name)); | 244 | logmsg (LOG_ERR, _("found no uploaders for %s"), trp->name); |
280 | logmsg (LOG_DEBUG, _("realname: %s"), SP (info.realname)); | 245 | dictionary_close (dict, md); |
281 | logmsg (LOG_DEBUG, _("gpg-key: %s"), SP (info.gpg_key)); | 246 | return 1; |
282 | logmsg (LOG_DEBUG, _("email: %s"), SP (info.email)); | ||
283 | } | 247 | } |
284 | 248 | ||
285 | if (!info.name || !info.realname || !info.gpg_key || !info.email) | 249 | ncols = dictionary_num_cols (dict); |
250 | if (ncols < 4) | ||
286 | { | 251 | { |
287 | logmsg (LOG_ERR, | 252 | logmsg (LOG_ERR, |
288 | _("project-uploader dictionary error: malformed row %lu"), | 253 | _("project-uploader dictionary error: too few columns (%lu)"), |
289 | (unsigned long) i); | 254 | (unsigned long) ncols); |
290 | /* FIXME: Memory not reclaimed */ | 255 | dictionary_close (dict, md); |
291 | continue; | 256 | return 1; |
292 | } | 257 | } |
293 | 258 | ||
294 | ptr = new_uploader_info (&info); | 259 | head = tail = NULL; |
295 | if (tail) | 260 | for (i = 0; i < nrows; i++) |
296 | tail->next = ptr; | 261 | { |
297 | else | 262 | const char *p; |
298 | head = ptr; | 263 | struct uploader_info info, *ptr; |
299 | tail = ptr; | ||
300 | } | ||
301 | 264 | ||
302 | dictionary_close (dict, md); | 265 | memset (&info, 0, sizeof (info)); |
303 | 266 | p = dictionary_result (dict, md, i, 0); | |
304 | if (!head) | 267 | if (p) |
305 | { | 268 | info.name = triplet_strdup (trp, p); |
306 | logmsg (LOG_ERR, _("no valid uploaders found for %s"), trp->name); | 269 | p = dictionary_result (dict, md, i, 1); |
307 | return 1; | 270 | if (p) |
308 | } | 271 | info.realname = triplet_strdup (trp, p); |
309 | 272 | p = dictionary_result (dict, md, i, 2); | |
310 | trp->uploader_list = head; | 273 | if (p) |
311 | trp->uploader = NULL; | 274 | info.email = triplet_strdup (trp, p); |
275 | p = dictionary_result (dict, md, i, 3); | ||
276 | if (p) | ||
277 | info.gpg_key = triplet_strdup (trp, p); | ||
278 | |||
279 | if (debug_level > 3) | ||
280 | { | ||
281 | logmsg (LOG_DEBUG, _("name: %s"), SP (info.name)); | ||
282 | logmsg (LOG_DEBUG, _("realname: %s"), SP (info.realname)); | ||
283 | logmsg (LOG_DEBUG, _("gpg-key: %s"), SP (info.gpg_key)); | ||
284 | logmsg (LOG_DEBUG, _("email: %s"), SP (info.email)); | ||
285 | } | ||
286 | |||
287 | if (!info.name || !info.realname || !info.gpg_key || !info.email) | ||
288 | { | ||
289 | logmsg (LOG_ERR, | ||
290 | _("project-uploader dictionary error: malformed row %lu"), | ||
291 | (unsigned long) i); | ||
292 | /* FIXME: Memory not reclaimed */ | ||
293 | continue; | ||
294 | } | ||
295 | |||
296 | ptr = new_uploader_info (&info); | ||
297 | if (tail) | ||
298 | tail->next = ptr; | ||
299 | else | ||
300 | head = ptr; | ||
301 | tail = ptr; | ||
302 | } | ||
303 | |||
304 | dictionary_close (dict, md); | ||
312 | 305 | ||
313 | if (verify_directive_signature (trp)) | 306 | if (!head) |
314 | { | 307 | { |
315 | /*FIXME: Update stats */ | 308 | logmsg (LOG_ERR, _("no valid uploaders found for %s"), trp->name); |
316 | logmsg (LOG_ERR, _("invalid signature for %s"), | 309 | return 1; |
317 | trp->name ? trp->name : "[unknown]"); | 310 | } |
318 | return 1; | 311 | |
312 | trp->uploader_list = head; | ||
313 | trp->uploader = NULL; | ||
314 | |||
315 | if (verify_directive_signature (trp)) | ||
316 | { | ||
317 | /*FIXME: Update stats */ | ||
318 | logmsg (LOG_ERR, _("invalid signature for %s"), | ||
319 | trp->name ? trp->name : "[unknown]"); | ||
320 | return 1; | ||
321 | } | ||
322 | else if (debug_level) | ||
323 | logmsg (LOG_DEBUG, _("%s: directive file signature OK"), trp->name); | ||
319 | } | 324 | } |
320 | else if (debug_level) | ||
321 | logmsg (LOG_DEBUG, _("%s: directive file signature OK"), trp->name); | ||
322 | 325 | ||
323 | if (debug_level > 1) | 326 | if (debug_level > 1) |
324 | { | 327 | { |