19 #ifndef __LIBPAMTEST_H_
20 #define __LIBPAMTEST_H_
24 #include <security/pam_appl.h>
82 #define pam_test(op, expected) { op, expected, 0, 0, { .envlist = NULL } }
84 #define pam_test_flags(op, expected, flags) { op, expected, flags, 0, { .envlist = NULL } }
113 const struct pam_message **msg,
114 struct pam_response **resp,
181 pam_handle_t *pam_handle);
183 #define run_pamtest_conv(service, user, conv_fn, conv_data, test_cases, pam_handle) \
184 _pamtest_conv(service, user, conv_fn, conv_data, test_cases, sizeof(test_cases)/sizeof(test_cases[0], pam_handle)
223 pam_handle_t *pam_handle);
225 #define run_pamtest(service, user, conv_data, test_cases, pam_handle) \
226 _pamtest(service, user, conv_data, test_cases, sizeof(test_cases)/sizeof(test_cases[0]), pam_handle)
244 #define pamtest_failed_case(test_cases) \
245 _pamtest_failed_case(test_cases, sizeof(test_cases) / sizeof(test_cases[0]))
266 enum pamtest_err _pamtest_conv(
const char *service,
271 size_t num_test_cases,
272 pam_handle_t *pam_handle);
278 size_t num_test_cases,
279 pam_handle_t *pam_handle);
282 size_t num_test_cases);
int(* pam_conv_fn)(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr)
PAM conversation function, defined in pam_conv(3)
Definition: libpamtest.h:112
void pamtest_free_env(char **envlist)
This frees the string array returned by the PAMTEST_GETENVLIST test.
Definition: libpamtest.c:125
const char * pamtest_strerror(enum pamtest_err perr)
return a string representation of libpamtest error code.
Definition: libpamtest.c:157
pamtest_ops
The enum which describes the operations performed by pamtest().
Definition: libpamtest.h:35
enum pamtest_err run_pamtest_conv(const char *service, const char *user, pam_conv_fn conv_fn, void *conv_userdata, struct pam_testcase test_cases[], pam_handle_t *pam_handle)
Run libpamtest test cases.
pamtest_err
The return code of the pamtest function.
Definition: libpamtest.h:89
enum pamtest_err run_pamtest(const char *service, const char *user, struct pamtest_conv_data *conv_data, struct pam_testcase test_cases[], pam_handle_t *pam_handle)
Run libpamtest test cases.
const struct pam_testcase * pamtest_failed_case(struct pam_testcase *test_cases)
Helper you can call if run_pamtest() fails.
@ PAMTEST_OPEN_SESSION
run pam_open_session() to start a PAM session
Definition: libpamtest.h:43
@ PAMTEST_SETCRED
run pam_setcred() to establish/delete user credentials
Definition: libpamtest.h:39
@ PAMTEST_CHAUTHTOK
run pam_chauthtok() to update the authentication token
Definition: libpamtest.h:47
@ PAMTEST_GETENVLIST
If this option is set the test will call pam_getenvlist() and copy the environment into case_out....
Definition: libpamtest.h:53
@ PAMTEST_AUTHENTICATE
run pam_authenticate to authenticate the account
Definition: libpamtest.h:37
@ PAMTEST_CLOSE_SESSION
run pam_close_session() to end a PAM session
Definition: libpamtest.h:45
@ PAMTEST_ACCOUNT
run pam_acct_mgmt() to validate the PAM account
Definition: libpamtest.h:41
@ PAMTEST_KEEPHANDLE
This will prevent calling pam_end() and will just return the PAM handle in case_out....
Definition: libpamtest.h:58
@ PAMTEST_ERR_END
pam_end failed
Definition: libpamtest.h:99
@ PAMTEST_ERR_CASE
A testcase failed.
Definition: libpamtest.h:95
@ PAMTEST_ERR_START
pam_start() failed
Definition: libpamtest.h:93
@ PAMTEST_ERR_KEEPHANDLE
Handled internally.
Definition: libpamtest.h:101
@ PAMTEST_ERR_INTERNAL
Internal error - bad input or similar.
Definition: libpamtest.h:103
@ PAMTEST_ERR_OP
Could not run a test case.
Definition: libpamtest.h:97
@ PAMTEST_ERR_OK
Testcases returns correspond with input.
Definition: libpamtest.h:91
The PAM testcase struction.
Definition: libpamtest.h:68
This structure should be used when using run_pamtest, which uses an internal conversation function.
Definition: libpamtest.h:121
char ** out_err
Captures messages through PAM_ERROR_MSG.
Definition: libpamtest.h:135
char ** out_info
Captures messages through PAM_TEXT_INFO.
Definition: libpamtest.h:139
const char ** in_echo_on
When the conversation function receives PAM_PROMPT_ECHO_ON, it reads the input from the in_echo_off a...
Definition: libpamtest.h:131
const char ** in_echo_off
When the conversation function receives PAM_PROMPT_ECHO_OFF, it reads the auth token from the in_echo...
Definition: libpamtest.h:126