struct pam_response **response,
void *appdata_ptr)
{
- int i, ri = 0;
+ int i = 0;
int ret;
struct pam_response *reply = NULL;
const char *prompt;
- struct pamtest_conv_ctx *cctx = \
- (struct pamtest_conv_ctx *) appdata_ptr;
+ struct pamtest_conv_ctx *cctx = (struct pamtest_conv_ctx *)appdata_ptr;
if (cctx == NULL) {
return PAM_CONV_ERR;
if (reply != NULL) {
if (prompt != NULL) {
- ret = add_to_reply(&reply[ri], prompt);
+ ret = add_to_reply(&reply[i], prompt);
if (ret != PAM_SUCCESS) {
free_reply(reply, num_msg);
return ret;
}
- } else {
- reply[ri].resp = NULL;
}
- ri++;
}
cctx->echo_off_idx++;
if (reply != NULL) {
if (prompt != NULL) {
- ret = add_to_reply(&reply[ri], prompt);
+ ret = add_to_reply(&reply[i], prompt);
if (ret != PAM_SUCCESS) {
free_reply(reply, num_msg);
return ret;
}
}
- ri++;
}
cctx->echo_on_idx++;
break;
case PAM_ERROR_MSG:
+ if (reply != NULL) {
+ ret = add_to_reply(&reply[i], msgm[i]->msg);
+ if (ret != PAM_SUCCESS) {
+ free_reply(reply, num_msg);
+ return ret;
+ }
+ }
+
if (cctx->data->out_err != NULL) {
memcpy(cctx->data->out_err[cctx->err_idx],
msgm[i]->msg,
}
break;
case PAM_TEXT_INFO:
+ if (reply != NULL) {
+ ret = add_to_reply(&reply[i], msgm[i]->msg);
+ if (ret != PAM_SUCCESS) {
+ free_reply(reply, num_msg);
+ return ret;
+ }
+ }
+
if (cctx->data->out_info != NULL) {
memcpy(cctx->data->out_info[cctx->info_idx],
msgm[i]->msg,
}
}
- if (response && ri > 0) {
+ if (response != NULL) {
*response = reply;
} else {
free(reply);
void *handle = NULL;
#ifdef RTLD_DEEPBIND
- flags |= RTLD_DEEPBIND;
+ const char *env = getenv("LD_PRELOAD");
+
+ /* Don't do a deepbind if we run with libasan */
+ if (env != NULL && strlen(env) < PATH_MAX) {
+ const char *p = strstr(env, "libasan.so");
+ if (p == NULL) {
+ flags |= RTLD_DEEPBIND;
+ }
+ }
#endif
switch (lib) {
PWRAP_LOG(PWRAP_LOG_DEBUG, "Initialize pam_wrapper");
- pwrap_clean_stale_dirs(tmp_config_dir);
-
pwrap.config_dir = strdup(tmp_config_dir);
if (pwrap.config_dir == NULL) {
PWRAP_LOG(PWRAP_LOG_ERROR,
rc = mkdir(libpam_path, 0755);
if (rc != 0) {
PWRAP_LOG(PWRAP_LOG_ERROR,
- "Failed to create pam_wrapper config dir: %s - %s",
+ "Failed to create path for libpam: %s - %s",
tmp_config_dir, strerror(errno));
p_rmdirs(pwrap.config_dir);
exit(1);