~ubuntu-branches/ubuntu/lucid/dovecot/lucid-security

« back to all changes in this revision

Viewing changes to src/master/mail-process.c

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug, Ante Karamatic, Mathias Gug
  • Date: 2009-02-12 21:45:09 UTC
  • mfrom: (1.10.17 upstream)
  • Revision ID: james.westby@ubuntu.com-20090212214509-8fp69kpkzf03j5xg
Tags: 1:1.1.11-0ubuntu1
[ Ante Karamatic ]
  Add new binary pkg dovecot-postfix that integrates postfix and dovecot
  automatically: (LP: #164837)
  - debian/control:
    + add new binary with short description.
  - 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.
    + 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 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/.
  
[ Mathias Gug ]
* New upstream release:
* Update dovecot-managesieve to 0.10.5. Fixes:
  - check if names of sieve scripts contain '/' (LP: #307291)
* Update dovecot-managesieve patch for 1.1.11 and 0.10.5.
* Update dovecot-sieve plugin to 1.1.6.
* Merge from debian experimental, remaining changes:
  - Use Snakeoil SSL certificates by default.
    + debian/control: Depend on ssl-cert
    + debian/paptches/ssl-cert-snakeoil.dpatch: Change default SSL cert 
      paths to snakeoil.
    + debian/dovecot-common.postinst: Relax grep for SSL_* a bit.
  - Add autopkgtest in debian/tests/*.
  - debian/dovecot-common.init: Check to see if there is an /etc/inetd.conf.
    (LP: #208411)
  - Fast TearDown: Update lsb init header to not stop in level 6.
  - Add status action to the init script:
    + debian/control: Depend on lsb >= 3.2.12ubuntu3.
    + debian/dovecot-common-init: Add the 'status' action (LP: #247096).
  - debian/rules:
    - Copy config.{guess,sub} after running libtoolize.
    - Clean dovecot-managesieve directory.
  - Add ufw integration: 
    - Created debian/dovecot-common.ufw.profile
    - debian/rules:
      + install profile
    - debian/control
      + Suggest ufw
  - debian/{control,rules}: enable PIE hardening.
  - Updated dovecot.common.README.Debian with information on what has changed 
    between 1.0 and 1.1.1. Fixes (LP: #257625) 
  - 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.
* Dropped:
  - debian/patches/fix-message-parser.dpatch: Parsing an invalid message
    address like "From: (" caused an assert-crash. (LP: #290901).
    (CVE-2008-4907 - fixed in 1.1.6)
  - debian/patches/login-max-process-count-warning.dpatch: Tell the user 
    that they have reached the maximum number of processes count.
    (LP: #189616) - Different implementation from upstream.
  - debian/patches/fix-dovecot-sieve.dpatch: Fixes assertion error
    when a header string ends with a LF (LP: #264306). Implemented upstream.
  - Don't fail in postinst if dovecot-{sql,ldap} is missing. (LP: #153161)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
 
1
/* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */
2
2
 
3
3
#include "common.h"
4
4
#include "array.h"
173
173
                     const char *local_ip, const char *remote_ip,
174
174
                     pid_t pid, uid_t uid)
175
175
{
 
176
#define VAR_EXPAND_HOME_IDX 4
176
177
        static struct var_expand_table static_tab[] = {
177
178
                { 'u', NULL },
178
179
                { 'n', NULL },
195
196
        tab[2].value = user == NULL ? NULL : strchr(user, '@');
196
197
        if (tab[2].value != NULL) tab[2].value++;
197
198
        tab[3].value = t_str_ucase(protocol);
198
 
        tab[4].value = home != NULL ? home :
199
 
                "/HOME_DIRECTORY_USED_BUT_NOT_GIVEN_BY_USERDB";
 
199
        tab[VAR_EXPAND_HOME_IDX].value = home;
200
200
        tab[5].value = local_ip;
201
201
        tab[6].value = remote_ip;
202
202
        tab[7].value = dec2str(pid);
205
205
        return tab;
206
206
}
207
207
 
 
208
static bool
 
209
has_missing_used_home(const char *str, const struct var_expand_table *table)
 
210
{
 
211
        i_assert(table[VAR_EXPAND_HOME_IDX].key == 'h');
 
212
 
 
213
        return table[VAR_EXPAND_HOME_IDX].value == NULL &&
 
214
                var_has_key(str, 'h');
 
215
}
 
216
 
208
217
static const char *
209
218
expand_mail_env(const char *env, const struct var_expand_table *table)
210
219
{
224
233
                str_append_c(str, *env++);
225
234
        }
226
235
 
 
236
        if (has_missing_used_home(env, table)) {
 
237
                i_fatal("userdb didn't return a home directory, "
 
238
                        "but mail location used it (%%h): %s", env);
 
239
        }
 
240
 
227
241
        /* expand %vars */
228
242
        var_expand(str, env, table);
229
243
        return str_c(str);
276
290
static void
277
291
mail_process_set_environment(struct settings *set, const char *mail,
278
292
                             const struct var_expand_table *var_expand_table,
279
 
                             bool dump_capability)
 
293
                             bool exec_mail)
280
294
{
281
295
        const char *const *envs;
282
296
        string_t *str;
353
367
                env_put("MBOX_VERY_DIRTY_SYNCS=1");
354
368
        if (set->mbox_lazy_writes)
355
369
                env_put("MBOX_LAZY_WRITES=1");
356
 
        /* when running dump-capability log still points to stderr,
357
 
           and io_add()ing it might break (epoll_ctl() gives EPERM) */
358
 
        if (set->shutdown_clients && !dump_capability)
 
370
        /* when we're not certain that the log fd points to the master
 
371
           process's log pipe (dump-capability, --exec-mail), don't let
 
372
           the imap process listen for stderr since it might break
 
373
           (e.g. epoll_ctl() gives EPERM). */
 
374
        if (set->shutdown_clients && !exec_mail)
359
375
                env_put("STDERR_CLOSE_SHUTDOWN=1");
360
376
        (void)umask(set->umask);
361
377
 
401
417
                str_truncate(str, 0);
402
418
                var_expand(str, envs[i+1], var_expand_table);
403
419
 
 
420
                if (has_missing_used_home(envs[i+1], var_expand_table)) {
 
421
                        i_error("userdb didn't return a home directory, "
 
422
                                "but it's used in plugin setting %s: %s",
 
423
                                envs[i], envs[i+1]);
 
424
                }
 
425
 
404
426
                env_put(t_strconcat(t_str_ucase(envs[i]), "=",
405
427
                                    str_c(str), NULL));
406
428
        }
464
486
        }
