Mailing List Archive

ldap fix
Hi there,

I'm updating the experimental packages for dbmail-2 (sorry for the long
delay).

I've had to fix some typos in authldap.c

Patch attached for your building pleasure. Ilja, can you commit this
please ?



--
________________________________________________________________
Paul Stevens paul@nfg.nl
NET FACILITIES GROUP GPG/PGP: 1024D/11F8CD31
The Netherlands_______________________________________www.nfg.nl
Re: ldap fix [ In reply to ]
done :)

BTW, why use the int64_t in auth_get_known_users()? Because
__auth_get_every_match() returns an int? I guess it would be better to
let that function return an unsigned int. Or am I missing something
here?

thanks for fixing those typos!

cheers,
Ilja

On Dec 3, 2003, at 1:31 PM, Paul J Stevens wrote:

>
>
> Hi there,
>
> I'm updating the experimental packages for dbmail-2 (sorry for the
> long delay).
>
> I've had to fix some typos in authldap.c
>
> Patch attached for your building pleasure. Ilja, can you commit this
> please ?
>
>
>
> --
> ________________________________________________________________
> Paul Stevens paul@nfg.nl
> NET FACILITIES GROUP GPG/PGP: 1024D/11F8CD31
> The Netherlands_______________________________________www.nfg.nl
> --- dbmail_cvs/auth/authldap.c 2003-12-03 11:03:50.000000000 +0100
> +++ dbmail/auth/authldap.c 2003-12-03 12:51:17.000000000 +0100
> @@ -25,6 +25,7 @@
> #include "config.h"
> #endif
>
> +#include "assert.h"
> #include "auth.h"
> #include "dbmail.h"
> #include "db.h"
> @@ -40,7 +41,7 @@
>
> #define AUTH_QUERY_SIZE 1024
>
> -extern char *configFile;
> +static char *configFile = DEFAULT_CONFIG_FILE;
>
> LDAP *_ldap_conn;
> LDAPMod **_ldap_mod;
> @@ -88,6 +89,8 @@
> trace(TRACE_DEBUG, #func ": value for " #val " stored in " #var " as
> [%s]", var)
> /* that's correct, no final ; so when the macro is called, it looks
> "normal" */
>
> +static void __auth_get_config(void);
> +
> static void __auth_get_config()
> {
> struct list ldapItems;
> @@ -181,6 +184,7 @@
> * calls. OTOH, if the calls are always far between, we'd
> * rather just be connected strictly as needed...
> */
> +int auth_reconnect(void);
> int auth_reconnect()
> {
> /* Destroy the old... */
> @@ -628,7 +632,7 @@
> id_char = __auth_get_first_match( query, fields );
>
> *user_idnr = ( id_char ) ? strtoull( id_char, NULL, 0 ) : 0;
> - trace(TRACE_DEBUG, "auth_user_exists(): returned value is [%llu]",
> id );
> + trace(TRACE_DEBUG, "auth_user_exists(): returned value is [%llu]",
> user_idnr );
>
> if( id_char ) free( id_char );
>
> @@ -686,7 +690,7 @@
> cid_char = __auth_get_first_match( query, fields );
>
> *client_idnr = ( cid_char ) ? strtoull( cid_char, NULL, 0 ) : 0;
> - trace(TRACE_DEBUG, "auth_getclientid(): returned value is [%llu]",
> cid );
> + trace(TRACE_DEBUG, "auth_getclientid(): returned value is [%llu]",
> client_idnr );
>
> if( cid_char ) free( cid_char );
>
> @@ -742,7 +746,7 @@
> * return -2 on mem error, -1 on db-error, 0 on success */
> int auth_get_known_users(struct list *users)
> {
> - u64_t known;
> + int64_t known;
> /* u64_t curr; unused variable */
> char query[AUTH_QUERY_SIZE];
> char *fields[] = { _ldap_cfg.field_uid, NULL };
> @@ -1675,7 +1679,7 @@
> if( ldap_err )
> {
> trace(TRACE_ERROR,"auth_validate(): ldap_bind_s failed: %s",
> ldap_err2string( ldap_err ) );
> - id = 0;
> + user_idnr = 0;
> }
> else
> {
> @@ -1715,11 +1719,11 @@
> // struct list templist;
> // struct element *tempelem1, *tempelem2, *tempelem3;
> //
> -// /* do the first entry here */
> +// // do the first entry here
> // tempelem1 = list_getstart( retlist );
> // count1 = retlist->total_nodes;
> //
> -// /* we'll get the next entry at the _end_ of the loop! */
> +// // we'll get the next entry at the _end_ of the loop!
> // printf( "retlist has %d nodes\n", retlist->total_nodes );
> // for( c1 = 0; c1 < count1; c1++ )
> // {
>
--
IC&S
Stadhouderslaan 57
3583 JD Utrecht
telnr. 030-6355730
faxnr. 030-6355731

PGP-key:
http://www.ic-s.nl/keys/ilja.txt
Re: ldap fix [ In reply to ]
I changed u64_t to int64_t because gcc -Wall started warning about:

auth/authldap.c:787:

/* pass through any error from __auth_get_every_match() */
return ( known < 0 ? known : 0 );

if known is unsigned this doesn't make any sense, does it ?

Anyway, I did some googling on u64_t, and only found some references to
old minix docs AND dbmail !!! Is u64_t deprecated? Or else, where is it
defined? And why doesn't dbmail use glib instead ?




Ilja Booij wrote:
> done :)
>
> BTW, why use the int64_t in auth_get_known_users()? Because
> __auth_get_every_match() returns an int? I guess it would be better to
> let that function return an unsigned int. Or am I missing something here?
>
> thanks for fixing those typos!
>
> cheers,
> Ilja
>
> On Dec 3, 2003, at 1:31 PM, Paul J Stevens wrote:
>
>>
>>
>> Hi there,
>>
>> I'm updating the experimental packages for dbmail-2 (sorry for the
>> long delay).
>>
>> I've had to fix some typos in authldap.c
>>
>> Patch attached for your building pleasure. Ilja, can you commit this
>> please ?
>>
>>
>>
>> --
>> ________________________________________________________________
>> Paul Stevens paul@nfg.nl
>> NET FACILITIES GROUP GPG/PGP: 1024D/11F8CD31
>> The Netherlands_______________________________________www.nfg.nl
>> --- dbmail_cvs/auth/authldap.c 2003-12-03 11:03:50.000000000 +0100
>> +++ dbmail/auth/authldap.c 2003-12-03 12:51:17.000000000 +0100
>> @@ -25,6 +25,7 @@
>> #include "config.h"
>> #endif
>>
>> +#include "assert.h"
>> #include "auth.h"
>> #include "dbmail.h"
>> #include "db.h"
>> @@ -40,7 +41,7 @@
>>
>> #define AUTH_QUERY_SIZE 1024
>>
>> -extern char *configFile;
>> +static char *configFile = DEFAULT_CONFIG_FILE;
>>
>> LDAP *_ldap_conn;
>> LDAPMod **_ldap_mod;
>> @@ -88,6 +89,8 @@
>> trace(TRACE_DEBUG, #func ": value for " #val " stored in " #var "
>> as [%s]", var)
>> /* that's correct, no final ; so when the macro is called, it
>> looks "normal" */
>>
>> +static void __auth_get_config(void);
>> +
>> static void __auth_get_config()
>> {
>> struct list ldapItems;
>> @@ -181,6 +184,7 @@
>> * calls. OTOH, if the calls are always far between, we'd
>> * rather just be connected strictly as needed...
>> */
>> +int auth_reconnect(void);
>> int auth_reconnect()
>> {
>> /* Destroy the old... */
>> @@ -628,7 +632,7 @@
>> id_char = __auth_get_first_match( query, fields );
>>
>> *user_idnr = ( id_char ) ? strtoull( id_char, NULL, 0 ) : 0;
>> - trace(TRACE_DEBUG, "auth_user_exists(): returned value is [%llu]",
>> id );
>> + trace(TRACE_DEBUG, "auth_user_exists(): returned value is [%llu]",
>> user_idnr );
>>
>> if( id_char ) free( id_char );
>>
>> @@ -686,7 +690,7 @@
>> cid_char = __auth_get_first_match( query, fields );
>>
>> *client_idnr = ( cid_char ) ? strtoull( cid_char, NULL, 0 ) : 0;
>> - trace(TRACE_DEBUG, "auth_getclientid(): returned value is [%llu]",
>> cid );
>> + trace(TRACE_DEBUG, "auth_getclientid(): returned value is [%llu]",
>> client_idnr );
>>
>> if( cid_char ) free( cid_char );
>>
>> @@ -742,7 +746,7 @@
>> * return -2 on mem error, -1 on db-error, 0 on success */
>> int auth_get_known_users(struct list *users)
>> {
>> - u64_t known;
>> + int64_t known;
>> /* u64_t curr; unused variable */
>> char query[AUTH_QUERY_SIZE];
>> char *fields[] = { _ldap_cfg.field_uid, NULL };
>> @@ -1675,7 +1679,7 @@
>> if( ldap_err )
>> {
>> trace(TRACE_ERROR,"auth_validate(): ldap_bind_s failed: %s",
>> ldap_err2string( ldap_err ) );
>> - id = 0;
>> + user_idnr = 0;
>> }
>> else
>> {
>> @@ -1715,11 +1719,11 @@
>> // struct list templist;
>> // struct element *tempelem1, *tempelem2, *tempelem3;
>> //
>> -// /* do the first entry here */
>> +// // do the first entry here
>> // tempelem1 = list_getstart( retlist );
>> // count1 = retlist->total_nodes;
>> //
>> -// /* we'll get the next entry at the _end_ of the loop! */
>> +// // we'll get the next entry at the _end_ of the loop!
>> // printf( "retlist has %d nodes\n", retlist->total_nodes );
>> // for( c1 = 0; c1 < count1; c1++ )
>> // {
>>
> --
> IC&S
> Stadhouderslaan 57
> 3583 JD Utrecht
> telnr. 030-6355730
> faxnr. 030-6355731
>
> PGP-key:
> http://www.ic-s.nl/keys/ilja.txt
>
> _______________________________________________
> Dbmail-dev mailing list
> Dbmail-dev@dbmail.org
> http://twister.fastxs.net/mailman/listinfo/dbmail-dev
>

--
________________________________________________________________
Paul Stevens paul@nfg.nl
NET FACILITIES GROUP GPG/PGP: 1024D/11F8CD31
The Netherlands_______________________________________www.nfg.nl
Re: ldap fix [ In reply to ]
Hi
On Dec 3, 2003, at 3:49 PM, Paul J Stevens wrote:

> I changed u64_t to int64_t because gcc -Wall started warning about:
>
> auth/authldap.c:787:
>
> /* pass through any error from __auth_get_every_match() */
> return ( known < 0 ? known : 0 );
ok, just skimmed through it and did see that one. Anyway, In quite a
lot of functions in db.c I've changed the return type from u64_t to
int, and used the u64_t variable as a call by reference parameter. That
way, it's much easier to check a function for an error, without
resorting to using comparisons between unsigned values and -1 for
instance.
I guess this is another one of those places that this needs to be fixed.
>
> if known is unsigned this doesn't make any sense, does it ?
>
> Anyway, I did some googling on u64_t, and only found some references
> to old minix docs AND dbmail !!! Is u64_t deprecated? Or else, where
> is it defined? And why doesn't dbmail use glib instead ?
u64_t is defined in dbmailtypes.h as unsigned long long.
This could be a portability problem, I guess.

Using glib would be quite nice of course, not only for the datatypes
(u64_t -> guint64), but also for things like linked lists, which are
very nicely done in glib.

2 problems though:
1. It's a lot of work to port everything to glib. Although I must say
it sounds very good to me.
2. It adds a library dependency. But I guess glib is available for all
platforms we need to support, given the fact that GTK+ also runs on
almost everything.

It could be a long-term goal to port to glib. Certainly not short-term.

Cheers,
Ilja

--
IC&S
Stadhouderslaan 57
3583 JD Utrecht
telnr. 030-6355730
faxnr. 030-6355731

PGP-key:
http://www.ic-s.nl/keys/ilja.txt