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.

