Skip to content

Commit

Permalink
updated , smtpd.c, autoresponder.c, svctool
Browse files Browse the repository at this point in the history
1. smtpd.c: Fix (double) error message for unsupported AUTH method
2. smtpd.c: Fix SEGV when decoding SRS recipient address
3. autoresponder.c: decode SRS return path address
4. svctool: make QmailHOME, INDIMAILDIR configurable through env variable
  • Loading branch information
mbhangui committed Oct 2, 2023
1 parent e8d531d commit 25d1d56
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 43 deletions.
27 changes: 20 additions & 7 deletions indimail-mta-x/autoresponder.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* $Id: autoresponder.c,v 1.39 2023-10-01 11:44:44+05:30 Cprogrammer Exp mbhangui $
* $Id: autoresponder.c,v 1.39 2023-10-02 17:40:58+05:30 Cprogrammer Exp mbhangui $
*
* This is a simple program to automatically respond to emails.
*
Expand Down Expand Up @@ -73,7 +73,7 @@ static char ssinbuf[512], ssoutbuf[512];
static char strnum[FMT_ULONG];
substdio ssin, ssout;
static pid_t inject_pid;
static stralloc liphost = { 0 }, content_type = { 0 };
static stralloc liphost = { 0 }, content_type = { 0 }, srs_domain = { 0 };
struct header
{
char *returnpath;
Expand Down Expand Up @@ -993,7 +993,7 @@ mkTempFile(int seekfd)
int
main(int argc, char *argv[])
{
int fdout, match;
int fdout, match, len, do_srs = 0, at;
char *sender, *dtrecip, *host, *ptr;
char dbuf[DATE822FMT];
#ifdef MIME
Expand Down Expand Up @@ -1026,6 +1026,11 @@ main(int argc, char *argv[])
strerr_die2sys(111, FATAL, "unable to read doublebounceto controls: ");
if ((liphostok = control_rldef(&liphost, "localiphost", 1, (char *) 0)) == -1)
strerr_die2sys(111, FATAL, "unable to read localiphost controls: ");
if (control_readline(&srs_domain, (ptr = env_get("SRS_DOMAIN")) && *ptr ? ptr : (ptr = "srs_domain")) == -1)
strerr_die4sys(111, FATAL, "unable to read ", ptr, " controls: ");
if (srs_domain.len && !stralloc_0(&srs_domain))
strerr_die2x(111, FATAL, "out of memory");
srs_domain.len--; /*- substract length due to stralloc_0 */
if (env_get("MAKE_SEEKABLE") && mkTempFile(0))
strerr_die2sys(111, FATAL, "makeseekable: ");
get_arguments(argc, argv);
Expand All @@ -1036,7 +1041,15 @@ main(int argc, char *argv[])
usage("DTLINE is not set; must be run from .qmail");
dtline_len = str_len(dtline);
#ifdef HAVESRS
if (*sender && (case_starts(sender, "SRS0=") || case_starts(sender, "SRS1="))) {
if (srs_domain.len && (case_starts(sender, "SRS0=") || case_starts(sender, "SRS1="))) {
len = str_len(sender);
if ((at = byte_rchr(sender, len, '@')) < len - 2) {
if (!str_diffn(srs_domain.s, sender + at + 1,
srs_domain.len > (len - at - 1) ? srs_domain.len + 1 : len - at))
do_srs = 1;
}
}
if (do_srs) {
switch (srsreverse(sender))
{
case -3:
Expand Down Expand Up @@ -1286,15 +1299,15 @@ main(int argc, char *argv[])
void
getversion_qmail_autoresponder_c()
{
static char *x = "$Id: autoresponder.c,v 1.39 2023-10-01 11:44:44+05:30 Cprogrammer Exp mbhangui $";
static char *x = "$Id: autoresponder.c,v 1.39 2023-10-02 17:40:58+05:30 Cprogrammer Exp mbhangui $";

x++;
}

/*
* $Log: autoresponder.c,v $
* Revision 1.39 2023-10-01 11:44:44+05:30 Cprogrammer
* decode SRS return path address
* Revision 1.39 2023-10-02 17:40:58+05:30 Cprogrammer
* decode srs return path address
*
* Revision 1.38 2023-03-26 01:52:43+05:30 Cprogrammer
* fixed code using wait_handler.
Expand Down
7 changes: 5 additions & 2 deletions indimail-mta-x/doc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ Release @version@-@release@ Start 11/09/2023 End --/--/----
- 30/09/2023
41. svctool: added --chksender option to enable CHECKSENDER
42. qmail-lspawn.c: skip setuser_privileges for non-etc-passwd users
- 01/10/2023
43. autoresponder.c: decode SRS return path address
- 02/10/2023
43. smtpd.c: Fix (double) error message for unsupported AUTH method
44. smtpd.c: Fix SEGV when decoding SRS recipient address
45. svctool: make QmailHOME, INDIMAILDIR configurable through env variable
46. autoresponder.c: decode SRS return path address

* Fri Sep 08 2023 11:58:03 +0000 Manvendra Bhangui <indimail-mta@indimail.org> 3.0.4-1.1%{?dist}
Release 3.0.4-1.1 Start 24/04/2023 End 08/09/2023
Expand Down
29 changes: 19 additions & 10 deletions indimail-mta-x/smtpd.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* RCS log at bottom
* $Id: smtpd.c,v 1.302 2023-09-28 01:12:49+05:30 Cprogrammer Exp mbhangui $
* $Id: smtpd.c,v 1.303 2023-10-02 17:46:10+05:30 Cprogrammer Exp mbhangui $
*/
#include <unistd.h>
#include <fcntl.h>
Expand Down Expand Up @@ -155,7 +155,7 @@ static SSL *ssl = NULL;
static struct strerr *se;
#endif
static int tr_success = 0;
static char *revision = "$Revision: 1.302 $";
static char *revision = "$Revision: 1.303 $";
static char *protocol = "SMTP";
static stralloc proto = { 0 };
static stralloc Revision = { 0 };
Expand Down Expand Up @@ -1764,7 +1764,7 @@ err_noauth()
{
out("504 auth type unimplemented (#5.5.1)\r\n", NULL);
flush();
return -1;
return -3;
}

#ifdef TLS
Expand Down Expand Up @@ -2556,8 +2556,6 @@ open_control_files1()
die_control("locals");
if (!constmap_init(&maplocals, locals.s, locals.len, 0))
die_nomem();
#ifdef USE_SPF
#endif
}

/*
Expand Down Expand Up @@ -2655,15 +2653,18 @@ open_control_files2()
}
#endif
#ifdef HAVESRS
if (control_readline(&srs_domain, (x = env_get("SRS_DOMAIN")) && *x ? x : "srs_domain") == -1)
die_control(x);
if (srs_domain.len && !stralloc_0(&srs_domain))
die_nomem();
srs_domain.len--; /*- substract length due to stralloc_0 */
if ((r = srs_setup(0)) < 0) {
logerr(1, "srs_setup failed\n", NULL);
logflush();
out("451 Sorry, I'm unable to read srs controls (#4.3.0)\r\n", NULL);
flush();
_exit(1);
}
if (r)
srs_domain.len--; /*- substract length due to stralloc_0 */
#endif
open_control_once(&acclistok, 0, &accFn, 0, "ACCESSLIST", 0, "accesslist", 0, &acclist, 0, 0);
if ((x = env_get("BODYCHECK"))) {
Expand Down Expand Up @@ -4139,8 +4140,9 @@ smtp_rcpt(char *arg)
#ifdef HAVESRS
do_srs = 0;
if (srs_domain.len && (case_starts(addr.s, "SRS0=") || case_starts(addr.s, "SRS1="))) {
if ((at = byte_rchr(addr.s, addr.len - 1, '@')) < addr.len - 1) {
if (!str_diffn(srs_domain.s, addr.s + at + 1, srs_domain.len > (addr.len - 2 - at) ? srs_domain.len : addr.len - at - 1))
if ((at = byte_rchr(addr.s, addr.len - 1, '@')) < addr.len - 3) {
if (!str_diffn(srs_domain.s, addr.s + at + 1,
srs_domain.len > (addr.len - at - 2) ? srs_domain.len + 1 : addr.len - at - 1))
do_srs = 1;
}
}
Expand Down Expand Up @@ -6294,6 +6296,9 @@ smtp_auth(char *arg)
case -2: /*- returned by err_noauthallowed() when SECURE_AUTH is set and TLS isn't used */
err_authinsecure(j);
break;
case -3: /*- returned by err_noauth() for invalid auth type */
err_authfailure(user.len ? user.s : 0, j);
break;
default:
err_child();
break;
Expand Down Expand Up @@ -7173,6 +7178,10 @@ addrrelay()

/*
* $Log: smtpd.c,v $
* Revision 1.303 2023-10-02 17:46:10+05:30 Cprogrammer
* Fix (double) error message for unsupported AUTH method
* Fix SEGV when decoding SRS recipient address
*
* Revision 1.302 2023-09-28 01:12:49+05:30 Cprogrammer
* added check sender feature
*
Expand Down Expand Up @@ -7535,7 +7544,7 @@ addrrelay()
char *
getversion_smtpd_c()
{
static char *x = "$Id: smtpd.c,v 1.302 2023-09-28 01:12:49+05:30 Cprogrammer Exp mbhangui $";
static char *x = "$Id: smtpd.c,v 1.303 2023-10-02 17:46:10+05:30 Cprogrammer Exp mbhangui $";

x++;
return revision + 11;
Expand Down
58 changes: 34 additions & 24 deletions indimail-mta-x/svctool.in
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
#
# $Id: svctool.in,v 2.706 2023-09-30 11:10:32+05:30 Cprogrammer Exp mbhangui $
# $Id: svctool.in,v 2.707 2023-10-02 02:44:38+05:30 Cprogrammer Exp mbhangui $
#

#
# User Configuration
#
QmailHOME=@qmaildir@
indimaildir=@indimaildir@
[ -z "$QmailHOME" ] && QmailHOME="/var/indimail"
[ -z "$INDIMAILDIR" ] && INDIMAILDIR="/var/indimail"
#indimaildir=`awk -F: '{print $6}' /etc/passwd|grep indimail|head -1`
indimaildir=$INDIMAILDIR
QmailBinPrefix=@prefix@
mandir=@mandir@
libexecdir=@libexecdir@
sysconfdir=@sysconfdir@
shareddir=@shareddir@
LOGDIR=@logdir@
#indimaildir=`awk -F: '{print $6}' /etc/passwd|grep indimail|head -1`
CONCURRENCYINCOMING=150
min_free=52428800
DATABYTES=20971520
Expand All @@ -26,7 +27,7 @@ host=@HOST@
shared_objects=0
use_dlmopen=0
skip_sendmail_check=0
RCSID="# \$Id: svctool.in,v 2.706 2023-09-30 11:10:32+05:30 Cprogrammer Exp mbhangui $"
RCSID="# \$Id: svctool.in,v 2.707 2023-10-02 02:44:38+05:30 Cprogrammer Exp mbhangui $"

#
# End of User Configuration
Expand Down Expand Up @@ -8700,6 +8701,9 @@ default_alias_config()
if [ ! -d $t -o ! -d $t/new -o ! -d $t/cur -o ! -d $t/tmp ] ; then
echo "Creating catch-all alias ($t) for all system users"
fi
if [ ! -d $QmailHOME/alias ] ; then
mkdir -p $QmailHOME/alias
fi
if [ -x "$DESTDIR"$QmailBinPrefix/bin/maildirmake ] ; then
"$DESTDIR"$QmailBinPrefix/bin/maildirmake "$DESTDIR"$t >/dev/null 2>&1
else
Expand All @@ -8711,29 +8715,35 @@ default_alias_config()
$chown -R alias:qmail "$DESTDIR"$t
/bin/chmod -R 775 "$DESTDIR"$t
fi
/bin/rm -f "$DESTDIR"$QmailHOME/alias/.qmail-postmaster
first_char=`echo $postmaster | cut -c1`
if [ " $first_char" = " /" ] ; then
if [ -x "$DESTDIR"$QmailBinPrefix/bin/maildirmake ] ; then
"$DESTDIR"$QmailBinPrefix/bin/maildirmake "$DESTDIR"$postmaster >/dev/null 2>&1
else
/bin/mkdir -p "$DESTDIR"$postmaster/tmp >/dev/null 2>&1
/bin/mkdir -p "$DESTDIR"$postmaster/new >/dev/null 2>&1
/bin/mkdir -p "$DESTDIR"$postmaster/cur >/dev/null 2>&1
fi
if [ $? -eq 0 ] ; then
$chown -R alias:qmail "$DESTDIR"$postmaster
/bin/chmod -R 775 "$DESTDIR"$postmaster
if [ $force -eq 1 -o ! -f "$DESTDIR"$QmailHOME/alias/.qmail-postmaster ] ; then
/bin/rm -f "$DESTDIR"$QmailHOME/alias/.qmail-postmaster
first_char=`echo $postmaster | cut -c1`
if [ " $first_char" = " /" ] ; then
if [ -x "$DESTDIR"$QmailBinPrefix/bin/maildirmake ] ; then
"$DESTDIR"$QmailBinPrefix/bin/maildirmake "$DESTDIR"$postmaster >/dev/null 2>&1
else
/bin/mkdir -p "$DESTDIR"$postmaster/tmp >/dev/null 2>&1
/bin/mkdir -p "$DESTDIR"$postmaster/new >/dev/null 2>&1
/bin/mkdir -p "$DESTDIR"$postmaster/cur >/dev/null 2>&1
fi
if [ $? -eq 0 ] ; then
$chown -R alias:qmail "$DESTDIR"$postmaster
/bin/chmod -R 775 "$DESTDIR"$postmaster
fi
fi
echo $postmaster > "$DESTDIR"$QmailHOME/alias/.qmail-postmaster
$chown -R alias:qmail "$DESTDIR"$QmailHOME/alias/.qmail-postmaster
fi
echo $postmaster > "$DESTDIR"$QmailHOME/alias/.qmail-postmaster
$chown -R alias:qmail "$DESTDIR"$QmailHOME/alias/.qmail-postmaster
cd "$DESTDIR"$QmailHOME/alias
if [ $? -eq 0 ] ; then
/bin/rm -f .qmail-root
/bin/rm -f .qmail-mailer-daemon
/bin/ln -s .qmail-postmaster .qmail-root
/bin/ln -s .qmail-postmaster .qmail-mailer-daemon
if [ ! -f .qmail-root -o $force -eq 1 ] ; then
/bin/rm -f .qmail-root
/bin/ln -s .qmail-postmaster .qmail-root
fi
if [ ! -f .qmail-mailer-daemon -o $force -eq 1 ] ; then
/bin/rm -f .qmail-mailer-daemon
/bin/ln -s .qmail-postmaster .qmail-mailer-daemon
fi
fi
}

Expand Down

0 comments on commit 25d1d56

Please sign in to comment.