summaryrefslogtreecommitdiff
path: root/transaction.c
diff options
context:
space:
mode:
authorMichael Steinert <[email protected]>2015-03-27 18:59:29 -0500
committerMichael Steinert <[email protected]>2015-03-28 17:00:58 -0500
commitd67bb86e54c08eb5ae75148195a0c840758ee43c (patch)
tree3f47649d11107635110fa9238536d7a2eb963200 /transaction.c
parenta6dbe3c2bf85196d35238b0a6edb696963184315 (diff)
Update interface
Diffstat (limited to 'transaction.c')
-rw-r--r--transaction.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/transaction.c b/transaction.c
new file mode 100644
index 0000000..e8eb824
--- /dev/null
+++ b/transaction.c
@@ -0,0 +1,42 @@
+#include "_cgo_export.h"
+#include <security/pam_appl.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 (!*resp) {
+ return PAM_BUF_ERR;
+ }
+ for (size_t i = 0; i < num_msg; ++i) {
+ const struct pam_message *m = msg[i];
+ struct cbPAMConv_return result =
+ cbPAMConv(m->msg_style, (char *)m->msg, 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) {
+ free((*resp)[i].resp);
+ }
+ free(*resp);
+ *resp = NULL;
+ return PAM_CONV_ERR;
+}
+
+struct pam_conv *make_pam_conv(void *appdata_ptr)
+{
+ struct pam_conv* conv = malloc(sizeof *conv);
+ if (!conv) {
+ return NULL;
+ }
+ conv->conv = cb_pam_conv;
+ conv->appdata_ptr = appdata_ptr;
+ return conv;
+}