Bug 9638 - smbtad won't initialize sqlite db
Summary: smbtad won't initialize sqlite db
Status: RESOLVED FIXED
Alias: None
Product: smbta
Classification: Unclassified
Component: smbtad (show other bugs)
Version: unspecified
Hardware: x64 Linux
: P5 normal
Target Milestone: ---
Assignee: Holger Hetterich
QA Contact:
URL:
Keywords:
Depends on:
Blocks: 9538
  Show dependency treegraph
 
Reported: 2013-02-06 14:24 UTC by jeff
Modified: 2013-02-08 10:31 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jeff 2013-02-06 14:24:57 UTC
Good day, I'm having problem with smbtad to initialize sqlite db. Below is the actual steps I have taken to compile and run smbtad. TIA.

**System info:
[root@localhost dev]# uname -a
Linux localhost 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost dev]# cat /etc/redhat-release 
CentOS release 6.3 (Final)
[root@localhost dev]# rpm -qa | grep libdbi 
libdbi-devel-0.8.3-3.1.el6.x86_64
libdbi-0.8.3-3.1.el6.x86_64
[root@localhost dev]# rpm -qa | grep sqlite
sqlite-3.6.20-1.el6.x86_64
qt-sqlite-4.6.2-24.el6.x86_64
[root@localhost dev]# rpm -qa | grep ncurses
ncurses-libs-5.7-3.20090208.el6.x86_64
ncurses-5.7-3.20090208.el6.x86_64
ncurses-devel-5.7-3.20090208.el6.x86_64
ncurses-base-5.7-3.20090208.el6.x86_64
[root@localhost dev]# rpm -qa | grep cmake
cmake-2.6.4-5.el6.x86_64
[root@localhost dev]# rpm -qa | grep libsmbclient
libsmbclient-devel-3.5.10-125.el6.x86_64
libsmbclient-3.5.10-125.el6.x86_64

**Getting source from git: referring to https://bugzilla.samba.org/show_bug.cgi?id=8288#c19

[root@localhost dev]# git clone git://github.com/hhetter/smbtad.git
Initialized empty Git repository in /root/dev/smbtad/.git/
remote: Counting objects: 2243, done.
remote: Compressing objects: 100% (764/764), done.
remote: Total 2243 (delta 1700), reused 2015 (delta 1472)
Receiving objects: 100% (2243/2243), 1.52 MiB | 82 KiB/s, done.
Resolving deltas: 100% (1700/1700), done.
[root@localhost dev]# cd smbtad
[root@localhost smbtad]# git branch test --track origin/devel
Branch test set up to track remote branch devel from origin.
[root@localhost smbtad]# git checkout devel
Branch devel set up to track remote branch devel from origin.
Switched to a new branch 'devel'
[root@localhost smbtad]# mkdir build
[root@localhost smbtad]# cd build/
[root@localhost build]# cmake --debug-output ../
Running with debug output on.
-- The C compiler identification is GNU
   Called from: [2]	/usr/share/cmake/Modules/CMakeDetermineCCompiler.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
-- Check for working C compiler: /usr/bin/gcc
   Called from: [2]	/usr/share/cmake/Modules/CMakeTestCCompiler.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
-- Check for working C compiler: /usr/bin/gcc -- works
   Called from: [2]	/usr/share/cmake/Modules/CMakeTestCCompiler.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
-- Detecting C compiler ABI info
   Called from: [2]	/usr/share/cmake/Modules/CMakeTestCCompiler.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
-- Detecting C compiler ABI info - done
   Called from: [2]	/usr/share/cmake/Modules/CMakeTestCCompiler.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
-- checking for modules 'QUIET;libdbi'
   Called from: [2]	/root/dev/smbtad/FindLibDBI.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
--   package 'QUIET' not found
   Called from: [2]	/root/dev/smbtad/FindLibDBI.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
--   package 'libdbi' not found
   Called from: [2]	/root/dev/smbtad/FindLibDBI.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
-- Found LibDbi: /usr/lib64/libdbi.so
   Called from: [2]	/root/dev/smbtad/FindLibDBI.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
-- checking for modules 'QUIET;libdbi'
   Called from: [2]	/root/dev/smbtad/FindLibDBI.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
