/* * Copyright (c) 2006 Sendmail, Inc. and its suppliers. * All rights reserved. * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the sendmail distribution. */ #include "sm/generic.h" SM_RCSID("@(#)$Id: pmilter_mailmod.c,v 1.5 2006/10/05 04:27:38 ca Exp $") #include "sm/error.h" #include "sm/assert.h" #include "pmilter.h" #include "sm/pmfdef.h" #include "sm/pmfapi.h" #include "sm/pmilter.h" #if MTA_USE_PMILTER /* ** SM_PMFI_MAIL_RPLC -- Replace MAIL address ** ** Parameters: ** pmse_ctx -- pmilter/SMTP server session context ** mail_pa -- new MAIL address (rfc 2821 format) ** args -- ESMTP parameters for MAIL ** (currently ignored) ** ** Returns: ** usual sm_error code */ sm_ret_T sm_pmfi_mail_rplc(pmse_ctx_P pmse_ctx, const char *mail_pa, char *args) { size_t len; SM_IS_PMSE_CTX(pmse_ctx); if (NULL == mail_pa) return sm_error_perm(SM_EM_PMILTER, EINVAL); if (!SM_IS_FLAG(pmse_ctx->pmse_pmss_ctx->pmss_pmcap, SM_SCAP_PM_MAILMOD)) return sm_error_perm(SM_EM_PMILTER, SM_E_PR_ERR); if (pmse_ctx->pmse_state != PMSE_ST_DOT) return sm_error_perm(SM_EM_PMILTER, SM_E_PR_ERR); len = strlen(mail_pa); if (len < 2 || len > MAXADDRLEN) return sm_error_perm(SM_EM_PMILTER, EINVAL); if (mail_pa[0] != '<' || mail_pa[len - 1] != '>') return sm_error_perm(SM_EM_PMILTER, EINVAL); /* do a full syntax check here?? */ pmse_ctx->pmse_mail_new = sm_str_scpyn0(NULL, mail_pa, len + 1, len + 2); if (NULL == pmse_ctx->pmse_mail_new) return sm_error_temp(SM_EM_PMILTER, ENOMEM); return SM_SUCCESS; } #endif /* MTA_USE_PMILTER */