[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: logging from PAM modules



> > >   char defbuf[256];  <== some not very large but still enouth
> > >                          for most cases size
> > >   char *buf = defbuf;
> > >   int size = sizeof(defbuf);
> > >   while (snprintf(buf, size, ...) cant fit in size) {
> > 
> > The "can't fit" is ">= size" with non-broken snprintf()'s.  I don't
> > think we should support broken ones at all, simply use a reasonable
> > size by default and, if that isn't enough, a truncated log entry is
> > the price paid for using a broken libc. ;-)
> 
> I didn't mean broken snprintf/etc, maybe I just improperly
> written that condition.  I mean "while(size isn't enouth for
> formatted string of full length)".

I understood you the first time, -- I simply translated some of your
pseudo-code to C in one of the possible ways.

> > Yes, this is what I meant.  I don't think you need that one buffer on
> > the stack, -- it only adds complexity.  You also need a free().
> it adds minimal complexity and removes unnecessary for 99.9% cases
> malloc/free pair.

It removes the extra CPU time those calls would take, but it doesn't
remove the calls from the source.  I don't think we want a minimal
performance improvement to the logging function (which is definitely
not performance-critical) if that has a complexity cost (even if the
cost is minimal).

> [pam_log vs pam_log & pam_vlog]

> Sometimes it is very nice to have two-args log(format, va_list) --

Agreed.

I also agree that the callback pointer should be inside pamh.

Signed,
Solar Designer





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []