summaryrefslogtreecommitdiffabout
path: root/src
authorSergey Poznyakoff <gray@gnu.org.ua>2012-12-30 12:52:15 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2012-12-30 12:52:15 (GMT)
commit1fa130754f837e514e7eb231f4e0c6e1b1419271 (patch) (unidiff)
tree4abf3f4178481ba6b95d44fad22bb563a1aeba3c /src
parenta7278cd9133596c3adbad2fc03571ce8bea18272 (diff)
downloadwydawca-1fa130754f837e514e7eb231f4e0c6e1b1419271.tar.gz
wydawca-1fa130754f837e514e7eb231f4e0c6e1b1419271.tar.bz2
Check returns from pipe, dup2 and chmod. Don't use obsolete MU functions.
Diffstat (limited to 'src') (more/less context) (ignore whitespace changes)
-rw-r--r--src/directive.c7
-rw-r--r--src/exec.c23
-rw-r--r--src/mail.c68
-rw-r--r--src/triplet.c2
-rw-r--r--src/wydawca.h2
5 files changed, 49 insertions, 53 deletions
diff --git a/src/directive.c b/src/directive.c
index 8893675..cb656e7 100644
--- a/src/directive.c
+++ b/src/directive.c
@@ -488,7 +488,12 @@ run_check_script (const char *script, struct file_triplet *trp,
488 setenv ("WYDAWCA_TRIPLET_BASE", trp->name, 1); 488 setenv ("WYDAWCA_TRIPLET_BASE", trp->name, 1);
489 setenv ("WYDAWCA_DIST_FILE", trp->file[file_dist].name, 1); 489 setenv ("WYDAWCA_DIST_FILE", trp->file[file_dist].name, 1);
490 490
491 chdir (temp_homedir); 491 if (chdir (temp_homedir))
492 {
493 logmsg (LOG_CRIT, "cannot change to %s: %s",
494 temp_homedir, strerror (errno));
495 _exit (127);
496 }
492 497
493 argv[0] = "sh"; 498 argv[0] = "sh";
494 argv[1] = script_file; 499 argv[1] = script_file;
diff --git a/src/exec.c b/src/exec.c
index e92fe17..9af6de2 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -30,16 +30,29 @@ start_prog (int argc, const char **argv, pid_t *ppid)
30 pid_t pid; 30 pid_t pid;
31 int i; 31 int i;
32 32
33 pipe (p); 33 if (pipe (p))
34 {
35 logmsg (LOG_CRIT, "pipe: %s", strerror (errno));
36 return NULL;
37 }
38
34 switch (pid = fork ()) 39 switch (pid = fork ())
35 { 40 {
36 case 0: 41 case 0:
37 /* Child process */ 42 /* Child process */
38 43
39 if (p[1] != 1) 44 if (p[1] != 1 && dup2 (p[1], 1) == -1)
40 dup2 (p[1], 1); 45 {
41 if (p[1] != 1) 46 logmsg (LOG_CRIT, "dup2: %s", strerror (errno));
42 dup2 (p[1], 2); 47 _exit (EX_UNAVAILABLE);
48 }
49
50 if (p[1] != 1 && dup2 (p[1], 2) == -1)
51 {
52 logmsg (LOG_CRIT, "dup2: %s", strerror (errno));
53 _exit (EX_UNAVAILABLE);
54 }
55
43 close (p[0]); 56 close (p[0]);
44 57
45 /* Close unneded descripitors */ 58 /* Close unneded descripitors */
diff --git a/src/mail.c b/src/mail.c
index c2e92f9..270c2f5 100644
--- a/src/mail.c
+++ b/src/mail.c
@@ -273,8 +273,6 @@ mail_send_message (mu_address_t rcpt, const char *text,
273 mu_stream_t stream = NULL; 273 mu_stream_t stream = NULL;
274 mu_header_t hdr; 274 mu_header_t hdr;
275 static char *x_mailer = "wydawca (" PACKAGE_STRING ")"; 275 static char *x_mailer = "wydawca (" PACKAGE_STRING ")";
276 size_t size;
277 char *buf;
278 const char *sval; 276 const char *sval;
279 277
280 mu_static_memory_stream_create (&stream, text, strlen (text)); 278 mu_static_memory_stream_create (&stream, text, strlen (text));
@@ -290,20 +288,15 @@ mail_send_message (mu_address_t rcpt, const char *text,
290 288
291 if (rcpt) 289 if (rcpt)
292 { 290 {
293 mu_address_to_string (rcpt, NULL, 0, &size); 291 const char *s;
294 buf = grecs_malloc (size + 1); 292
295 mu_address_to_string (rcpt, buf, size + 1, NULL); 293 if (mu_address_sget_printable (rcpt, &s) == 0)
296 294 mu_header_set_value (hdr, "To", s, 1);
297 mu_header_set_value (hdr, "To", buf, 1); 295
298 free (buf);
299
300 if (from_address && mu_header_sget_value (hdr, "From", &sval)) 296 if (from_address && mu_header_sget_value (hdr, "From", &sval))
301 { 297 {
302 mu_address_to_string (from_address, NULL, 0, &size); 298 if (mu_address_sget_printable (from_address, &s) == 0)
303 buf = grecs_malloc (size + 1); 299 mu_header_set_value (hdr, "From", s, 1);
304 mu_address_to_string (from_address, buf, size + 1, NULL);
305 mu_header_set_value (hdr, "From", buf, 1);
306 free (buf);
307 } 300 }
308 } 301 }
309 302
@@ -431,13 +424,10 @@ mail_stats ()
431 424
432 if (debug_level) 425 if (debug_level)
433 { 426 {
434 size_t size; 427 const char *s;
435 char *buf; 428
436 mu_address_to_string (admin_address, NULL, 0, &size); 429 if (mu_address_sget_printable (admin_address, &s) == 0)
437 buf = grecs_malloc (size + 1); 430 logmsg (LOG_DEBUG, _("sending stats to %s"), s);
438 mu_address_to_string (admin_address, buf, size + 1, NULL);
439 logmsg (LOG_DEBUG, _("sending stats to %s"), buf);
440 free (buf);
441 } 431 }
442 432
443 tc = timer_get_count () * 3; 433 tc = timer_get_count () * 3;
@@ -595,14 +585,11 @@ do_notify (struct file_triplet *trp, enum notification_event ev,
595 { 585 {
596 if (rcpt) 586 if (rcpt)
597 { 587 {
598 size_t size; 588 const char *s;
599 char *buf; 589
600 mu_address_to_string (rcpt, NULL, 0, &size); 590 if (mu_address_sget_printable (rcpt, &s) == 0)
601 buf = grecs_malloc (size + 1); 591 logmsg (LOG_DEBUG, _("notifying %s (project %s) about %s"),
602 mu_address_to_string (rcpt, buf, size + 1, NULL); 592 s, trp->project, notification_event_str (ev));
603 logmsg (LOG_DEBUG, _("notifying %s (project %s) about %s"),
604 buf, trp->project, notification_event_str (ev));
605 free (buf);
606 } 593 }
607 else 594 else
608 logmsg (LOG_DEBUG, 595 logmsg (LOG_DEBUG,
@@ -638,14 +625,8 @@ notify (struct notification *notification_list,
638const char * 625const char *
639expand_email_admin (struct metadef *def, void *data) 626expand_email_admin (struct metadef *def, void *data)
640{ 627{
641 size_t size; 628 if (mu_address_aget_printable (admin_address, &def->storage) == 0)
642 if (mu_address_to_string (admin_address, NULL, 0, &size) == 0) 629 def->value = def->storage;
643 {
644 size++;
645 def->storage = grecs_malloc (size);
646 mu_address_to_string (admin_address, def->storage, size, NULL);
647 def->value = def->storage;
648 }
649 else 630 else
650 def->value = ""; 631 def->value = "";
651 return def->value; 632 return def->value;
@@ -657,7 +638,6 @@ expand_email_owner (struct metadef *def, void *data)
657 struct file_triplet *trp = data; 638 struct file_triplet *trp = data;
658 mu_address_t addr; 639 mu_address_t addr;
659 const char *errp; 640 const char *errp;
660 size_t size;
661 641
662 addr = get_recipient (trp->spool->dictionary[project_owner_dict], 642 addr = get_recipient (trp->spool->dictionary[project_owner_dict],
663 trp, &errp); 643 trp, &errp);
@@ -667,16 +647,14 @@ expand_email_owner (struct metadef *def, void *data)
667 trp->project, gettext (errp)); 647 trp->project, gettext (errp));
668 def->value = ""; 648 def->value = "";
669 } 649 }
670 else if (mu_address_to_string (addr, NULL, 0, &size) == 0) 650 else
671 { 651 {
672 size++; 652 if (mu_address_aget_printable (addr, &def->storage) == 0)
673 def->storage = grecs_malloc (size); 653 def->value = def->storage;
674 mu_address_to_string (addr, def->storage, size, NULL); 654 else
675 def->value = def->storage; 655 def->value = "";
676 mu_address_destroy (&addr); 656 mu_address_destroy (&addr);
677 } 657 }
678 else
679 def->value = "";
680 return def->value; 658 return def->value;
681} 659}
682 660
diff --git a/src/triplet.c b/src/triplet.c
index 14182be..a327b43 100644
--- a/src/triplet.c
+++ b/src/triplet.c
@@ -328,8 +328,6 @@ remove_triplet (struct file_triplet *trp)
328time_t 328time_t
329triplet_sweep (void) 329triplet_sweep (void)
330{ 330{
331 struct file_triplet const *tp;
332
333 while (triplet_list && triplet_expired_p (triplet_list)) 331 while (triplet_list && triplet_expired_p (triplet_list))
334 remove_triplet (triplet_list); 332 remove_triplet (triplet_list);
335 333
diff --git a/src/wydawca.h b/src/wydawca.h
index 25153c2..a150595 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -428,6 +428,8 @@ int spool_cwd_add_new_file (const struct spool *spool, const char *name,
428int spool_open_dictionaries (struct spool *spool); 428int spool_open_dictionaries (struct spool *spool);
429void spool_close_dictionaries (struct spool *spool); 429void spool_close_dictionaries (struct spool *spool);
430 430
431void parse_file_name (const char *name, struct file_info *finfo);
432void file_info_cleanup (struct file_info *finfo);
431int for_each_spool (int (*fun) (struct spool *, void *), void *data); 433int for_each_spool (int (*fun) (struct spool *, void *), void *data);
432void register_spool (struct spool *spool); 434void register_spool (struct spool *spool);
433struct spool *wydawca_find_spool (const char *name); 435struct spool *wydawca_find_spool (const char *name);

Return to:

Send suggestions and report system problems to the System administrator.