Discussion:
[Refdb-devel] refdbd maintenance mode fails
David Nebauer
2006-10-12 11:58:44 UTC
Permalink
After upgrading to svn revision 193 I now get an error when running the
command

refdbd -a -D "sqlite" -i "/var/lib/refdb/db"

as part of the debian package install. It announces the error

'(null)' cannot be resolved as a hostname

and exits with a non-zero return value.

Regards,
David.
Markus Hoenicka
2006-10-12 12:24:23 UTC
Permalink
Post by David Nebauer
After upgrading to svn revision 193 I now get an error when running the
command
refdbd -a -D "sqlite" -i "/var/lib/refdb/db"
as part of the debian package install. It announces the error
'(null)' cannot be resolved as a hostname
and exits with a non-zero return value.
That's not good. However, I can't reproduce the problem on my Windows/Cygwin box
at work (using sqlite3 as I don't have sqlite 2.x installed). On your box refdbd
claims that ip_or_path is NULL, although it is an initialized stack variable. It
would take a pretty gross memory error to achieve this, but valgrind tells me
there is nothing wrong.

I'm afraid you'd have to look at refdbd with a debugger in order to see what's
wrong. Are you familiar with gdb? I'd set a breakpoint after the getopt loop
and check the values every couple of lines to see where the values get lost. If
this is above your head, I'll run these tests on the weekend on a Debian box,
provided I can reproduce the problem.

regards,
Markus
--
Markus Hoenicka
***@cats.de
(Spam-protected email: replace the quadrupeds with "mhoenicka")
http://www.mhoenicka.de
David Nebauer
2006-10-12 12:13:46 UTC
Permalink
Post by David Nebauer
After upgrading to svn revision 193 I now get an error when running
the command
refdbd -a -D "sqlite" -i "/var/lib/refdb/db"
as part of the debian package install. It announces the error
'(null)' cannot be resolved as a hostname
and exits with a non-zero return value.
This is a quoting problem. The postinstall script is assembling the
following command:

cmd="refdbd -a -D \"sqlite\" -i \"/var/lib/refdb/db\""

and executing it with a simple

${cmd}

This reproducibly causes the error message reported earlier.

As a matter of fact, this error is caused by the quoting of the database
backend:

----------------------------------------------------------------------------------
# cmd="refdbd -a -D \"sqlite\" -i /var/lib/refdb/db"
# ${cmd}
'(null)' cannot be resolved as a hostname
#
----------------------------------------------------------------------------------

Quoting the main database directory causes a different error:

----------------------------------------------------------------------------------
# cmd="refdbd -a -D sqlite -i \"/var/lib/refdb/db\""
# ${cmd}
maintenance of main database failed
#
----------------------------------------------------------------------------------

Use of single quotes for the internal quoting

cmd="refdbd -a -D 'sqlite' -i '/var/lib/refdb/db'"

produces the same error.

Removing the internal quotes entirely

cmd="refdbd -a -D sqlite -i /var/lib/refdb/db"

solves the problem and the command executes without a problem.

At a minimum I must be able to quote the main database directory since
the user may have placed it in a directory path containing spaces.

Regards,
David.
Markus Hoenicka
2006-10-12 12:48:40 UTC
Permalink
Post by David Nebauer
This is a quoting problem.
A weird one at that.

The postinstall script is assembling the
Post by David Nebauer
cmd="refdbd -a -D \"sqlite\" -i \"/var/lib/refdb/db\""
and executing it with a simple
${cmd}
This seems to be the culprit. I ran the following tests in my bash:

$ refdbd -a -D sqlite -e 0 -l 7 -i 'usr/local/var/lib/refdb/db'
[...]
connected to database server using database:
refdb
current main database version: 2

So the command you're trying to run works perfectly fine. But when I try to do
it like your script:

$ cmd="refdbd -a -D sqlite -e 0 -l 7 -i 'usr/local/var/lib/refdb/db'"

$ echo $cmd
refdbd -a -D sqlite -e 0 -l 7 -i 'usr/local/var/lib/refdb/db'

$ ${cmd}
Database directory:
'usr/local/var/lib/refdb/db'
check main database version
pc51997
Administrator


3306
sqlite
'usr/local/var/lib/refdb/db'
UTF8
refdb
failed to connect to database server using database:
refdb
libdbi could not establish a connection
could not open main database
Can't access or create SQLite database
maintenance of main database failed

That is, running the command as ${cmd} does not consume the quotes as when you
run the very same command in the shell. refdbd receives the quoted arguments
which are no longer properly recognized.

One workaround is to run the command like this:

echo $cmd|sh

although more elegant ways may exist.

regards,
Markus
--
Markus Hoenicka
***@cats.de
(Spam-protected email: replace the quadrupeds with "mhoenicka")
http://www.mhoenicka.de
Loading...