465
487
 
466
488
        mail_process_set_environment(set, getenv("MAIL"), var_expand_table,
467
 
                                     FALSE);
 
489
                                     TRUE);
468
490
        if (args == NULL)
469
491
                client_process_exec(executable, "");
470
492
        else
506
528
        if (point.type == NULL || strcasecmp(point.type, "NFS") != 0)
507
529
                return;
508
530
 
509
 
        i_fatal("Mailbox indexes in %s are in NFS mount. "
510
 
                "You must set mail_nfs_index=yes to avoid index corruptions. "
 
531
        i_fatal("Mailbox indexes in %s are in NFS mount. You must set "
 
532
                "mail_nfs_index=yes (and mail_nfs_storage=yes) to avoid index corruptions. "
511
533
                "If you're sure this check was wrong, set nfs_check=no.", path);
512
534
}
513
535
 
593
615
        if (uid == (uid_t)-1) {
594
616
                uid = set->mail_uid_t;
595
617
                if (uid == (uid_t)-1) {
596
 
                        i_error("User %s is missing UID (set mail_uid)", user);
 
618
                        i_error("User %s is missing UID (see mail_uid setting)",
 
619
                                user);
597
620
                        return MASTER_LOGIN_STATUS_INTERNAL_ERROR;
598
621
                }
599
622
        }
600
623
        if (gid == (gid_t)-1) {
601
624
                gid = set->mail_gid_t;
602
625
                if (gid == (gid_t)-1) {
603
 
                        i_error("User %s is missing GID (set mail_gid)", user);
 
626
                        i_error("User %s is missing GID (see mail_gid setting)",
 
627
                                user);
604
628
                        return MASTER_LOGIN_STATUS_INTERNAL_ERROR;
605
629
                }
606
630
        }
625
649
        if (*chroot_dir != '\0') {
626
650
                if (!validate_chroot(set, chroot_dir)) {
627
651
                        i_error("Invalid chroot directory '%s' (user %s) "
628
 
                                "(see valid_chroot_dirs in config file)",
 
652
                                "(see valid_chroot_dirs setting)",
629
653
                                chroot_dir, user);
630
654
                        return MASTER_LOGIN_STATUS_INTERNAL_ERROR;
631
655
                }
735
759
        /* setup environment - set the most important environment first
736
760
           (paranoia about filling up environment without noticing) */
737
761
        restrict_access_set_env(system_user, uid, gid, set->mail_priv_gid_t,
738
 
                                chroot_dir,
 
762
                                dump_capability ? "" : chroot_dir,
739
763
                                set->first_valid_gid, set->last_valid_gid,
740
764
                                set->mail_access_groups);
741
765
 
744
768
        if (dump_capability)
745
769
                env_put("DUMP_CAPABILITY=1");
746
770
 
747
 
        if (*home_dir == '\0' && *chroot_dir == '\0') {
 
771
        if ((*home_dir == '\0' && *chroot_dir == '\0') || dump_capability) {
748
772
                full_home_dir = "";
749
773
                ret = -1;
750
774
        } else {
831
855
 
832
856
        addr = net_ip2addr(remote_ip);
833
857
        env_put(t_strconcat("IP=", addr, NULL));
 
858
        env_put(t_strconcat("LOCAL_IP=", net_ip2addr(local_ip), NULL));
834
859
 
835
860
        if (!set->verbose_proctitle)
836
861
                title[0] = '\0';