Update Standards-Version
[manu/libnss-mysql-bg.git] / DEBUGGING
1 # $Id: DEBUGGING,v 1.7 2003/06/19 01:37:31 cinergi Exp $
2
3 Debugging libnss-mysql
4 ======================
5     Serious problems will be sent to syslog, so check there first.
6
7     If you're having problems with ProFTPD, check the FAQ.
8     If you've just installed libnss-mysql but it's not working, make
9     sure you've restarted any related daemons (IE ssh or nscd).  It's
10     probably best to reboot the system unless you know all the daemons
11     to restart.  Rebooting (or manually restarting just about everything)
12     will help prevent strange problems.
13
14     libnss-mysql has debug code available if you compile is by adding
15     '--enable-debug' to the 'configure' line.  Then, you have a choice
16     as to where debug information goes.  By default, it will go to the
17     file '/tmp/libnss-mysql-debug.log'. Setting the environment variable
18     'LIBNSS_MYSQL_DEBUG' will change where debug information goes.
19         0 = /tmp/libnss-mysql-debug.log
20         1 = stderr
21         2 = syslog (prio = debug, same facility compiled with (default=auth))
22     Note that setting the environment variable will ONLY affect commands
23     spawned from the same process the variable was set in.
24     DO NOT LEAVE DEBUG SUPPORT COMPILED IN WHEN YOU'RE DONE - it's 3 
25     times slower and is a security hazard.  Make sure to remove the debug
26     logfile when you're done, too.
27
28     You can also trace your programs with 'strace' (Linux) or 'truss'
29     (Solaris).  This is especially useful if you get *no* debugging
30     information (IE because the library isn't loading).
31
32     Before we go down that road:
33       - Make sure you've added 'mysql' to /etc/nsswitch.conf.
34       - Note that daemons, including nscd, may not see changes to
35         nsswitch.conf unless they're restarted.
36       - Shut off nscd until you get things working (/etc/init.d/nscd stop).
37
38     Trace a simple request like 'id username'.  Here are command lines
39     that will trace the heck out of everything.  They will take some
40     time to complete.  The results will be in the file 'trace.out'
41     Linux:
42         strace -e read=all -e write=all -x -o trace.out id cinergi
43     Solaris:
44         truss -u '*' -u '\!libc' -wall -rall -vall -o trace.out id cinergi
45
46     You'll want to verify that the library gets loaded, so search for
47     'nss_mysql' and make sure you see that the system attempts to open it:
48   ****************************************************************************
49         open("/usr/lib/nss_mysql.so.1", O_RDONLY)       = 3
50   ****************************************************************************
51     Soon after that line you should see further attempts to open other
52     libraries such as libmysqlclient (if you're using a shared MySQL library).
53     Make SURE the return code is NOT -1 (it is '3' in the example line above) -
54     otherwise the system isn't finding the libraries it needs.  After
55     the libraries are opened, you should see the libnss-mysql.cfg file get
56     opened and whatnot.  If you get this far, we know that the library is
57     properly installed.
58     You can also check to see what the actual MySQL queries are like.
59     Search for 'S E L' or 'SEL' in the output.  Depending on your OS, you'll
60     see something like:
61   ****************************************************************************
62   write(3, 0x00025220, 88)                        = 88
63   T\0\0\003 S E L E C T   u s e r n a m e , ' x ' , u i d , g i d
64   , g e c o s , h o m e d i r , s h e l l   F R O M   u s e r s
65   W H E R E   u i d = ' 5 0 0 0 '   L I M I T   1
66   ****************************************************************************
67     or:
68   ****************************************************************************
69   write(3, "T\0\0\0\3SELECT username,\'x\',uid,gid"..., 88) = 88
70   | 00000  54 00 00 00 03 53 45 4c  45 43 54 20 75 73 65 72  T....SEL ECT user |
71   | 00010  6e 61 6d 65 2c 27 78 27  2c 75 69 64 2c 67 69 64  name,'x' ,uid,gid |
72   | 00020  2c 67 65 63 6f 73 2c 68  6f 6d 65 64 69 72 2c 73  ,gecos,h omedir,s |
73   | 00030  68 65 6c 6c 20 46 52 4f  4d 20 75 73 65 72 73 20  hell FRO M users  |
74   | 00040  57 48 45 52 45 20 75 69  64 3d 27 35 30 30 30 27  WHERE ui d='5000' |
75   | 00050  20 4c 49 4d 49 54 20 31                            LIMIT 1          |
76   ****************************************************************************
77
78     Reading a little past that point, you should be able to see the response
79     to your query.
80
81     You can, of couse, use a debugger like gdb or adb, but I won't get
82     into that here - it can get pretty complex.  Feel free to ask for help
83     if you're having problems.  I try to help anyone who asks.
84