Joerg,

Thanks for your advice.

I introduced a "goto label" because if I add a log_warn() function before the return, smtpd start and exit right away.

Your fix produce a segmentation fault with the portable version.

Either way I don't know why a debugging function exit/crash the daemon.

Regards,
*Alexis VACHETTE | Network and System Engineer
* Sisteer France: 43 rue Pierre Valette, 92240 Malakoff – France
Direct line: +33 1 70 95 51 19 | Fax: +33 1 70 95 50 90
www.sisteer.com <http://www.sisteer.com>
On 11/01/2016 12:52, Joerg Jung wrote:
On Mon, Jan 11, 2016 at 10:25:47AM +0100, Alexis VACHETTE wrote:
Hi,

It was stated last week that OpenSMTPD daemon doesn't throw any warning if a
specific table isn't readable by OpenSMTPD user.

I made a patch for the portable version on github :

*** a/table_static.c    2016-01-11 10:16:15.486422024 +0100
--- b/table_static.c    2016-01-08 12:58:58.564321019 +0100
***************
*** 95,101 ****

       fp = fopen(config, "r");
       if (fp == NULL)
!         return 0;

       while ((flen = getline(&buf, &sz, fp)) != -1) {
           if (buf[flen - 1] == '\n')
--- 95,101 ----

       fp = fopen(config, "r");
       if (fp == NULL)
!         goto err;

       while ((flen = getline(&buf, &sz, fp)) != -1) {
           if (buf[flen - 1] == '\n')
***************
*** 143,148 ****
--- 143,151 ----
       free(buf);
       fclose(fp);
       return ret;
+ err:
+         log_warn("warn: Table \"%s\"", config);
+         return 0;
   }

   static int

If someone could review it and test it before I fork the repository and make
a merge request on github.
Some notes:

- Development happens in OpenBSD -current, so please diff against CVS.
- Please send unified diffs (not context output as above).
- I do not see the point of introducing a goto/label, just add the log
   message and return, also if check can be folded, like this:

if ((fp = fopen(config, "r") == NULL) {
        log_warn("warn: table \"%s\"", config);
        return 0;
}

Thank you.

Regards,
Alexis VACHETTE.

--
You received this mail because you are subscribed to misc@opensmtpd.org
To unsubscribe, send a mail to: misc+unsubscr...@opensmtpd.org


Reply via email to