~ubuntu-branches/ubuntu/dapper/postfix/dapper-security

« back to all changes in this revision

Viewing changes to src/postqueue/postqueue.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2005-12-07 15:39:11 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20051207153911-hutf07z6i8ty25z5
Tags: 2.2.6-1
* New upstream.
  - the *SQL clients did not uniformly choose the database host from
    the available pool
  - raise the "policy violation" flag when a client request exceeds
    a concurrency or rate limit.
  - don't do smtpd_end_of_data_restrictions after the transaction
    failed due to, e.g., a write error.
  - two messages could get the same message ID due to a race
    condition. This time window was increased when queue file creation
    was postponed from MAIL FROM until the first accepted RCPT TO.  The
    window is closed again.
  - the queue manager did not write a per-recipient defer logfile record
    when the delivery agent crashed after the initial handshake with the
    queue manager, and before reporting the delivery status to the queue
    manager.
  - moved code around from one place to another to make REDIRECT, FILTER,
    HOLD and DISCARD access(5) table actions work in
    smtpd_end_of_data_restrictions.  PREPEND will not be fixed; it must
    be specified before the message content is received.
* Updated Italian translations.  Closes: #336925
* Swedish translations.  Closes: #339746
* Switch to libdb4.3.  Closes: #336488
* Add Replaces: mail-transport-agent.  Closes: #325624
* Merge changes from ubuntu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
/* .br
11
11
/*      \fBpostqueue\fR [\fB-c \fIconfig_dir\fR] \fB-s \fIsite\fR
12
12
/* DESCRIPTION
13
 
/*      The \fBpostqueue\fR program implements the Postfix user interface
 
13
/*      The \fBpostqueue\fR(1) command implements the Postfix user interface
14
14
/*      for queue management. It implements operations that are
15
15
/*      traditionally available via the \fBsendmail\fR(1) command.
16
16
/*      See the \fBpostsuper\fR(1) command for queue operations
25
25
/* .IP \fB-f\fR
26
26
/*      Flush the queue: attempt to deliver all queued mail.
27
27
/*
28
 
/*      This option implements the traditional \fBsendmail -q\fR command,
 
28
/*      This option implements the traditional "\fBsendmail -q\fR" command,
29
29
/*      by contacting the Postfix \fBqmgr\fR(8) daemon.
30
30
/*
31
31
/*      Warning: flushing undeliverable mail frequently will result in
51
51
/* .RE
52
52
/* .IP "\fB-s \fIsite\fR"
53
53
/*      Schedule immediate delivery of all mail that is queued for the named
54
 
/*      \fIsite\fR. The site must be eligible for the "fast flush" service.
 
54
/*      \fIsite\fR. A numerical site must be specified as a valid RFC 2821
 
55
/*      address literal enclosed in [], just like in email addresses.
 
56
/*      The site must be eligible for the "fast flush" service.
55
57
/*      See \fBflush\fR(8) for more information about the "fast flush"
56
58
/*      service.
57
59
/*
58
 
/*      This option implements the traditional \fBsendmail -qR\fIsite\fR
 
60
/*      This option implements the traditional "\fBsendmail -qR\fIsite\fR"
59
61
/*      command, by contacting the Postfix \fBflush\fR(8) daemon.
60
62
/* .IP \fB-v\fR
61
63
/*      Enable verbose logging for debugging purposes. Multiple \fB-v\fR
88
90
/*      The following \fBmain.cf\fR parameters are especially relevant to
89
91
/*      this program.
90
92
/*      The text below provides only a parameter summary. See
91
 
/*      postconf(5) for more details including examples.
 
93
/*      \fBpostconf\fR(5) for more details including examples.
92
94
/* .IP "\fBalternate_config_directories (empty)\fR"
93
95
/*      A list of non-default Postfix configuration directories that may
94
96
/*      be specified with "-c config_directory" on the command line, or
113
115
/*      records, so that "smtpd" becomes, for example, "postfix/smtpd".
114
116
/* .IP "\fBtrigger_timeout (10s)\fR"
115
117
/*      The time limit for sending a trigger to a Postfix daemon (for
116
 
/*      example, the pickup(8) or qmgr(8) daemon).
 
118
/*      example, the \fBpickup\fR(8) or \fBqmgr\fR(8) daemon).
 
119
/* .PP
 
120
/*      Available in Postfix version 2.2 and later:
 
121
/* .IP "\fBauthorized_flush_users (static:anyone)\fR"
 
122
/*      List of users who are authorized to flush the queue.
 
123
/* .IP "\fBauthorized_mailq_users (static:anyone)\fR"
 
124
/*      List of users who are authorized to view the queue.
117
125
/* FILES
118
126
/*      /var/spool/postfix, mail queue
119
127
/* SEE ALSO
180
188
#include <mail_flush.h>
181
189
#include <flush_clnt.h>
182
190
#include <smtp_stream.h>
 
191
#include <user_acl.h>
 
192
#include <valid_mailhost_addr.h>
183
193
 
184
194
/* Application-specific. */
185
195
 
