fetchmail-friends
[Top] [All Lists]

[fetchmail]'showdots' function doesn't work with multiple 'poll' entries

2004-04-19 04:42:49
This is a weird one! However I've managed to work it out and the patch is
attached (patch-bc).

Code: fetchmail-6.2.5

I have two "poll" entries in my .fetchmailrc. This turns out to be critical.

Problem: 'set showdots' in .fetchmailrc does not actually cause the dots to
be shown, nor does giving the '--showdots' option on the command line,
although both are parsed and accepted.

--configdump shows that the option is 'true', whether or not 'set showdots'
exists in the config file.

$ grep showdots .fetchmailrc
$ fetchmail --configdump | grep showdots
    'showdots':TRUE,
$ fetchmail --showdots --configdump | grep showdots
    'showdots':TRUE,

However, putting a fprintf in function readbody() in transact.c shows that
run.showdots is zero at that point.

Putting "set no showdots" in the config file does change the value given by
configdump:

$ fetchmail --configdump | grep showdots
    'showdots':FALSE,

*and* it causes the dots to be printed!

I don't see an option to do that on the command line (--noshowdots,
--no-showdots and --showdots=no all give syntax errors)

Right, thanks to fprintf, I can isolate the problem as follows.

(1) boolean flags have special values before they are turned into their
'final' values:

/* we need to use zero as a flag-uninitialized value */
#define FLAG_TRUE       2
#define FLAG_FALSE      1

(2) the showdots flag is converted to a C boolean value here in fetchmail.c

            /* one global gets treated specially */
            DEFAULT(run.showdots, run.poll_interval==0 || nodetach);

(3) fprintf shows that this is run *twice*. The first time, run.showdots is
0 (uninitialised) and so is set to 1 (true). The second time, its initial
value is 1 (FLAG_FALSE) and so it is set to 0 (false).

It is being run twice because I have two 'poll' entries. If I change one to
'skip' then it's fine.

The solution is to move the 'showdots' setting out of the ctl loop: patch
attached.

However, it might also make sense to reverse the flags, so that FLAG_TRUE is
1 and FLAG_FALSE is 2 - or even to make -1 the value for 'uninitialized' and
then FLAG_FALSE and FLAG_TRUE can keep their normal C values of 0 and 1 - to
make this sort of thing less likely to occur in future.

Incidentally, two other patches are attached:

patch-bb is my final solution to the ssl certificate problem. Now, the CN
mismatch error is only printed if verbose or sslcertck are selected (same as
any other certificate errors). Also, the sslcertpath option is honoured even
if sslcertck is not selected; this is useful because 'fetchmail -v' can
validate certificates correctly, even if you don't want it to abort on error
which sslcertck does.

patch-ba removes the useless 3-second sleep after a POP3 login. fetchmail
now just zips along!!

Regards,

Brian.

Attachment: patch-bc
Description: Text document

Attachment: patch-bb
Description: Text document

Attachment: patch-ba
Description: Text document

<Prev in Thread] Current Thread [Next in Thread>
  • [fetchmail]'showdots' function doesn't work with multiple 'poll' entries, Brian Candler <=