Ejemplo n.º 1
0
static int smtp_helo (CONNECTION* conn)
{
        char buf[LONG_STRING];
        const char* fqdn;

        memset (Capabilities, 0, sizeof (Capabilities));

        if (!Esmtp) {
/* if TLS or AUTH are requested, use EHLO */
                if (conn->account.flags & M_ACCT_USER)
                        Esmtp = 1;
#ifdef USE_SSL
                if (option (OPTSSLFORCETLS) || quadoption (OPT_SSLSTARTTLS) != M_NO)
                        Esmtp = 1;
#endif
        }

        if(!(fqdn = mutt_fqdn (0)))
                fqdn = NONULL (Hostname);

        snprintf (buf, sizeof (buf), "%s %s\r\n", Esmtp ? "EHLO" : "HELO", fqdn);
/* XXX there should probably be a wrapper in mutt_socket.c that
 * repeatedly calls conn->write until all data is sent.  This
 * currently doesn't check for a short write.
 */
        if (mutt_socket_write (conn, buf) == -1)
                return smtp_err_write;
        return smtp_get_resp (conn);
}
Ejemplo n.º 2
0
ADDRESS *mutt_default_from (void)
{
  ADDRESS *adr;
  const char *fqdn = mutt_fqdn(1);

  /* 
   * Note: We let $from override $realname here.  Is this the right
   * thing to do? 
   */

  if (From)
    adr = rfc822_cpy_adr_real (From);
  else if (option (OPTUSEDOMAIN))
  {
    adr = rfc822_new_address ();
    adr->mailbox = safe_malloc (mutt_strlen (Username) + mutt_strlen (fqdn) + 2);
    sprintf (adr->mailbox, "%s@%s", NONULL(Username), NONULL(fqdn));	/* __SPRINTF_CHECKED__ */
  }
  else
  {
    adr = rfc822_new_address ();
    adr->mailbox = safe_strdup (NONULL(Username));
  }
  
  return (adr);
}
Ejemplo n.º 3
0
int mix_check_message (HEADER *msg)
{
  const char *fqdn;
  short need_hostname = 0;
  ADDRESS *p;
  
  if (msg->env->cc || msg->env->bcc)
  {
    mutt_error _("Mixmaster doesn't accept Cc or Bcc headers.");
    return -1;
  }

  /* When using mixmaster, we MUST qualify any addresses since
   * the message will be delivered through remote systems.
   * 
   * use_domain won't be respected at this point, hidden_host will.
   */

  for (p = msg->env->to; p; p = p->next)
  {
    if (!p->group && strchr (p->mailbox, '@') == NULL)
    {
      need_hostname = 1;
      break;
    }
  }
    
  if (need_hostname)
  {
    
    if (!(fqdn = mutt_fqdn (1)))
    {
      mutt_error _("Please set the hostname variable to a proper value when using mixmaster!");
      return (-1);
    }
  
    /* Cc and Bcc are empty at this point. */
    rfc822_qualify (msg->env->to, fqdn);
    rfc822_qualify (msg->env->reply_to, fqdn);
    rfc822_qualify (msg->env->mail_followup_to, fqdn);
  }

  return 0;
}
Ejemplo n.º 4
0
static ADDRESS *mutt_expand_aliases_r (ADDRESS *a, LIST **expn)
{
  ADDRESS *head = NULL, *last = NULL, *t, *w;
  LIST *u;
  char i;
  const char *fqdn;
  
  while (a)
  {
    if (!a->group && !a->personal && a->mailbox && strchr (a->mailbox, '@') == NULL)
    {
      t = mutt_lookup_alias (a->mailbox);

      if (t)
      {	
        i = 0;
        for (u = *expn; u; u = u->next)
	{
	  if (mutt_strcmp (a->mailbox, u->data) == 0) /* alias already found */
	  {
	    dprint (1, (debugfile, "mutt_expand_aliases_r(): loop in alias found for '%s'\n", a->mailbox));
	    i = 1;
	    break;
	  }
	}

        if (!i)
	{
          u = safe_malloc (sizeof (LIST));
          u->data = safe_strdup (a->mailbox);
          u->next = *expn;
          *expn = u;
	  w = rfc822_cpy_adr (t, 0);
	  w = mutt_expand_aliases_r (w, expn);
	  if (head)
	    last->next = w;
	  else
	    head = last = w;
	  while (last && last->next)
	    last = last->next;
        }
	t = a;
	a = a->next;
	t->next = NULL;
	rfc822_free_address (&t);
	continue;
      }
      else
      {
	struct passwd *pw = getpwnam (a->mailbox);

	if (pw)
	{
	  char namebuf[STRING];
	  
	  mutt_gecos_name (namebuf, sizeof (namebuf), pw);
	  mutt_str_replace (&a->personal, namebuf);
	  
#ifdef EXACT_ADDRESS
	  FREE (&a->val);
#endif
	}
      }
    }

    if (head)
    {
      last->next = a;
      last = last->next;
    }
    else
      head = last = a;
    a = a->next;
    last->next = NULL;
  }

  if (option (OPTUSEDOMAIN) && (fqdn = mutt_fqdn(1)))
  {
    /* now qualify all local addresses */
    rfc822_qualify (head, fqdn);
  }

  return (head);
}
Ejemplo n.º 5
0
/**
 * crypt_get_keys - Check we have all the keys we need
 * @param[in]  msg         Message with addresses to match
 * @param[out] keylist     Keys needed
 * @param[in]  oppenc_mode If true, use opportunistic encryption
 * @retval  0 Success
 * @retval -1 Error
 *
 * Do a quick check to make sure that we can find all of the
 * encryption keys if the user has requested this service.
 * Return the list of keys in KEYLIST.
 * If oppenc_mode is true, only keys that can be determined without
 * prompting will be used.
 */