209
219
  */
210
220
#define STR     vstring_str
211
221
 
 
222
 /*
 
223
  * Queue manipulation access lists.
 
224
  */
 
225
char   *var_flush_acl;
 
226
char   *var_showq_acl;
 
227
 
 
228
static CONFIG_STR_TABLE str_table[] = {
 
229
    VAR_FLUSH_ACL, DEF_FLUSH_ACL, &var_flush_acl, 0, 0,
 
230
    VAR_SHOWQ_ACL, DEF_SHOWQ_ACL, &var_showq_acl, 0, 0,
 
231
    0,
 
232
};
 
233
 
212
234
/* show_queue - show queue status */
213
235
 
214
236
static void show_queue(void)
215
237
{
 
238
    const char *errstr;
216
239
    char    buf[VSTREAM_BUFSIZE];
217
240
    VSTREAM *showq;
218
241
    int     n;
 
242
    uid_t   uid = getuid();
 
243
 
 
244
    if (uid != 0 && uid != var_owner_uid
 
245
        && (errstr = check_user_acl_byuid(var_showq_acl, uid)) != 0)
 
246
        msg_fatal_status(EX_NOPERM,
 
247
                       "User %s(%ld) is not allowed to view the mail queue",
 
248
                         errstr, (long) uid);
219
249
 
220
250
    /*
221
251
     * Connect to the show queue service. Terminate silently when piping into
278
308
 
279
309
static void flush_queue(void)
280
310
{
 
311
    const char *errstr;
 
312
    uid_t   uid = getuid();
 
313
 
 
314
    if (uid != 0 && uid != var_owner_uid
 
315
        && (errstr = check_user_acl_byuid(var_flush_acl, uid)) != 0)
 
316
        msg_fatal_status(EX_NOPERM,
 
317
                      "User %s(%ld) is not allowed to flush the mail queue",
 
318
                         errstr, (long) uid);
281
319
 
282
320
    /*
283
321
     * Trigger the flush queue service.
295
333
static void flush_site(const char *site)
296
334
{
297
335
    int     status;
 
336
    const char *errstr;
 
337
    uid_t   uid = getuid();
 
338
 
 
339
    if (uid != 0 && uid != var_owner_uid
 
340
        && (errstr = check_user_acl_byuid(var_flush_acl, uid)) != 0)
 
341
        msg_fatal_status(EX_NOPERM,
 
342
                      "User %s(%ld) is not allowed to flush the mail queue",
 
343
                         errstr, (long) uid);
298
344
 
299
345
    flush_init();
300
346
 
405
451
     * Further initialization...
406
452
     */
407
453
    mail_conf_read();
 
454
    get_mail_conf_str_table(str_table);
408
455
 
409
456
    /*
410
457
     * This program is designed to be set-gid, which makes it a potential
430
477
     */
431
478
    if (site_to_flush != 0) {
432
479
        bad_site = 0;
433
 
        if (*site_to_flush == '['
434
 
            && *(last = site_to_flush + strlen(site_to_flush) - 1) == ']') {
435
 
            *last = 0;
436
 
            bad_site = !valid_hostaddr(site_to_flush + 1, DONT_GRIPE);
437
 
            *last = ']';
 
480
        if (*site_to_flush == '[') {
 
481
            bad_site = !valid_mailhost_literal(site_to_flush, DONT_GRIPE);
438
482
        } else {
439
 
            bad_site = (!valid_hostname(site_to_flush, DONT_GRIPE)
440
 
                        && !valid_hostaddr(site_to_flush, DONT_GRIPE));
 
483
            bad_site = !valid_hostname(site_to_flush, DONT_GRIPE);
441
484
        }
442
485
        if (bad_site)
443
486
            msg_fatal_status(EX_USAGE,