summaryrefslogtreecommitdiff
path: root/transaction.c
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <[email protected]>2023-09-19 20:04:06 +0200
committerMarco Trevisan (Treviño) <[email protected]>2023-09-19 20:06:38 +0200
commit78ffef4acdc2b5b6365c7167405cf72239da584a (patch)
treeb5af24a72244faeccbda6a86ea754293214560fe /transaction.c
parent5253f659f39e53933241047250d12d92aa173192 (diff)
transaction: Use cgo.Handle to pass callback data to PAM
Go provides a nicer way to handle Go structs lifetime when they are passed to C now, so use this instead of a custom implementation that requires to store them in a map
Diffstat (limited to 'transaction.c')
-rw-r--r--transaction.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/transaction.c b/transaction.c
index 07155e1..df25cf6 100644
--- a/transaction.c
+++ b/transaction.c
@@ -1,5 +1,6 @@
#include "_cgo_export.h"
#include <security/pam_appl.h>
+#include <stdint.h>
#include <string.h>
#ifdef __sun
@@ -25,7 +26,7 @@ int cb_pam_conv(
struct cbPAMConv_return result = cbPAMConv(
msg[i]->msg_style,
(char *)msg[i]->msg,
- (long)appdata_ptr);
+ (uintptr_t)appdata_ptr);
if (result.r1 != PAM_SUCCESS) {
goto error;
}
@@ -45,10 +46,10 @@ error:
return PAM_CONV_ERR;
}
-void init_pam_conv(struct pam_conv *conv, long c)
+void init_pam_conv(struct pam_conv *conv, uintptr_t appdata)
{
conv->conv = cb_pam_conv;
- conv->appdata_ptr = (void *)c;
+ conv->appdata_ptr = (void *)appdata;
}
// pam_start_confdir is a recent PAM api to declare a confdir (mostly for tests)