Service crashes when trying to authenticate through pam_krb5

I have this weird problem wherein a user on a remote host runs a command

on my server, and my daemon tries to authenticate the user through pam using pam_krb5. The command runs for a while, and then the daemon crashes.

The authentication works fine when I use, say, pam_unix_auth, but if I specify pam_krb5, it crashes with a core dump.

Following is a (partial) backtrace of the core obtained:

#0 0xfeabd7fc in _lwp_kill () from /lib/libc.so.1

#1 0xfea5da1c in raise () from /lib/libc.so.1

#2 0xfea3de60 in abort () from /lib/libc.so.1

#3 0xff384990 in ut_want_no_core () from /opt/NTAPdfm/lib//libdbtasks9_r.so.1

#4 0xfeabc744 in __sighndlr () from /lib/libc.so.1

#5 0xfeab1bb0 in call_user_handler () from /lib/libc.so.1

#6 0xfd1d5fdc in krb5_mcc_destroy () from /usr/lib/gss/mech_krb5.so.1

#7 0xfd1d607c in krb5_mcc_destroy () from /usr/lib/gss/mech_krb5.so.1

#8 0xfd1e9c0c in krb5_verify_init_creds () from /usr/lib/gss/mech_krb5.so.1

#9 0xfd2b2ed4 in attempt_krb5_auth () from /usr/lib/security/pam_krb5.so.1

#10 0xfd2b26dc in pam_sm_authenticate () from /usr/lib/security/pam_krb5.so.1

#11 0xff182c08 in run_stack () from /lib/libpam.so.1

#12 0xff182eac in pam_authenticate () from /lib/libpam.so.1

#13 0x00365db4 in auth_chkpw_pam (username=0x5d5aac "*****", password=0x5d5ac4 "*****", error=0xfc2fb948) at auth.c:205

#14 0x00365f94 in auth_chkpw (username=0x5d5aac "*****", password=0x5d5ac4 "*****", error=0xfc2fb948, use_pam=1) at auth.c:276

The code is something like this:

1. pam_start

2. if error then leave

3. pam_authenticate

4. if user_unknown or PAM_ABORT or PAM_MAXTRIES then leave.

5. pam_acct_mgmt

6. while error is PAM_AUTHTOK_ERR, try pam_authtok, else leave

7. pam_setcred

8. leave.

Obviously, at all the places where I "leave", i call pam_end first.

Anybody have any ideas on what I'm doing wrong?

Thanks in advance.

[2028 byte] By [Hariharan_Iyer] at [2007-11-26 10:37:14]
# 1
I forgot to mention this - the daemon is a multi-threaded process, and the crashes seem to occur only when more than one remote process is making requests.
Hariharan_Iyer at 2007-7-7 2:48:12 > top of Java-index,General,Talk to the Sysop...
# 2

Here's a clearer backtrace:

#0 0xfeabd7fc in _lwp_kill () from /lib/libc.so.1

#1 0xfea5da1c in raise () from /lib/libc.so.1

#2 0xfea3de60 in abort () from /lib/libc.so.1

#3 0xff384990 in ut_want_no_core () from /opt/NTAPdfm/lib//libdbtasks9_r.so.1

#4 0xfeabc744 in __sighndlr () from /lib/libc.so.1

#5 0xfeab1bb0 in call_user_handler () from /lib/libc.so.1

#6 0xfeaebaa4 in flist () from /lib/libc.so.1

#7 0xfd66b23c in krb5_free_cred_contents () from /usr/lib/gss/mech_krb5.so.1

#8 0xfd66b3d0 in krb5_free_creds () from /usr/lib/gss/mech_krb5.so.1

#9 0xfd655fa4 in krb5_mcc_free () from /usr/lib/gss/mech_krb5.so.1

#10 0xfd65607c in krb5_mcc_destroy () from /usr/lib/gss/mech_krb5.so.1

#11 0xfd669c0c in krb5_verify_init_creds () from /usr/lib/gss/mech_krb5.so.1

#12 0xfd732ed4 in attempt_krb5_auth () from /usr/lib/security/pam_krb5.so.1

#13 0xfd7326dc in pam_sm_authenticate () from /usr/lib/security/pam_krb5.so.1

#14 0xff182c08 in run_stack () from /lib/libpam.so.1

#15 0xff182eac in pam_authenticate () from /lib/libpam.so.1

#16 0x00365db4 in auth_chkpw_pam (username=0x598bfc "*****", password=0x58ebec "*****", error=0xfbe7b948) at auth.c:205

#17 0x00365ffc in auth_chkpw (username=0x598bfc "*****", password=0x58ebec "*****", error=0xfbe7b948, use_pam=1) at auth.c:285

I'm unclear as to whether this is a problem in my code or in the pam_krb5 library. My inclination is to the former, but I am at a loss :-( .

Hariharan_Iyer at 2007-7-7 2:48:12 > top of Java-index,General,Talk to the Sysop...