[linux-pam] #45: Premature thread wake up on successful pam_authenticate call
by fedora-badges
#45: Premature thread wake up on successful pam_authenticate call
---------------------+------------------------------
Reporter: igleyy | Owner: pam-developers@…
Type: defect | Status: new
Priority: major | Component: library
Version: | Keywords:
Blocked By: | Blocking:
---------------------+------------------------------
For given example code, thread which should sleep for given period of time
is prematurely woken up upon successful pam_authenticate call.
Environment:[[BR]]
Linux Mint 16[[BR]]
libpamc.so.0.82.1[[BR]]
libpam_misc.so.0.82.0[[BR]]
libpam.so.0.83.0[[BR]]
g++ (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1[[BR]]
Code:
{{{
#include <security/pam_appl.h>
#include <security/pam_misc.h>
#include <pthread.h>
#include <iostream>
static struct pam_conv conv = {
misc_conv,
NULL
};
void* thread_func(void* foo) {
int i = 0;
std::cout << "Start thread func stuff " << i++ << std::endl;
while (1) {
std::cout << "Thread func stuff " << i++ << std::endl;
sleep(1000000);
}
}
int main ()
{
pthread_t th;
int th_ret;
th_ret = pthread_create( &th, NULL, thread_func, (void*) NULL);
if (th_ret) {
std::cout << "pthread_create failed: " << th_ret << std::endl;
exit(1);
}
pam_handle_t* pamh;
struct pam_conv pamc;
/* Set up the PAM conversation. */
pamc.conv = &misc_conv;
pamc.appdata_ptr = NULL;
/* Start a new authentication session. */
pam_start ("passwd", "myusername", &pamc, &pamh);
/* Authenticate the user. */
if (pam_authenticate (pamh, 0) != PAM_SUCCESS)
std::cout << "Authentication failed!" << std::endl;
else
std::cout << "Authentication OK" << std::endl;
/* All done. */
pam_end (pamh, 0);
while(1) {} /* Prevent application finish. */
return 0;
}
}}}
Compiled with
{{{
g++ -g pamexample.c -pthread -lpam -lpam_misc
}}}
For my local user and correct password I get following output:
{{{
./a.out
Start thread func stuff 0
Thread func stuff 1
Password:
Thread func stuff 2
Thread func stuff 3
Thread func stuff 4
Thread func stuff 5
Thread func stuff 6
Authentication OK
}}}
For unsuccessful pam_authenticate calls output is correct. Output for
given example is correct on SLES 11.3, Ubuntu 14.04. Please let me know if
you need more information.
--
Ticket URL: <https://fedorahosted.org/linux-pam/ticket/45>
linux-pam <http://fedorahosted.org/linux-pam>
The Linux-PAM (Pluggable Authentication Modules) project
8 years, 7 months