diff options
author | Iftikhar Ahmad <iftikhar.ahmad@gmail.com> | 2013-03-19 10:45:06 +0000 |
---|---|---|
committer | Tarmac <Unknown> | 2013-03-19 10:45:06 +0000 |
commit | 0f96eaa7063719725176f8598e4bf4dd22767e45 (patch) | |
tree | 7e6acd2284d724a46079c2fb0018cde44d6151a7 /tests/mock_pam.c | |
parent | 749ee321ed3560c4d3889476fc86e3fbf75d89b1 (diff) | |
parent | 5cf1567bf526dd292e084e1a289f72609ea92c2d (diff) | |
download | libpam-freerdp2-0f96eaa7063719725176f8598e4bf4dd22767e45.tar.gz libpam-freerdp2-0f96eaa7063719725176f8598e4bf4dd22767e45.tar.bz2 libpam-freerdp2-0f96eaa7063719725176f8598e4bf4dd22767e45.zip |
Empty password fix and added related unit test Bug#1092428.
Approved by David Barth, PS Jenkins bot.
Diffstat (limited to 'tests/mock_pam.c')
-rw-r--r-- | tests/mock_pam.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/mock_pam.c b/tests/mock_pam.c index 6368b84..2a1dcc7 100644 --- a/tests/mock_pam.c +++ b/tests/mock_pam.c @@ -47,7 +47,37 @@ int fake_conv (int num_msg, const struct pam_message **msg, return PAM_SUCCESS; } +int fake_conv_empty_password (int num_msg, const struct pam_message **msg, + struct pam_response **resp, void *appdata_ptr) +{ + struct pam_response *response = NULL; + response = malloc (sizeof (struct pam_response)); + + if (response == NULL) + return PAM_BUF_ERR; + + response->resp_retcode = 0; + + if (strcmp((*msg)->msg, "login:") == 0) + response->resp = strdup ("guest"); /* IMPORTANT: this needs to be in /etc/passwd */ + else if (strcmp((*msg)->msg, "remote login:") == 0) + response->resp = strdup ("ruser"); + else if (strcmp((*msg)->msg, "remote host:") == 0) + response->resp = strdup ("protocol://rhost/dummy"); + else if (strcmp((*msg)->msg, "password:") == 0) + response->resp = strdup (""); + else if (strcmp((*msg)->msg, "domain:") == 0) + response->resp = strdup ("domain"); + else + return PAM_SYMBOL_ERR; /* leaks... */ + + *resp = response; + + return PAM_SUCCESS; +} + struct pam_conv static_conv = { &fake_conv, (void *)NULL }; +struct pam_conv static_conv_empty_pswd = { &fake_conv_empty_password, (void *)NULL }; pam_handle_t *pam_handle_new (void) { @@ -61,6 +91,18 @@ pam_handle_t *pam_handle_new (void) return newh; } +pam_handle_t *pam_handle_empty_pswd_new (void) +{ + pam_handle_t *newh = malloc (sizeof (pam_handle_t)); + + if (newh != NULL) { + newh->conv = &static_conv_empty_pswd; + memset(newh->item, 0, sizeof(void *) * PAM_NUM_ITEMS); + } + + return newh; +} + int pam_get_item (const pam_handle_t *pamh, int type, const void **value) { if (pamh == NULL) |