~ubuntu-branches/ubuntu/wily/dovecot/wily

« back to all changes in this revision

Viewing changes to src/lib/istream.c

  • Committer: Bazaar Package Importer
  • Author(s): CHuck Short, Chuck Short
  • Date: 2009-11-06 00:47:29 UTC
  • mfrom: (4.1.9 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091106004729-i39n7v9e7d4h51f6
Tags: 1:1.2.6-1ubuntu1
* Merge from debian testing, remaining changes:
  Add new binary pkg dovecot-postfix that integrates postfix and dovecot
  automatically: (LP: #164837)
  + debian/control:
    - add new binary with short description
    - set Architecture all for dovecot-postfix (LP: #329878)
  + debian/dovecot-postfix.postinst:
    - create initial certificate symlinks to snakeoil.
    - set up postfix with postconf to:
      - use Maildir/ as the default mailbox.
      - use dovecot as the sasl authentication server.
      - use dovecot LDA (deliver).
      - use tls for smtp{d} services.
    - fix certificates paths in postfix' main.cf
    - add reject_unauth_destination to postfix' recipient restrictions
    - add reject_unknown_sender_domain to postfix' sender restrictions
    - rename configuration name on remove, delete on purge
    - restart dovecot after linking certificates
    - handle use case when postfix is unconfigurated
   + debian/dovecot-postfix.dirs: create backup directory for postfix's configuration
   + restart postfix and dovecot.
   + debian/dovecot-postfix.postrm:
     - remove all dovecot related configuration from postfix.
     - restart postfix and dovecot.
   + debian/dovecot-common.init:
     - check if /etc/dovecot/dovecot-postfix.conf exists and use it
       as the configuration file if so.
   + debian/patches/warning-ubuntu-postfix.dpatch
     - add warning about dovecot-postfix.conf in dovecot default 
       configuration file
   + debian/patches/dovecot-postfix.conf.diff:
     - Ubuntu server custom changes to the default dovecot configuration for
       better interfation with postfix
     - enable sieve plugin
   + debian/patches/dovecot-postfix.conf.diff:
     + Ubuntu server custom changes to the default dovecot configuration for
       better integration with postfix:
       - enable imap, pop3, imaps, pop3s and managesieve by default.
       - enable dovecot LDA (deliver).
       - enable SASL auth socket in postfix private directory.
   + debian/rules:
     - copy, patch and install dovecot-postfix.conf in /etc/dovecot/.
     - build architecure independent packages too
   + Use Snakeoil SSL certificates by default.
     - debian/control: Depend on ssl-cert.
     - debian/patches/ssl-cert-snakeoil.dpatch: Change default SSL cert
       paths to snakeoil.
     - debian/dovecot-common.postinst: Relax grep for SSL_* a bit.
   + Add autopkgtest to debian/tests/*.
   + Fast TearDown: Update the lsb init header to not stop in level 6.
   + Add ufw integration:
     - Created debian/dovecot-common.ufw.profile.
     - debian/rules:
       + install profile
     - debian/control:
       + Suggest ufw
   + debian/{control,rules}: enable PIE hardening.
   + dovecot-imapd, dovecot-pop3: Replaces dovecot-common (<< 1:1.1). LP: #254721
   + debian/control:
     - Update Vcs-* headers.
   + debian/rules:
     - Create emtpy stamp.h.in files in dovecot-sieve/ and dovecot-managesieve/
       if they're not there since empty files are not included in the diff.gz 
       file.
   + Add SMTP-AUTH support for Outlook (login auth mechanism)
   + Dropped:
     - debian/patches/security-CVE-2009-3235: Applied upstream.
     - debian/patches/fix-pop3-assertion.dpatch: Applied upstream.
     - dovecot-sieve and dovecot-managesieve: Use the debian patches instead.

  [Chuck Short]
  - Updated dovecot-sieve to 0.1.13.
  - Updated dovecot-managesieve to 0.11.9.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
                stream->stream_errno = ENOENT;
55
55
}
56
56
 
 
57
void i_stream_set_init_buffer_size(struct istream *stream, size_t size)
 
58
{
 
59
        stream->real_stream->init_buffer_size = size;
 
60
}
 
61
 
57
62
void i_stream_set_max_buffer_size(struct istream *stream, size_t max_size)
58
63
{
59
64
        io_stream_set_max_buffer_size(&stream->real_stream->iostream, max_size);
67
72
ssize_t i_stream_read(struct istream *stream)
68
73
{
69
74
        struct istream_private *_stream = stream->real_stream;
 
75
        size_t old_size;
70
76
        ssize_t ret;
71
77
 
72
78
        if (unlikely(stream->closed))
75
81
        stream->eof = FALSE;
76
82
        stream->stream_errno = 0;
77
83
 
 
84
        old_size = _stream->pos - _stream->skip;
78
85
        ret = _stream->read(_stream);
79
86
        switch (ret) {
80
87
        case -2:
92
99
        case 0:
93
100
                i_assert(!stream->blocking);
94
101
                break;
 
102
        default:
 
103
                i_assert(ret > 0);
 
104
                i_assert((size_t)ret+old_size == _stream->pos - _stream->skip);
 
105
                break;
95
106
        }
96
107
        return ret;
97
108
}
98
109
 
 
110
ssize_t i_stream_read_copy_from_parent(struct istream *istream)
 
111
{
 
112
        struct istream_private *stream = istream->real_stream;
 
113
        size_t pos;
 
114
        ssize_t ret;
 
115
 
 
116
        stream->pos -= stream->skip;
 
117
        stream->skip = 0;
 
118
 
 
119
        stream->buffer = i_stream_get_data(stream->parent, &pos);
 
120
        if (pos > stream->pos)
 
121
                ret = 0;
 
122
        else do {
 
123
                if ((ret = i_stream_read(stream->parent)) == -2)
 
124
                        return -2;
 
125
 
 
126
                stream->istream.stream_errno = stream->parent->stream_errno;
 
127
                stream->istream.eof = stream->parent->eof;
 
128
                stream->buffer = i_stream_get_data(stream->parent, &pos);
 
129
                /* check again, in case the parent stream had been seeked
 
130
                   backwards and the previous read() didn't get us far
 
131
                   enough. */
 
132
        } while (pos <= stream->pos && ret > 0);
 
133
 
 
134
        ret = pos > stream->pos ? (ssize_t)(pos - stream->pos) :
 
135
                (ret == 0 ? 0 : -1);
 
136
        stream->pos = pos;
 
137
        i_assert(ret != -1 || stream->istream.eof ||
 
138
                 stream->istream.stream_errno != 0);
 
139
        return ret;
 
140
}
 
141
 
99
142
void i_stream_skip(struct istream *stream, uoff_t count)
100
143
{
101
144
        struct istream_private *_stream = stream->real_stream;
187
230
        return _stream->stat(_stream, exact);
188
231
}
189
232
 
190
 
bool i_stream_have_bytes_left(struct istream *stream)
 
233
bool i_stream_have_bytes_left(const struct istream *stream)
191
234
{
192
 
        struct istream_private *_stream = stream->real_stream;
 
235
        const struct istream_private *_stream = stream->real_stream;
193
236
 
194
237
        return !stream->eof || _stream->skip != _stream->pos;
195
238
}
280
323
        return line;
281
324
}
282
325
 