--   package 'QUIET' not found
   Called from: [2]	/root/dev/smbtad/FindLibDBI.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
--   package 'libdbi' not found
   Called from: [2]	/root/dev/smbtad/FindLibDBI.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
-- Found Talloc: /usr/lib64/libtalloc.so
   Called from: [2]	/root/dev/smbtad/FindTalloc.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
-- Found Talloc: /usr/lib64/libtalloc.so;/usr/lib64/libtalloc.so
   Called from: [2]	/root/dev/smbtad/FindTalloc.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
-- Looking for include files CMAKE_HAVE_PTHREAD_H
   Called from: [2]	/usr/share/cmake/Modules/FindThreads.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
-- Looking for include files CMAKE_HAVE_PTHREAD_H - found
   Called from: [2]	/usr/share/cmake/Modules/FindThreads.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
-- Looking for pthread_create in pthreads
   Called from: [2]	/usr/share/cmake/Modules/FindThreads.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
-- Looking for pthread_create in pthreads - not found
   Called from: [2]	/usr/share/cmake/Modules/FindThreads.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
-- Looking for pthread_create in pthread
   Called from: [2]	/usr/share/cmake/Modules/FindThreads.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
-- Looking for pthread_create in pthread - found
   Called from: [2]	/usr/share/cmake/Modules/FindThreads.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
-- Found Threads: TRUE
   Called from: [2]	/usr/share/cmake/Modules/FindThreads.cmake
                [1]	/root/dev/smbtad/CMakeLists.txt
-- ----> FYI: Unable to find iniparser libraries on your system
   Called from: [1]	/root/dev/smbtad/CMakeLists.txt
-- ---->      compiling my own version and link it statically.
   Called from: [1]	/root/dev/smbtad/CMakeLists.txt
-- Configuring done
-- Generating /root/dev/smbtad/build
-- Generating done
-- Build files have been written to: /root/dev/smbtad/build

** my system current CMAKE doesn't seem to recognize QUIET keyword, but still it manage to find required libs.

[root@localhost build]# make
Scanning dependencies of target buildiniparser
[  0%] Building iniparser.
compiling src/iniparser.c ...
compiling src/dictionary.c ...
a - src/iniparser.o
a - src/dictionary.o
[  7%] Built target buildiniparser
Scanning dependencies of target smbtad
[ 14%] Building C object CMakeFiles/smbtad.dir/src/main.c.o
[ 21%] Building C object CMakeFiles/smbtad.dir/src/configuration.c.o
[ 28%] Building C object CMakeFiles/smbtad.dir/src/help.c.o
[ 35%] Building C object CMakeFiles/smbtad.dir/src/daemon.c.o
[ 42%] Building C object CMakeFiles/smbtad.dir/src/connection_list.c.o
[ 50%] Building C object CMakeFiles/smbtad.dir/src/network.c.o
[ 57%] Building C object CMakeFiles/smbtad.dir/src/protocol.c.o
[ 64%] Building C object CMakeFiles/smbtad.dir/src/cache.c.o
[ 71%] Building C object CMakeFiles/smbtad.dir/src/query_list.c.o
[ 78%] Building C object CMakeFiles/smbtad.dir/src/database.c.o
[ 85%] Building C object CMakeFiles/smbtad.dir/src/crypto/aes.c.o
[ 92%] Building C object CMakeFiles/smbtad.dir/src/crypto/rijndael-alg-fst.c.o
[100%] Building C object CMakeFiles/smbtad.dir/src/monitor-list.c.o
Linking C executable smbtad
[100%] Built target smbtad

** checking sqlite db and config file


[root@localhost build]# ls -alh /var/smbtadb/smbdb.sqlite
-rw-r--r--. 1 root root 0 Feb  6 19:54 /var/smbtadb/smbdb.sqlite
[root@localhost build]# cat ~/smbtad.conf 
[general]
        debug_level = 10
        use_db = 1
[network]
        query_port = 3491
        unix_domain_socket = no
        unix_domain_socket_clients = no
[database]
        driver = sqlite3
        name = smbdb.sqlite
        sqlite_dbdir = /var/smbtadb/
[maintenance]
        interval = 01:00:00
        config = 01,00:00:00

** initializing tables...

