/* Allows the conversation function to find required items */ struct conv_func_data
{ constchar *pass;
};
struct auth_info
{ int session_opened; int did_setcred;
pam_handle_t *ph;
};
/***************************************************************************//**
* Returns a string representing a pam_conv message style
*
* @param msg_style PAM msg_style (pam_conv(3))
* @param buff Buffer for conversion of unrecognised values
* @param bufflen Total length of above
*
* The buffer described by buff is only written to if required.
*/ staticconstchar *
msg_style_to_str(int msg_style, char *buff, unsignedint bufflen)
{ constchar *result; switch (msg_style)
{ case PAM_PROMPT_ECHO_OFF:
result = "PAM_PROMPT_ECHO_OFF"; break;
case PAM_PROMPT_ECHO_ON:
result = "PAM_PROMPT_ECHO_ON"; break;
case PAM_ERROR_MSG:
result = "PAM_ERROR_MSG"; break;
case PAM_TEXT_INFO:
result = "PAM_TEXT_INFO"; break;
default:
g_snprintf(buff, bufflen, "UNKNOWN_0x%x", msg_style);
result = buff;
}
return result;
}
/***************************************************************************//**
* Provides the PAM conversation callback function
*
* At present, the main purpose of this function is to supply the
* user's password to the PAM stack, although some module logging is
* implemented here.
*
* @param[in] num_msg Count of messages in the msg array
* @param[in] msg Messages from the PAM stack to the application
* @param[out] resp Message replies from the application to the PAM stack
* @param[in] appdata_ptr Used to pass in a struct conv_func_data pointer
*
* @result PAM_SUCCESS if the messages were all processed successfully.
*
* @post If PAM_SUCCESS is returned, resp and its contents are allocated here
* and must be freed by the caller
* @post If PAM_SUCCESS is not returned, resp is not allocated and must not
* be not freed by the caller
*
* @note See pam_conv(3) for more information
* @note A basic example conversation function can be found in OSF RFC 86.0 (1995)
*/
/* Set the appdata_ptr passed to the conversation function to
* NULL, as the existing value is going out of scope */
pamc.appdata_ptr = NULL;
perror = pam_set_item(auth_info->ph, PAM_CONV, &pamc); if (perror != PAM_SUCCESS)
{
LOG(LOG_LEVEL_ERROR, "pam_set_item(PAM_CONV) failed: %s",
pam_strerror(auth_info->ph, perror));
}
return E_SCP_LOGIN_OK;
}
/******************************************************************************/ /* returns non-NULL for success
* Detailed error code is in the errorcode variable */
/******************************************************************************/ /** *Mainroutinetostartasession * *Callstheprivateroutineandlogsanadditionalerroriftheprivate *routinefails
*/ int
auth_start_session(struct auth_info *auth_info, int display_num)
{ int result = auth_start_session_private(auth_info, display_num); if (result != 0)
{
LOG(LOG_LEVEL_ERROR, "Can't start PAM session. See PAM logging for more info");
}
return result;
}
/******************************************************************************/ /* returns error */ staticint
auth_stop_session(struct auth_info *auth_info)
{ int rv = 0; int error;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.