Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 311679 Details for
Bug 455217
pam_tally2 race when authenticating more than once at the same time.
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
pam_authenticate.c
pam_authenticate.c (text/plain), 3.61 KB, created by
Jatin Nansi
on 2008-07-14 05:27:07 UTC
(
hide
)
Description:
pam_authenticate.c
Filename:
MIME Type:
Creator:
Jatin Nansi
Created:
2008-07-14 05:27:07 UTC
Size:
3.61 KB
patch
obsolete
>/* >Author: Sachin Prabhu <sprabhu@redhat.com> > >Code samples used from following sources. >file:///usr/share/doc/pam-devel-0.99.8.1/html/adg-example.html >http://www.freebsd.org/doc/en/articles/pam/pam-sample-conv.html >*/ > >#include <stdio.h> >#include <string.h> >#include <errno.h> >#include <stdlib.h> > >#include <security/pam_appl.h> >#include <security/pam_misc.h> > >char *password=NULL; > >int converse(int n, const struct pam_message **msg, struct pam_response **resp, void *data) >{ > struct pam_response *aresp; > char buf[PAM_MAX_RESP_SIZE]; > int i; > > data = data; > if (n <= 0 || n > PAM_MAX_NUM_MSG) > return (PAM_CONV_ERR); > if ((aresp = calloc(n, sizeof *aresp)) == NULL) > return (PAM_BUF_ERR); > for (i = 0; i < n; ++i) { > aresp[i].resp_retcode = 0; > aresp[i].resp = NULL; > switch (msg[i]->msg_style) { > case PAM_PROMPT_ECHO_OFF: > aresp[i].resp = strdup(password); > if (aresp[i].resp == NULL) > goto fail; > break; > case PAM_PROMPT_ECHO_ON: > fputs(msg[i]->msg, stderr); > if (fgets(buf, sizeof buf, stdin) == NULL) > goto fail; > aresp[i].resp = strdup(buf); > if (aresp[i].resp == NULL) > goto fail; > break; > case PAM_ERROR_MSG: > fputs(msg[i]->msg, stderr); > if (strlen(msg[i]->msg) > 0 && > msg[i]->msg[strlen(msg[i]->msg) - 1] != '\n') > fputc('\n', stderr); > break; > case PAM_TEXT_INFO: > fputs(msg[i]->msg, stdout); > if (strlen(msg[i]->msg) > 0 && > msg[i]->msg[strlen(msg[i]->msg) - 1] != '\n') > fputc('\n', stdout); > break; > default: > goto fail; > } > } > *resp = aresp; > return (PAM_SUCCESS); > fail: > for (i = 0; i < n; ++i) { > if (aresp[i].resp != NULL) { > memset(aresp[i].resp, 0, strlen(aresp[i].resp)); > free(aresp[i].resp); > } > } > memset(aresp, 0, n * sizeof *aresp); > *resp = NULL; > return (PAM_CONV_ERR); >} > >static struct pam_conv conv = { > converse, > NULL >}; > >int myauth(char *service, char *username) >{ > > pam_handle_t *pamh=NULL; > int retval; > > if( (retval = pam_start(service, username, &conv, &pamh )) != PAM_SUCCESS ){ > fprintf( stderr, "pam_start: %d: %s\n", retval, pam_strerror(pamh, retval) ); > return -retval; > } > > if( (retval = pam_authenticate(pamh,0)) != PAM_SUCCESS ){ > fprintf( stderr, "pam_authenticate: %d: %s\n", retval, pam_strerror(pamh, retval) ); > return -retval; > } > > if( (retval = pam_acct_mgmt(pamh,0)) != PAM_SUCCESS ){ > fprintf( stderr, "pam_acct_mgmt: %d: %s\n", retval, pam_strerror(pamh, retval) ); > return -retval; > } > > if( (retval = pam_open_session(pamh,0)) != PAM_SUCCESS ){ > fprintf( stderr, "pam_open_session: %d: %s\n", retval, pam_strerror(pamh, retval) ); > return -retval; > } > > if( pam_end(pamh, retval) != PAM_SUCCESS ){ > fprintf( stderr, "pam_end: failed to close pam session\n" ); > return -1; > } > > return 0; >} > >int main( int argc, char **argv) >{ > unsigned int i=0,errors=0; > > if( argc != 4 ){ > fprintf(stderr, "Invalid number of arguments.\nUsage: %s <service> <username> <passwd>\n", argv[0]); > return -EINVAL; > } > > password=argv[3]; > > for( i=0; i<100000; i++ ){ > if( myauth(argv[1], argv[2]) < 0 ){ > errors++; > printf("errors=%lu, count=%lu\n", errors,i+1); > } > if( ((i+1)%1000) == 0 ){ > printf("count %lu\n",i+1); > } > } > > printf("Completed %lu iterations. Number of errors encountered = %lu.\n",i,errors); > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 455217
: 311679 |
311680
|
311681