# cat /etc/pam.d/testing
#%PAM-1.0
auth required pam_debug.so auth=success cred=success acct=success
account required pam_debug.so auth=success cred=success acct=success
password requisite pam_debug.so auth=success cred=success acct=success
session required pam_debug.so auth=success cred=success acct=success
import net.sf.jpam.*;
class TestClass {
String fslkjfsdl = "dsafdsf";
}
class Test {
public static void main(String[] args) {
String user1Name = "testing";
String user1Credentials = "xxxx";
Pam pam = new Pam("testing");
boolean authenticated = pam.authenticateSuccessful(user1Name, user1Credentials);
System.out.println(authenticated);
for (int i = 0; i < 100000; i++) {
TestClass tc = new TestClass();
System.sleep(1);
System.gc();
}
}
}
Run several times:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x007abdd0, pid=7771, tid=3086408592
#
# JRE version: 6.0-b16
# Java VM: OpenJDK Client VM (14.0-b16 mixed mode linux-x86 )
# Distribution: Custom build (Tue Aug 10 15:43:15 EDT 2010)
# Problematic frame:
# C [libc.so.6+0x69dd0]
#
# An error report file with more information is saved as:
# /home/dev/temp/jpam_test/hs_err_pid7771.log
#
# If you would like to submit a bug report, please include
# instructions how to reproduce the bug and visit:
# http://icedtea.classpath.org/bugzilla
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
There is some memory leak that causes the test program crash after some time in native code.
This is much better example:
import net.sf.jpam.*;
class Test {
public static void main(String[] args) {
String user1Name = "testing";
String user1Credentials = "redhat";
Pam pam = new Pam("rhn-satellite");
for (int i = 0; i < 100; i++) {
pam.authenticateSuccessful(user1Name, user1Credentials);
}
}
}
Stack: [0xb7f10000,0xb7f61000], sp=0xb7f5fc34, free space=319k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [libc.so.6+0x69dd0]
C [libc.so.6+0x6be97] __libc_malloc+0x67
C [libc.so.6+0x60033] vasprintf+0x23
C [libpam.so.0+0x6245] pam_vprompt+0xa5
C [libpam.so.0+0x63bc] pam_prompt+0x3c
C [pam_debug.so+0x7ac]
C [libpam.so.0+0x243f] _pam_dispatch+0x28f
C [libpam.so.0+0x1b43] pam_acct_mgmt+0x43
C [libjpam.so+0xeda] Java_net_sf_jpam_Pam_authenticate+0x1e2
j net.sf.jpam.Pam.authenticate(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)I+0
j net.sf.jpam.Pam.authenticate(Ljava/lang/String;Ljava/lang/String;)Lnet/sf/jpam/PamReturnValue;+97
j net.sf.jpam.Pam.authenticateSuccessful(Ljava/lang/String;Ljava/lang/String;)Z+7
j Test.main([Ljava/lang/String;)V+29
v ~StubRoutines::call_stub
V [libjvm.so+0x1f40cc]
V [libjvm.so+0x2f6e69]
V [libjvm.so+0x1f305f]
V [libjvm.so+0x1fce25]
V [libjvm.so+0x214740]
C [java+0x2dbb] JavaMain+0xdcb
C [libpthread.so.0+0x5832]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j net.sf.jpam.Pam.authenticate(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)I+0
j net.sf.jpam.Pam.authenticate(Ljava/lang/String;Ljava/lang/String;)Lnet/sf/jpam/PamReturnValue;+97
j net.sf.jpam.Pam.authenticateSuccessful(Ljava/lang/String;Ljava/lang/String;)Z+7
j Test.main([Ljava/lang/String;)V+29
v ~StubRoutines::call_stub
I will attach the whole log.
error log
Last comment: I am testing latest 1.1.
On 0.4 this error is not reproducible. It was probably introduced with
pam_set_item(pamh, PAM_AUTHTOK, password);
line but I am not sure as I am not skilled C dev... :-)