15.03.2025 19:40, Wietse Venema via Postfix-users wrote:
Michael Tokarev via Postfix-users:
I'm sure I've seen this issue before here on postfix-users.
But can't find it.
When main.cf does not have a trailing newline, ,..,,
Well don't do that, then. Use a proper text editor, or better, use
postconf commands to manage Postfix configuration files.
For some, it's easier to manage things using an editor than postconf.
And it's easier to fix the tool instead of relying on everyone out
there using "proper" editor. Right now it is postfix (postconf utility)
which corrupts its own configuration.
I'm adding the following patch to the debian postfix package to fix
https://bugs.debian.org/1100449
Thanks,
/mjt
From 7c14df90836aed7060a8eac8bab8e883297e2078 Mon Sep 17 00:00:00 2001
From: Michael Tokarev <m...@tls.msk.ru>
Date: Sat, 15 Mar 2025 19:51:16 +0300
Subject: [PATCH] postconf: ensure the file ends with a newline
Signed-off-by: Michael Tokarev <m...@tls.msk.ru>
---
src/postconf/postconf_edit.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/postconf/postconf_edit.c b/src/postconf/postconf_edit.c
index 7085acd72..b84b221f2 100644
--- a/src/postconf/postconf_edit.c
+++ b/src/postconf/postconf_edit.c
@@ -113,8 +113,14 @@ static char *pcf_find_cf_info(VSTRING *buf, VSTREAM *dst)
static char *pcf_next_cf_line(VSTRING *buf, VSTREAM *src, VSTREAM *dst, int *lineno)
{
char *cp;
+ int c;
- while (vstring_get(buf, src) != VSTREAM_EOF) {
+ while ((c = vstring_get(buf, src)) != VSTREAM_EOF) {
+ if (c != '\n') {
+ /* add newline if there's none */
+ VSTRING_ADDCH(buf, '\n');
+ VSTRING_TERMINATE(buf);
+ }
if (lineno)
*lineno += 1;
if ((cp = pcf_find_cf_info(buf, dst)) != 0)
@@ -225,7 +231,6 @@ void pcf_edit_main(int mode, int argc, char **argv)
* Copy original file to temp file, while replacing parameters on the
* fly. Issue warnings for names found multiple times.
*/
-#define STR(x) vstring_str(x)
interesting = 0;
while ((cp = pcf_next_cf_line(buf, src, dst, (int *) 0)) != 0) {
--
2.39.5
_______________________________________________
Postfix-users mailing list -- postfix-users@postfix.org
To unsubscribe send an email to postfix-users-le...@postfix.org