Dear Turbo

Thank you for your reply.

Turbo Fredriksson wrote:
Quoting Steve Chan <[EMAIL PROTECTED]>:


In Fedora 6 environment, I patched original qmail 1.03
(qmail-1.03.tar.gz) with qmail-ldap-1.03-20060201.patch, then with
qmail-ldap-1.03-20060201-controls20060403b.


I failed to compile it.


Why not?

Here is the error messages:
-------------------------------------------------------------------------
./compile -DALTQUEUE -DQLDAP_CLUSTER -DUSE_CONTROLDB -DQLDAP_BAILOUT -DSECUREBIND_ALL control.c control.c:62: error: static declaration of 'sasl_flags' follows non-static declaration
control.h:19: error: previous declaration of 'sasl_flags' was here
control.c: In function 'control_ldap_search':
control.c:408: warning: incompatible implicit declaration of built-in function 'strndup'
control.c:463: warning: assignment makes pointer from integer without a cast
make: *** [control.o] Error 1
-------------------------------------------------------------------------

That's why I trace the variable "sasl_flags". I look at the source code and found that the field just used in a few locations.




1.  Commented out "extern unsigned sasl_flags;" in control.h.  It
seems that sasl_flags are defined as static in all programs using this
header file.


Which is absolute nonsense... Sorry, but it is.

If you don't want SASL, don't enable SECUREBIND. The fix is THAT
simpe... Simpler than hacking the code to disable it (which you where
doing)...

-------------------------------------------------------------------------
# grep sasl_flags *.h *.c
control.h:extern unsigned sasl_flags;
control.c:static unsigned sasl_flags = LDAP_SASL_AUTOMATIC;
control.c:      sasl_flags = LDAP_SASL_QUIET;
qldap.c:unsigned        sasl_flags      = LDAP_SASL_AUTOMATIC;
qmail-ldapctrld.c:static unsigned sasl_flags = LDAP_SASL_AUTOMATIC;
-------------------------------------------------------------------------

"sasl_flags" is static in control.c, qladap.c and qmail-ldapctrld.c
"extern unsigned sasl_flags;" in control.h is redundant, isn't it?




2.  Replaced function verify_ldap_file_check with old source code (use
strcmp instead of strstr).


Why?


The strstr code has bug.


In what way?

The few statements are to make sure that the required control (i.e., fn) is not "me", "ldapserver", "ldapcontroldn", "ldaplogin", or "ldappassword". However, during my debug process, the value of fn sometimes got "xxx", sometimes got "control/xxx" (where xxx identify a control name). I couldn't remember which control actually cause the problem. I think it is "control/me" from function "control_init". If fn="me", then strstr(fn, "me") will return a pointer point to fn; if fn="control/me", then strstr(fn, "me") will return a pointer pointing to fn+8. Then (strstr(fn, "me") == fn) will return false. Hence the "verify_ldap_file_check" function will return 0. Then LDAP will never be checked. The old code checked all the formats: "xxx", "control/xxx" and even "/var/qmail/control/xxx".

I just use the old code in my working version (with older qmail-ldap patch and qmail-ldap-control patch) runing in Fedora 3 environment.



3.  Included str_diffn.o in the qmail-newmrh section of Makefile.
Someone suggested this change in this newgroup.


Why (see below)?


This is due to another compilation error:
-------------------------------------------------------------------------
./compile -DALTQUEUE -DQLDAP_CLUSTER -DUSE_CONTROLDB -DQLDAP_BAILOUT -DSECUREBIND_ALL qmail-newmrh.c
./load qmail-newmrh getln.a open.a cdbmake.a seek.a \
        case.a stralloc.a alloc.a strerr.a substdio.a error.a \
        qldap.a read-ctrl.o case.a str.a auto_qmail.o \
control.o stralloc.a fs.a getopt.a substdio.a -L/usr/local/lib -lldap -llber
control.o: In function `control_ldap_search':
control.c:(.text+0xaaf): undefined reference to `str_diffn'
control.c:(.text+0xf84): undefined reference to `str_diffn'
collect2: ld returned 1 exit status
make: *** [qmail-newmrh] Error 1
-------------------------------------------------------------------------

I just found two solution to fix this problem from this newsgroup:
1.  set DEBUG=-DEBUG in the Makefile, or
2.  add str_diffn.o to the linking of qmail-newmrh.


See also extract from http://qmail.bayour.com/patches_ldap/changelog.txt
------------------------------------------------------------------------
qmail (1.03-25.35) unstable; urgency=low

  * Add a build depends on debhelper and libldap2.2-dev.
  * Upgrade the QmailLDAP patch to version 20050401a.
  * Upgrade QmailLDAP/Controls patch to latest QmailLDAP patch
    - Add 'qldap.a' if: LDAPFLAGS || SECUREBIND || CONTROLDB.
    - Add 'str_diffn.o' to linking of 'qmail-newmrh' if CONTROLDB.

 -- Turbo Fredriksson <[EMAIL PROTECTED]>  Thu, 14 Apr 2005 10:42:45 +0200
------------------------------------------------------------------------



After a lot of debug tracing, I found that the value of "fn" was
cleared after called to "control_ldap_search" in the control_readfile
function.  Someone already mentioned this point in this newsgroup
before.  At last, I disabled the gcc optimization option (I removed
"-O2" from file conf-cc) and everything work fine.


If you can remove your 'fixes' and try again and see if you still get
the same problem I'm happy to discuss this. There ARE bugs here and there,
but most (?) of this seems to come from faulty/missing #ifdef's (I'm not compiling with the same options as any one else it seems :).

I've been running this exact code for almost a year now on multiple machines
without problem, so... ?

I did have "-O2" option in the conf-cc in all previous debug compile. This option is there since 16-Jun-1998 (from the original file date). What I can see is the variable "fn" was cleared when exit from the "control_ldap_search" in "control_readfile". The value is still there before the "return". However, "fn" becomes NULL after return from "control_ldap_search". Then the following "open file" code failed with errno=14. Your version works doesn't means all version works. I'm talking about the GCC 4.1.1 compiler in Fedora 6. Hence I suspect that this is due to compiler problem.

After I removed the "-O2" option, the "fn" cleared problem did not appear again.

I post the message in this newsgroup is to gather more people to verify my result. If the compiler is wrong, we should inform the compiler writers to fix it.




#if defined(SECUREBIND_SASL) || defined(SECUREBIND_ALL)
-extern unsigned sasl_flags;
+//extern unsigned sasl_flags;


As you can see... if you hadn't enabled SECUREBIND_SASL and/or
SECUREBIND_ALL this wouldn't happen...


@@ -1759,7 +1761,7 @@
stralloc.a alloc.a strerr.a substdio.a error.a str.a auto_qmail.o \
$(NEWLDAPPROGLIBS) $(SECUREBINDLIBS) $(QLDAPLIB) $(CONTROLLIBS)
        ./load qmail-newmrh getln.a open.a cdbmake.a seek.a \
-       case.a stralloc.a alloc.a strerr.a substdio.a error.a \
+       case.a stralloc.a alloc.a strerr.a substdio.a error.a str_diffn.o \
        $(QLDAPLIB) $(CONTROLLIBS) str.a auto_qmail.o \
        $(NEWLDAPPROGLIBS) $(SECUREBINDLIBS) $(LDAPLIBS)


Why this? This however looks like a fix I've seen before, but can't
remember if I could reproduce...



Yes, this fix come from this newsgroup.

BTW, please also read this:
http://www.mail-archive.com/qmail-ldap@qmail-ldap.org/msg05268.html

What he described is exactly my findings.


Regards
Steve

Reply via email to