pamtest(3)
π NAME
okay so bestie, you're looking at pamtest(3) from the Library Functions Manual β and it's literally the pamtest API. That's the whole NAME section, no cap. π
β¨ SYNOPSIS
This is the quick-look menu, and every signature is coming with us β no skipping the boring bits, periodt. π«Ά
π§ Data Structures
struct pam_testcaseβ The PAM testcase struction. (yes, that's the spelling in the docs π)struct pamtest_conv_dataβ This structure should be used when usingrun_pamtest, which uses an internal conversation function.
π Macros
#define pam_test(op, expected)
#define pam_test_flags(op, expected, flags)
pam_testβ Initializes apam_tescasestructure. (typo stays iconic π )pam_test_flagsβ Initializes aCMUnitTeststructure with additional PAM flags.
π¦ Typedefs
typedef int(* pam_conv_fn) (int num_msg, const struct pam_message **msg,
struct pam_response **resp, void *appdata_ptr)
pam_conv_fnβ PAM conversation function, defined inpam_conv(3).
πΈ Enumerations
enum pamtest_err { PAMTEST_ERR_OK, PAMTEST_ERR_START, PAMTEST_ERR_CASE,
PAMTEST_ERR_OP, PAMTEST_ERR_END, PAMTEST_ERR_KEEPHANDLE,
PAMTEST_ERR_INTERNAL }
enum pamtest_ops { PAMTEST_AUTHENTICATE, PAMTEST_SETCRED,
PAMTEST_ACCOUNT, PAMTEST_OPEN_SESSION, PAMTEST_CLOSE_SESSION,
PAMTEST_CHAUTHTOK, PAMTEST_GETENVLIST = 20, PAMTEST_KEEPHANDLE }
pamtest_errβ The return code of the pamtest function.pamtest_opsβ The enum which describes the operations performed bypamtest().
π Functions
const struct pam_testcase * pamtest_failed_case (struct pam_testcase
*test_cases)
void pamtest_free_env (char **envlist)
const char * pamtest_strerror (enum pamtest_err perr)
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)
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)
pamtest_failed_caseβ Helper you can call ifrun_pamtest()fails.pamtest_free_envβ This frees the string array returned by thePAMTEST_GETENVLISTtest.pamtest_strerrorβ Returns a string representation of libpamtest error code.run_pamtestβ Run libpamtest test cases.run_pamtest_convβ Run libpamtest test cases.
π Detailed Description
This is the big-picture section, and the actual deets are chilling in the docs below β keep scrolling, bestie. π
π§ Typedef Documentation
pam_conv_fn
typedef 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). This is just a typedef to use in our declarations. See man pam_conv(3) for more details. slay π
π Enumeration Type Documentation
enum pamtest_err
The return code of the pamtest function.
Enumerator
PAMTEST_ERR_OKβ Testcases returns correspond with input.PAMTEST_ERR_STARTβpam_start()failedPAMTEST_ERR_CASEβ A testcase failed. Usepamtest_failed_casePAMTEST_ERR_OPβ Could not run a test case.PAMTEST_ERR_ENDβpam_endfailedPAMTEST_ERR_KEEPHANDLEβ Handled internally.PAMTEST_ERR_INTERNALβ Internal error - bad input or similar.
enum pamtest_ops
The enum which describes the operations performed by pamtest().
Enumerator
PAMTEST_AUTHENTICATEβ runpam_authenticateto authenticate the accountPAMTEST_SETCREDβ runpam_setcred()to establish/delete user credentialsPAMTEST_ACCOUNTβ runpam_acct_mgmt()to validate the PAM accountPAMTEST_OPEN_SESSIONβ runpam_open_session()to start a PAM sessionPAMTEST_CLOSE_SESSIONβ runpam_close_session()to end a PAM sessionPAMTEST_CHAUTHTOKβ runpam_chauthtok()to update the authentication tokenPAMTEST_GETENVLISTβ If this option is set the test will callpam_getenvlist()and copy the environment intocase_out.envlist.PAMTEST_KEEPHANDLEβ This will prevent callingpam_end()and will just return the PAM handle incase_out.ph.
π₯ Function Documentation
pamtest_failed_case
const struct pam_testcase * pamtest_failed_case (struct pam_testcase
*test_cases)
Helper you can call if run_pamtest() fails. If PAMTEST_ERR_CASE is returned by run_pamtest() you should call this function to get a pointer to the failed test case.
Parameters
test_casesβ The array of tests.
Returns
a pointer to the array of test_cases[] that corresponds to the first test case where the expected error code doesn't match the real error code.
pamtest_free_env
void pamtest_free_env (char **envlist)
This frees the string array returned by the PAMTEST_GETENVLIST test.
Parameters
envlistβ The array to free.
pamtest_strerror
const char * pamtest_strerror (enum pamtest_err perr)
Returns a string representation of libpamtest error code.
Parameters
perrβ libpamtest error code
Returns
String representation of the perr argument. Never returns NULL.
References: PAMTEST_ERR_CASE, PAMTEST_ERR_END, PAMTEST_ERR_INTERNAL, PAMTEST_ERR_KEEPHANDLE, PAMTEST_ERR_OK, PAMTEST_ERR_OP, and PAMTEST_ERR_START.
run_pamtest
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. This is using the default libpamtest conversation function.
Parameters
serviceβ The PAM service to use in the conversationuserβ The user to run conversation asconv_dataβ Test-specific conversation datatest_casesβ List of libpamtest test cases. Must end withPAMTEST_CASE_SENTINELpam_handleβ The PAM handle to use to run the tests
int main(void) {
int rc;
const struct pam_testcase tests[] = {
pam_test(PAM_AUTHENTICATE, PAM_SUCCESS),
};
rc = run_pamtest(tests, NULL, NULL);
return rc;
}
Returns
PAMTEST_ERR_OK on success, else the error code matching the failure.
run_pamtest_conv
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. This is using the default libpamtest conversation function.
Parameters
serviceβ The PAM service to use in the conversationuserβ The user to run conversation asconv_fnβ Test-specific conversation functionconv_userdataβ Test-specific conversation datatest_casesβ List of libpamtest test cases. Must end withPAMTEST_CASE_SENTINELpam_handleβ The PAM handle to use to run the tests
int main(void) {
int rc;
const struct pam_testcase tests[] = {
pam_test(PAM_AUTHENTICATE, PAM_SUCCESS),
};
rc = run_pamtest(tests, NULL, NULL);
return rc;
}
Returns
PAMTEST_ERR_OK on success, else the error code matching the failure.
π Author
Generated automatically by Doxygen for pam_wrapper from the source code. That's the author tea, bestie. π
Sign-off: this page is from pam_wrapper, page pamtest(3) β and there's no date line in this footer, so that's the whole footer vibe. mwah π
π¦ where this page comes from
- arch rolling: pam_wrapper-docs 1.1.8-2 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms