Unable to break into a PAM module

Full Name nuncestbibendum@excite.com
Thu Jan 16 21:57:00 GMT 2020


   I am developing a PAM module to be used by the OpenSSH daemon in CentOS 7.  I would like to be able to get gdb to break into my module - but I I have yet to succeed.  This is how I am launching gdb:

# gdb <sshd-path>/sshd
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-115.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from <sshd-path>/sshd...done.
(gdb) b pam_sm_authenticate
Function "pam_sm_authenticate" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y

Breakpoint 1 (pam_sm_authenticate) pending.

(gdb) run -d -D -p 324

The breakpoints that the b pam_sm_authenticate command sets are the following:

 (gdb) i br
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   <MULTIPLE>         
	breakpoint already hit 3 times
1.1                         y     0x00007ffff179ce50 in pam_sm_authenticate 
                                                   at pam_lastlog.c:572
1.2                         y     0x00007ffff39cd080 in pam_sm_authenticate 
                                                   at pam_selinux.c:766
1.3                         y     0x00007ffff41e4840 in pam_sm_authenticate 
                                                   at pam_permit.c:36
1.4                         y     0x00007ffff43e6a20 in pam_sm_authenticate 
                                                   at pam_localuser.c:61
1.5                         y     0x00007ffff45e9d00 in pam_sm_authenticate 
                                                   at pam_nologin.c:141
1.6                         y     0x00007ffff47ec700 in pam_sm_authenticate 
                                                   at pam_deny.c:33
1.7                         y     0x00007ffff49ef860 in pam_sm_authenticate 
                                                   at pam_succeed_if.c:406
1.8                         y     0x00007ffff4e0f390 in pam_sm_authenticate 
                                                   at pam_unix_auth.c:106
1.9                         y     0x00007ffff5026b70 in pam_sm_authenticate 
                                                   at pam_faildelay.c:158
1.10                      y     0x00007ffff522b2c0 in pam_sm_authenticate 
                                                   at pam_env.c:763
1.11                      y     0x00007ffff56342d7 in pam_sm_authenticate 
                                                   at src/pam_my_module.c:1087
1.12                      y     0x00007ffff5ee6760 in pam_sm_authenticate 
                                                   at pam_sepermit.c:369

The breakpoint I am interested in is 1.11. 

When I run gdb and make an SSH connection, out of all the breakpoints above gdb only breaks at 1.7.  However, I know for a fact that pam_sm_authenticate() in src/pam_my_module.c is being executed,  for it has debugging statements unique to this function that send output to syslog, and when I run the code I do indeed see such output in syslog. Even setting a breakpoint explicitly at the relevant file and line does not make gdb to break there. gdb should break at 1.11, but it is not.

Any thoughts on what is going on here? Other relevant information:

#  gdb -v
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-115.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.

# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 

My PAM module is built as follows:

cc -g -Wall -fPIC -D_GNU_SOURCE -c src/pam_rmy_module.c -o pam_my_module.o
cc -shared pam_my_module.o -lpam -o pam_my_module.so



More information about the Gdb mailing list