aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2012-12-30 14:52:15 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2012-12-30 14:52:15 +0200
commit1fa130754f837e514e7eb231f4e0c6e1b1419271 (patch)
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')
-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
@@ -489,5 +489,10 @@ run_check_script (const char *script, struct file_triplet *trp,
setenv ("WYDAWCA_DIST_FILE", trp->file[file_dist].name, 1);
- chdir (temp_homedir);
+ if (chdir (temp_homedir))
+ {
+ logmsg (LOG_CRIT, "cannot change to %s: %s",
+ temp_homedir, strerror (errno));
+ _exit (127);
+ }
argv[0] = "sh";
diff --git a/src/exec.c b/src/exec.c
index e92fe17..9af6de2 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -31,5 +31,10 @@ start_prog (int argc, const char **argv, pid_t *ppid)
int i;
- pipe (p);
+ if (pipe (p))
+ {
+ logmsg (LOG_CRIT, "pipe: %s", strerror (errno));
+ return NULL;
+ }
+
switch (pid = fork ())
{
@@ -37,8 +42,16 @@ start_prog (int argc, const char **argv, pid_t *ppid)
/* Child process */
- if (p[1] != 1)
- dup2 (p[1], 1);
- if (p[1] != 1)
- dup2 (p[1], 2);
+ if (p[1] != 1 && dup2 (p[1], 1) == -1)
+ {
+ logmsg (LOG_CRIT, "dup2: %s", strerror (errno));
+ _exit (EX_UNAVAILABLE);
+ }
+
+ if (p[1] != 1 && dup2 (p[1], 2) == -1)
+ {
+ logmsg (LOG_CRIT, "dup2: %s", strerror (errno));
+ _exit (EX_UNAVAILABLE);
+ }
+
close (p[0]);
diff --git a/src/mail.c b/src/mail.c
index c2e92f9..270c2f5 100644
--- a/src/mail.c
+++ b/src/mail.c
@@ -274,6 +274,4 @@ mail_send_message (mu_address_t rcpt, const char *text,
mu_header_t hdr;
static char *x_mailer = "wydawca (" PACKAGE_STRING ")";
- size_t size;
- char *buf;
const char *sval;
@@ -291,18 +289,13 @@ mail_send_message (mu_address_t rcpt, const char *text,
if (rcpt)
{
- mu_address_to_string (rcpt, NULL, 0, &size);
- buf = grecs_malloc (size + 1);
- mu_address_to_string (rcpt, buf, size + 1, NULL);
-
- mu_header_set_value (hdr, "To", buf, 1);
- free (buf);
-
+ const char *s;
+
+ if (mu_address_sget_printable (rcpt, &s) == 0)
+ mu_header_set_value (hdr, "To", s, 1);
+
if (from_address && mu_header_sget_value (hdr, "From", &sval))
{
- mu_address_to_string (from_address, NULL, 0, &size);
- buf = grecs_malloc (size + 1);
- mu_address_to_string (from_address, buf, size + 1, NULL);
- mu_header_set_value (hdr, "From", buf, 1);
- free (buf);
+ if (mu_address_sget_printable (from_address, &s) == 0)
+ mu_header_set_value (hdr, "From", s, 1);
}
}
@@ -432,11 +425,8 @@ mail_stats ()
if (debug_level)
{
- size_t size;
- char *buf;
- mu_address_to_string (admin_address, NULL, 0, &size);
- buf = grecs_malloc (size + 1);
- mu_address_to_string (admin_address, buf, size + 1, NULL);
- logmsg (LOG_DEBUG, _("sending stats to %s"), buf);
- free (buf);
+ const char *s;
+
+ if (mu_address_sget_printable (admin_address, &s) == 0)
+ logmsg (LOG_DEBUG, _("sending stats to %s"), s);
}
@@ -596,12 +586,9 @@ do_notify (struct file_triplet *trp, enum notification_event ev,
if (rcpt)
{
- size_t size;
- char *buf;
- mu_address_to_string (rcpt, NULL, 0, &size);
- buf = grecs_malloc (size + 1);
- mu_address_to_string (rcpt, buf, size + 1, NULL);
- logmsg (LOG_DEBUG, _("notifying %s (project %s) about %s"),
- buf, trp->project, notification_event_str (ev));
- free (buf);
+ const char *s;
+
+ if (mu_address_sget_printable (rcpt, &s) == 0)
+ logmsg (LOG_DEBUG, _("notifying %s (project %s) about %s"),
+ s, trp->project, notification_event_str (ev));
}
else
@@ -639,12 +626,6 @@ const char *
expand_email_admin (struct metadef *def, void *data)
{
- size_t size;
- if (mu_address_to_string (admin_address, NULL, 0, &size) == 0)
- {
- size++;
- def->storage = grecs_malloc (size);
- mu_address_to_string (admin_address, def->storage, size, NULL);
- def->value = def->storage;
- }
+ if (mu_address_aget_printable (admin_address, &def->storage) == 0)
+ def->value = def->storage;
else
def->value = "";
@@ -658,5 +639,4 @@ expand_email_owner (struct metadef *def, void *data)
mu_address_t addr;
const char *errp;
- size_t size;
addr = get_recipient (trp->spool->dictionary[project_owner_dict],
@@ -668,14 +648,12 @@ expand_email_owner (struct metadef *def, void *data)
def->value = "";
}
- else if (mu_address_to_string (addr, NULL, 0, &size) == 0)
+ else
{
- size++;
- def->storage = grecs_malloc (size);
- mu_address_to_string (addr, def->storage, size, NULL);
- def->value = def->storage;
+ if (mu_address_aget_printable (addr, &def->storage) == 0)
+ def->value = def->storage;
+ else
+ def->value = "";
mu_address_destroy (&addr);
}
- else
- def->value = "";
return def->value;
}
diff --git a/src/triplet.c b/src/triplet.c
index 14182be..a327b43 100644
--- a/src/triplet.c
+++ b/src/triplet.c
@@ -329,6 +329,4 @@ time_t
triplet_sweep (void)
{
- struct file_triplet const *tp;
-
while (triplet_list && triplet_expired_p (triplet_list))
remove_triplet (triplet_list);
diff --git a/src/wydawca.h b/src/wydawca.h
index 25153c2..a150595 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -429,4 +429,6 @@ int spool_open_dictionaries (struct spool *spool);
void spool_close_dictionaries (struct spool *spool);
+void parse_file_name (const char *name, struct file_info *finfo);
+void file_info_cleanup (struct file_info *finfo);
int for_each_spool (int (*fun) (struct spool *, void *), void *data);
void register_spool (struct spool *spool);

Return to:

Send suggestions and report system problems to the System administrator.