patch for passing SASL log messages with different syslog facilities

Andrey V. Malyshev amal at krasn.ru
Fri Nov 11 07:03:29 EST 2005


Hello!
Excuse me for persistence, but I'm again here.

This message deals with the logging subsystem of cyrus-sasl2 (v.2.1.21).

Actually, my motivation here is to realise such feature:
"pass SASL log messages with different syslog facilities, according to
application-specific options (from /usr/lib/sasl2/application_name.conf)".

For example, I do not want to see pop3/imap SASL-generated messages (when
cyrus-imapd works) in /var/log/auth.log, where all auth.* messages are
collecting. Thus I want to pass SASL messages, for exapmle, with
facility=local6 (as cyrus-imap do), when it works with cyrus-imapd.

I'm offering my solution here (and patch, of course).

1) First of all. This fragment (from lib/common.c:1221)

#ifdef HAVE_SYSLOG
  case SASL_CB_LOG:
    *pproc = (int (*)()) &_sasl_syslog;
    *pcontext = NULL;
    return SASL_OK;
#endif /* HAVE_SYSLOG */

disables using context information in _sasl_syslog (due to *pcontext = NULL
instead of *pcontext = conn;).
It means, as I can see, that any application-specific parameter, including
parameter "log_level", described in doc/options.html, does not work at all
when _sasl_syslog() is called.
If it is a deliberate decision - why?

Below I use *pcontext = conn in that line.

2) The second step is to change ALL calls of  *->utils->log(NULL, ...) to
pass corresponding context instead of NULL.
For now some plugins (f.e., digest-md5) do it (not at all),
some - do not at all.
Why? The corresponding context is always available, it stores in
*->utils->conn variable.
I've used simple sh/sed script to rewrite all NULL-contexted calls of
utils->log().

And the third step is to add support for corresponding application-based
parameter.
I call it "syslog_facility", it takes numeric decimal values according to
/usr/include/syslog.h, from LOG_KERN to LOG_LOCAL7.
Default value is LOG_AUTH.
For above-mentioned example (for logging together with cyrus-imap) I use
next values in file /usr/local/lib/sasl2/Cyrus.conf:

syslog_facility: 176
log_level: 7

where 176 is decimal value from this line of syslog.conf:
#define LOG_LOCAL6      (22<<3)

4) And the last point: it seems reasonable to prepend log messages with
"SASL2:" prefix. How do you think?

I am attaching patch for all above described. I've splitted it into two
parts.
First part contains realisation of pp. 1,3,4.
Second part is realisation of point 2.

Thanks for attention.

P.S. Whether developers read this maillist? Are they interesting in any
patches like I've sent earlier and sending now?
May be I have to stop to send it here (or stop sending at all) - tell me, if
yes :-)

-- 
With best regards, Andrey V. Malyshev.
E-mail: amal at krasn.ru 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch-syslog_facility.tgz
Type: application/octet-stream
Size: 10058 bytes
Desc: not available
Url : https://lists.andrew.cmu.edu/mailman/private/cyrus-devel/attachments/20051111/a5664ce9/patch-syslog_facility-0001.obj


More information about the Cyrus-devel mailing list