I'm trying to use lbdb for Debian work, but I found some of my
queries are not returning results.
- eval ${method}_query \""$@"\" >> "$collection" || true
+ ${method}_query "$@" >> "$collection" || true
Instead I submit to you the idea to just-not-use-eval-at-all-ever-as-it's-rarely-really-actually-needed^TM:
This seems to fix my problem at least, but I'm not sure passing the
$@ args individually is the behaviour you intended?
$ lbdbq Roland Rosenfeld
lbdbq: no matches
(surprisingly, with other backends this works as expected and finds
some "Roland Rosenfeld" matches, seems that I have to re-check the
ldap backend. BTW: with m_gpg I have 4 matches)
$ lbdbq "Roland Rosenfeld"
also gives no matches (m_gpg also gives 4 matches).
Hmmm, from my point of view there is a bug in m_ldap, which should
be possible to find at least one "Roland Rosenfeld" (maybe by
internally fetching all "roland" and then grep for "Roland
Rosenfeld" in the result).
On Thu, 10 Apr 2025, Daniel Gröber wrote:
I'm trying to use lbdb for Debian work, but I found some of my
queries are not returning results.
Could you please be more concrete in what you executed and what your
results are?
To become more reproducible with your setup, I copied your ldap.rc
enabled METHODS="m_ldap" and LDAP_NICKS="debian" (m_gpg heavily
depends on the installed pubring).
Hmmm, from my point of view there is a bug in m_ldap, which should be possible to find at least one "Roland Rosenfeld" (maybe by internally fetching all "roland" and then grep for "Roland Rosenfeld" in the
result).
On the other hand I don't think that the behavior gets better with
your patch, since searching for Roland Rosenfeld (without quotes)
returns 8 Rolands, 7 of them without "Rosenfeld".
Searching with quotes has the same bug as my version.
Instead I submit to you the idea to just-not-use-eval-at-all-ever-as-it's-rarely-really-actually-needed^TM:
To say the truth, I never reviewed this eval before. This was in the original lbdb package by Thomas Roessler and I always kept it without reviewing this. As you mentioned, the behavior was last changed 25
years ago...
I'll have to check whether changing this will fix or break something, especially with different implementations of /bin/sh (I use dash
myself, but tested your change with bash and dash without noting a
behavior change).
This seems to fix my problem at least, but I'm not sure passing the
$@ args individually is the behaviour you intended?
If I enter
To: Roland Rosenfeld
in mutt and press Ctrl-T, I expect that only "Roland Rosenfeld" is
found in the results.
For this
$ lbdbq Roland Rosenfeld
should work (otherwise it may be necessary to add some quotes around
%s in muttrc
set query_command="lbdbq %s"
In the meantime I digged a little deeper and found the root cause for
this problem: The Debian LDAP (db.debian.org) uses the attribute cn
in an unusual way:
cn: Roland
uid: roland
sn: Rosenfeld
gecos: Roland Rosenfeld,,,,
The usual way is to have the first name (Roland) in the givenName
attribute and use the cn (CommonName) attribute for the complete name
(Roland Rosenfeld). But this one is only available in the gecos field
here (with the commas (unused subfields) as a suffix).
So if I want to search in db.debian.org for "Roland Rosenfeld", I have
to search in the gecos field using wildcards (which can be enabled in mutt_ldap_query/m_ldap with $ignorant=1).
This can be archived with the following ldap.rc:
%ldap_server_db = (
'debian' => [
'ldaps://db.debian.org',
'ou=users,dc=debian,dc=org',
'uid cn sn ircnick gecos',
'uid cn sn ircnick',
'${uid}@debian.org',
'${cn} ${sn}', '${ircnick}',
1, # wildcard search for matching gecos
],
);
After some more testing I found out, that mutt_ldap_query by default
does an "or" join, if called with two parameters. This also seems to
be the behavior you intended with your patch, which works at
least with m_ldap:
$ lbdbq-test Gröber Rosenfeld
lbdbq: 2 matches
dxld@debian.org Daniel Gröber dxld
roland@debian.org Roland Rosenfeld RoRo
The problem here is, that most other modules (like m_inmail or m_gpg)
do not expect multiple parameters this way and fail with your changed
lbdbq.
Maybe I should extend the documentation to more explicitly mention
that lbdbq always takes all parameters as a long (virtually quoted)
string and searches for this string in this order (instead of
searching for multiple space separated strings as "or"-connected).
Alternatively I could modify all modules to join multiple space
separated parameters with "or" (except manually quoted in the query
string), but this would change the default behavior for most current
users which doesn't sound like a very good idea to me...
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 480 |
Nodes: | 16 (2 / 14) |
Uptime: | 255:53:41 |
Calls: | 9,532 |
Files: | 13,651 |
Messages: | 6,138,230 |