From: Jeremy Harris Date: Thu, 4 Jun 2020 12:54:55 +0000 (+0100) Subject: Fix -bi. Bug 2590 X-Git-Tag: exim-4.95-RC0~337 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/0e0e1716286028c369f93a28412839c657e6b47c Fix -bi. Bug 2590 Actual fix from pierre.labastie@neuf.fr ; additional coding and testcase bu jgh Broken-by: bdcc6f2bd5 --- diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index d9959d5ac..2c3335856 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -21,6 +21,10 @@ JH/03 Bug 2586: Fix listcount expansion operator. Using tainted arguments is "log_reject_target", "malware" and "spam"; the arguments are expanded so could be handling tainted values. +JH/04 Bug 2590: Fix -bi (newaliases). A previous code rearrangement had + broken the (no-op) support for this sendmail command. Restore it + to doing nothing, silently, and returning good status. + Exim version 4.94 ----------------- diff --git a/src/src/exim.c b/src/src/exim.c index 2f4149f6f..0b7b87ed5 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -2149,7 +2149,7 @@ on the second character (the one after '-'), to save some effort. */ concept of *the* alias file, but since Sun's YP make script calls sendmail this way, some support must be provided. */ case 'i': - if (!*++argrest) bi_option = TRUE; + if (!*argrest) bi_option = TRUE; else badarg = TRUE; break; @@ -4117,7 +4117,7 @@ script. */ if (bi_option) { (void)fclose(config_file); - if (bi_command) + if (bi_command && *bi_command) { int i = 0; uschar *argv[3]; @@ -4128,11 +4128,11 @@ if (bi_option) setgroups(group_count, group_list); exim_setugid(real_uid, real_gid, FALSE, US"running bi_command"); - DEBUG(D_exec) debug_printf("exec %.256s %.256s\n", argv[0], - argv[1] ? argv[1] : US""); + DEBUG(D_exec) debug_printf("exec '%.256s' %s%.256s%s\n", argv[0], + argv[1] ? "'" : "", argv[1] ? argv[1] : US"", argv[1] ? "'" : ""); execv(CS argv[0], (char *const *)argv); - exim_fail("exim: exec failed: %s\n", strerror(errno)); + exim_fail("exim: exec '%s' failed: %s\n", argv[0], strerror(errno)); } else { diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c index b9cf540a9..09586c335 100644 --- a/src/src/smtp_in.c +++ b/src/src/smtp_in.c @@ -1824,9 +1824,12 @@ s_connhad_log(gstring * g) const uschar * sep = smtp_connection_had[SMTP_HBUFF_SIZE-1] != SCH_NONE ? US" C=..." : US" C="; -for (int i = smtp_ch_index; i < SMTP_HBUFF_SIZE; i++, sep = US",") +for (int i = smtp_ch_index; i < SMTP_HBUFF_SIZE; i++) if (smtp_connection_had[i] != SCH_NONE) + { g = string_append(g, 2, sep, smtp_names[smtp_connection_had[i]]); + sep = US","; + } for (int i = 0; i < smtp_ch_index; i++, sep = US",") g = string_append(g, 2, sep, smtp_names[smtp_connection_had[i]]); return g; diff --git a/test/confs/0590 b/test/confs/0590 new file mode 100644 index 000000000..224d05919 --- /dev/null +++ b/test/confs/0590 @@ -0,0 +1,12 @@ +# Exim test configuration 0590 + +OPT = + +.include DIR/aux-var/std_conf_prefix + + +# ----- Main settings ----- + +OPT + +# End diff --git a/test/scripts/0000-Basic/0590 b/test/scripts/0000-Basic/0590 new file mode 100644 index 000000000..63fedab35 --- /dev/null +++ b/test/scripts/0000-Basic/0590 @@ -0,0 +1,6 @@ +# -bi / newaliases +# +exim -bi +**** +exim -DOPT=bi_command=/bin/echo -bi -oA 'hello from -bi' +**** diff --git a/test/stdout/0590 b/test/stdout/0590 new file mode 100644 index 000000000..6bd819d51 --- /dev/null +++ b/test/stdout/0590 @@ -0,0 +1 @@ +hello from -bi