int crypt_get_keys(struct Email *msg, char **keylist, bool oppenc_mode)
{
  struct Address *addrlist = NULL, *last = NULL;
  const char *fqdn = mutt_fqdn(true);
  char *self_encrypt = NULL;

  /* Do a quick check to make sure that we can find all of the encryption
   * keys if the user has requested this service.  */

  if (!WithCrypto)
    return 0;

  if (WithCrypto & APPLICATION_PGP)
    OptPgpCheckTrust = true;

  last = mutt_addr_append(&addrlist, msg->env->to, false);
  last = mutt_addr_append(last ? &last : &addrlist, msg->env->cc, false);
  mutt_addr_append(last ? &last : &addrlist, msg->env->bcc, false);

  if (fqdn)
    mutt_addr_qualify(addrlist, fqdn);
  addrlist = mutt_addrlist_dedupe(addrlist);

  *keylist = NULL;

  if (oppenc_mode || (msg->security & SEC_ENCRYPT))
  {
    if (((WithCrypto & APPLICATION_PGP) != 0) && (msg->security & APPLICATION_PGP))
    {
      *keylist = crypt_pgp_find_keys(addrlist, oppenc_mode);
      if (!*keylist)
      {
        mutt_addr_free(&addrlist);
        return -1;
      }
      OptPgpCheckTrust = false;
      if (C_PgpSelfEncrypt || (C_PgpEncryptSelf == MUTT_YES))
        self_encrypt = C_PgpDefaultKey;
    }
    if (((WithCrypto & APPLICATION_SMIME) != 0) && (msg->security & APPLICATION_SMIME))
    {
      *keylist = crypt_smime_find_keys(addrlist, oppenc_mode);
      if (!*keylist)
      {
        mutt_addr_free(&addrlist);
        return -1;
      }
      if (C_SmimeSelfEncrypt || (C_SmimeEncryptSelf == MUTT_YES))
        self_encrypt = C_SmimeDefaultKey;
    }
  }

  if (!oppenc_mode && self_encrypt && *self_encrypt)
  {
    const size_t keylist_size = mutt_str_strlen(*keylist);
    mutt_mem_realloc(keylist, keylist_size + mutt_str_strlen(self_encrypt) + 2);
    sprintf(*keylist + keylist_size, " %s", self_encrypt);
  }

  mutt_addr_free(&addrlist);

  return 0;
}