[root@localhost build]# date
Wed Feb  6 20:14:53 PHT 2013
[root@localhost build]# ./smbtad -T -c ~/smbtad.conf
DBI: ERROR dbi_initialize. Exiting.
Error connecting to the database.
please check syslog.
[root@localhost build]# tail -n 5 /var/log/messages
Feb  6 19:52:48 localhost smbd[18664]:   failed to retrieve printer list: NT_STATUS_UNSUCCESSFUL
Feb  6 20:05:48 localhost smbd[22171]: [2013/02/06 20:05:48.897099,  0] printing/print_cups.c:109(cups_connect)
Feb  6 20:05:48 localhost smbd[22171]:   Unable to connect to CUPS server localhost:631 - Connection refused
Feb  6 20:05:48 localhost smbd[18664]: [2013/02/06 20:05:48.897352,  0] printing/print_cups.c:468(cups_async_callback)
Feb  6 20:05:48 localhost smbd[18664]:   failed to retrieve printer list: NT_STATUS_UNSUCCESSFUL
[root@localhost build]# date
Wed Feb  6 20:15:01 PHT 2013

** above: smbtad failed to init db and no syslog generated.

[root@localhost build]# ldd smbtad 
	linux-vdso.so.1 =>  (0x00007fff89cab000)
	libdbi.so.0 => /usr/lib64/libdbi.so.0 (0x00007fc517dfa000)
	libtalloc.so.2 => /usr/lib64/libtalloc.so.2 (0x00007fc517bf0000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc5179d2000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007fc5177ce000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fc51743b000)
	libm.so.6 => /lib64/libm.so.6 (0x00007fc5171b6000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fc518014000)
Comment 1 Holger Hetterich 2013-02-06 15:02:59 UTC
It fails in the initialization of libdbi in this code segment, in database.c, in 

int database_connect( struct configuration_data *conf )

>>>
        rc = dbi_initialize(NULL);
        if ( rc == -1 ) {
                printf("DBI: ERROR dbi_initialize. Exiting.\n");
                return 1;
        }
<<<

This is before it does anything else with the database. I am going to reproduce a setup step to make sure there's no libdbi stack problem.
Comment 2 Holger Hetterich 2013-02-07 09:29:28 UTC
have not yet had the time to reproduce this, please stay tuned..

This will block the release tracker bug.
Comment 3 Holger Hetterich 2013-02-07 11:48:03 UTC
holger@d163:~/Dev/smbtad/run> ./smbtad -T -c ./config 

Succesfully created database tables.
holger@d163:~/Dev/smbtad/run> 


Works for me. My config is the same as yours, apart from the sqlite_dbdir:


holger@d163:~/Dev/smbtad/run> cat config
[general]
        debug_level = 10
        use_db = 1
[network]
        query_port = 3491
        unix_domain_socket = no
        unix_domain_socket_clients = no
[database]
        driver = sqlite3
        name = smbdb.sqlite
        sqlite_dbdir = /home/holger/Dev/smbtad/run/
[maintenance]
        interval = 01:00:00
        config = 01,00:00:00

holger@d163:~/Dev/smbtad/run>
Comment 4 Holger Hetterich 2013-02-07 11:53:48 UTC
int dbi_initialize(const char *driverdir);

Locates all available database drivers and loads them into memory.

Arguments

    driverdir: The directory to search for drivers. If NULL, DBI_DRIVER_DIR (defined at compile time) will be used instead.
Returns

    The number of drivers successfully loaded, or -1 if there was an error.



Sure the sqlite dbi driver is correctly installed?

Not sure how fragmented libdbi is on redhat RPM wise. openSUSE does provide subpackages for the libdbi drivers, including one for sqlite.


Your grep for libdbi gives:
[root@localhost dev]# rpm -qa | grep libdbi 
libdbi-devel-0.8.3-3.1.el6.x86_64
libdbi-0.8.3-3.1.el6.x86_64
Comment 5 jeff 2013-02-08 10:31:05 UTC
Good day sir, yes it seems your right I was missing dbi-sqlite library, they were indeed on a separate package. I just did "yum install libdbi-dbd-sqlite.x86_64" and compiled again from dev source and it initialize the sqlite db. Thank you for help.