diff options
author | Thomas Boerger <thomas@webhippie.de> | 2016-11-03 23:16:01 +0100 |
---|---|---|
committer | Thomas Boerger <thomas@webhippie.de> | 2016-11-04 08:43:11 +0100 |
commit | 1ebb35b98889ff77299f24d82da426b434b0cca0 (patch) | |
tree | 6dcb814d6df4d11c7e7a0ba6da8a6945628e2c5d /vendor/github.com/msteinert/pam/transaction.c | |
parent | 78f86abba45cb35018c58b8bd5f4c48a86cc8634 (diff) | |
download | gitea-1ebb35b98889ff77299f24d82da426b434b0cca0.tar.gz gitea-1ebb35b98889ff77299f24d82da426b434b0cca0.zip |
Added all required dependencies
Diffstat (limited to 'vendor/github.com/msteinert/pam/transaction.c')
-rw-r--r-- | vendor/github.com/msteinert/pam/transaction.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/vendor/github.com/msteinert/pam/transaction.c b/vendor/github.com/msteinert/pam/transaction.c new file mode 100644 index 0000000000..5cf22a5db3 --- /dev/null +++ b/vendor/github.com/msteinert/pam/transaction.c @@ -0,0 +1,46 @@ +#include "_cgo_export.h" +#include <security/pam_appl.h> +#include <string.h> + +int cb_pam_conv( + int num_msg, + const struct pam_message **msg, + struct pam_response **resp, + void *appdata_ptr) +{ + *resp = calloc(num_msg, sizeof **resp); + if (num_msg <= 0 || num_msg > PAM_MAX_NUM_MSG) { + return PAM_CONV_ERR; + } + if (!*resp) { + return PAM_BUF_ERR; + } + for (size_t i = 0; i < num_msg; ++i) { + struct cbPAMConv_return result = cbPAMConv( + msg[i]->msg_style, + (char *)msg[i]->msg, + (long)appdata_ptr); + if (result.r1 != PAM_SUCCESS) { + goto error; + } + (*resp)[i].resp = result.r0; + } + return PAM_SUCCESS; +error: + for (size_t i = 0; i < num_msg; ++i) { + if ((*resp)[i].resp) { + memset((*resp)[i].resp, 0, strlen((*resp)[i].resp)); + free((*resp)[i].resp); + } + } + memset(*resp, 0, num_msg * sizeof *resp); + free(*resp); + *resp = NULL; + return PAM_CONV_ERR; +} + +void init_pam_conv(struct pam_conv *conv, long c) +{ + conv->conv = cb_pam_conv; + conv->appdata_ptr = (void *)c; +} |