CVM

CVM Module Library

To write a module using the CVM module library, you must provide the following items:

const unsigned cvm_credential_count
Set this global to the number of credentials required from the client.
const char* cvm_credentials[X], where X is the same as credential_count above
Pointers to the credentials read from the client are stored in this array.
int cvm_auth_init(void)
This routine is called once when the CVM starts up.
int cvm_authenticate(void)
The main authentication verification routine.
Before cvm_authenticate() is called, the input data stream is read and the account name is parsed into cvm_account_name, the domain name into cvm_account_domain, and the credentials are parsed into cvm_credentials.

If authentication fails, the module must return CVME_PERMFAIL (value 100). If there was a temporary error, return any other non-zero number error code. Otherwise, return zero after setting cvm_fact_username, cvm_fact_userid, cvm_fact_groupid, cvm_fact_directory, and cvm_fact_shell, which will be automatically sent to the client when authenticate() completes. cvm_fact_realname, cvm_fact_groupname, cvm_fact_sys_username, cvm_fact_sys_directory, and cvm_fact_domain will also be sent if they are set. If any other facts are to be returned to the client, send them with cvm_fact_str(int number, const char* data) or cvm_fact_uint(int number, unsigned data).

NOTE: cvm_authenticate() must never exit except on fatal errors. If it allocates any memory, it must either be freed or reallocated on the next invocation.

Each module will implement at least one type of credential validation (ie plain text, CRAM, etc). Modules are not obligated to implement multiple types of validation, but may do so by examinimg which credentials are present in the input. The invoker will choose which modules to invoke depending on what type of credentials it needs validated.