~ubuntu-branches/ubuntu/oneiric/exim4/oneiric

« back to all changes in this revision

Viewing changes to src/spool_mbox.c

  • Committer: Bazaar Package Importer
  • Author(s): Artur Rona
  • Date: 2010-12-28 22:20:17 UTC
  • mfrom: (2.3.4 experimental)
  • Revision ID: james.westby@ubuntu.com-20101228222017-r6vg4eqlqy2fk4ul
Tags: 4.73~rc1-1ubuntu1
* Merge from debian unstable.  Remaining changes: (LP: #697934)
  - debian/patches/71_exiq_grep_error_on_messages_without_size.patch:
    + Improve handling of broken messages when "exim4 -bp" (mailq)
      reports lines without size info.
  - debian/control: Don't declare a Provides: default-mta; in Ubuntu,
    we want postfix to be the default.
  - debian/{control,rules}: Add and enable hardened build for PIE.
    (Closes: #542726)
* Drop B-D on libmysqlclient15-dev, resolved in Debian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Cambridge: exim/exim-src/src/spool_mbox.c,v 1.14 2008/01/16 09:56:55 tom Exp $ */
 
1
/* $Cambridge: exim/src/src/spool_mbox.c,v 1.15 2010/06/05 11:13:30 pdp Exp $ */
2
2
 
3
3
/*************************************************
4
4
*     Exim - an Internet mail transport agent    *
25
25
int spool_mbox_ok = 0;
26
26
uschar spooled_message_id[17];
27
27
 
28
 
/* returns a pointer to the FILE, and puts the size in bytes into mbox_file_size */
 
28
/* returns a pointer to the FILE, and puts the size in bytes into mbox_file_size
 
29
 * normally, source_file_override is NULL */
29
30
 
30
 
FILE *spool_mbox(unsigned long *mbox_file_size) {
 
31
FILE *spool_mbox(unsigned long *mbox_file_size, uschar *source_file_override) {
31
32
  uschar message_subdir[2];
32
33
  uschar buffer[16384];
33
34
  uschar *temp_string;
100
101
    (void)fwrite("\n", 1, 1, mbox_file);
101
102
 
102
103
    /* copy body file */
103
 
    message_subdir[1] = '\0';
104
 
    for (i = 0; i < 2; i++) {
105
 
      message_subdir[0] = (split_spool_directory == (i == 0))? message_id[5] : 0;
106
 
      temp_string = string_sprintf("%s/input/%s/%s-D", spool_directory,
107
 
        message_subdir, message_id);
108
 
      data_file = Ufopen(temp_string, "rb");
109
 
      if (data_file != NULL) break;
 
104
    if (source_file_override == NULL) {
 
105
      message_subdir[1] = '\0';
 
106
      for (i = 0; i < 2; i++) {
 
107
        message_subdir[0] = (split_spool_directory == (i == 0))? message_id[5] : 0;
 
108
        temp_string = string_sprintf("%s/input/%s/%s-D", spool_directory,
 
109
          message_subdir, message_id);
 
110
        data_file = Ufopen(temp_string, "rb");
 
111
        if (data_file != NULL) break;
 
112
      };
 
113
    } else {
 
114
      data_file = Ufopen(source_file_override, "rb");
110
115
    };
111
116
 
112
117
    if (data_file == NULL) {
125
130
     * explicitly, because the one in the file is parted of the locked area.
126
131
     */
127
132
 
128
 
    (void)fseek(data_file, SPOOL_DATA_START_OFFSET, SEEK_SET);
 
133
    if (!source_file_override)
 
134
      (void)fseek(data_file, SPOOL_DATA_START_OFFSET, SEEK_SET);
129
135
 
130
136
    do {
131
137
      j = fread(buffer, 1, sizeof(buffer), data_file);
188
194
    mbox_path = string_sprintf("%s/scan/%s", spool_directory, spooled_message_id);
189
195
 
190
196
    tempdir = opendir(CS mbox_path);
 
197
    if (!tempdir) {
 
198
      debug_printf("Unable to opendir(%s): %s\n", mbox_path, strerror(errno));
 
199
      /* Just in case we still can: */
 
200
      rmdir(CS mbox_path);
 
201
      return;
 
202
    }
191
203
    /* loop thru dir & delete entries */
192
204
    while((entry = readdir(tempdir)) != NULL) {
193
205
      uschar *name = US entry->d_name;