283
 
const unsigned char *i_stream_get_data(struct istream *stream, size_t *size_r)
 
326
const unsigned char *
 
327
i_stream_get_data(const struct istream *stream, size_t *size_r)
284
328
{
285
 
        struct istream_private *_stream = stream->real_stream;
 
329
        const struct istream_private *_stream = stream->real_stream;
286
330
 
287
331
        if (_stream->skip >= _stream->pos) {
288
332
                *size_r = 0;
293
337
        return _stream->buffer + _stream->skip;
294
338
}
295
339
 
296
 
unsigned char *i_stream_get_modifiable_data(struct istream *stream,
 
340
unsigned char *i_stream_get_modifiable_data(const struct istream *stream,
297
341
                                            size_t *size_r)
298
342
{
299
 
        struct istream_private *_stream = stream->real_stream;
 
343
        const struct istream_private *_stream = stream->real_stream;
300
344
 
301
345
        if (_stream->skip >= _stream->pos || _stream->w_buffer == NULL) {
302
346
                *size_r = 0;
360
404
        old_size = stream->buffer_size;
361
405
 
362
406
        stream->buffer_size = stream->pos + bytes;
363
 
        if (stream->buffer_size <= I_STREAM_MIN_SIZE)
364
 
                stream->buffer_size = I_STREAM_MIN_SIZE;
 
407
        if (stream->buffer_size <= stream->init_buffer_size)
 
408
                stream->buffer_size = stream->init_buffer_size;
365
409
        else
366
410
                stream->buffer_size = nearest_power(stream->buffer_size);
367
411
 
394
438
        return stream->pos != stream->buffer_size;
395
439
}
396
440
 
 
441
bool i_stream_add_data(struct istream *_stream, const unsigned char *data,
 
442
                       size_t size)
 
443
{
 
444
        struct istream_private *stream = _stream->real_stream;
 
445
        size_t size2;
 
446
 
 
447
        (void)i_stream_get_buffer_space(stream, size, &size2);
 
448
        if (size > size2)
 
449
                return FALSE;
 
450
 
 
451
        memcpy(stream->w_buffer + stream->pos, data, size);
 
452
        stream->pos += size;
 
453
        return TRUE;
 
454
}
 
455
 
397
456
static void
398
457
i_stream_default_set_max_buffer_size(struct iostream_private *stream,
399
458
                                     size_t max_size)
427
486
                _stream->iostream.set_max_buffer_size =
428
487
                        i_stream_default_set_max_buffer_size;
429
488
        }
 
489
        if (_stream->init_buffer_size == 0)
 
490
                _stream->init_buffer_size = I_STREAM_MIN_SIZE;
430
491
 
431
492
        memset(&_stream->statbuf, 0, sizeof(_stream->statbuf));
432
493
        _stream->statbuf.st_size = -1;