Commit Graph

8 Commits

Author SHA1 Message Date
Marco Trevisan (Treviño) 04ad7bdc73 module-transaction: Do not allow parallel conversations by default
Pam conversations per se may also run in parallel, but this implies that
the application supports this.

Since this normally not the case, do not create modules that may invoke
the pam conversations in parallel by default, adding a mutex to protect
such calls.
2023-12-14 22:07:50 +01:00
Marco Trevisan (Treviño) ac879208ea module-transaction: Add support for binary conversations
A module can now initiate a binary conversation decoding the native
pointer value as it wants.

Added tests to verify the main cases
2023-12-14 22:07:50 +01:00
Marco Trevisan (Treviño) 883dc86533 module-transaction: Add support for initiating PAM Conversations
Modules have the ability to start PAM conversations, so while the
transaction code can handle them we did not have a way to init them.
Yet.

So add some APIs allowing this, making it easier from the go side to
handle the conversations.

In this commit we only support text-based conversations, but code is
designed with the idea of supporting binary cases too.

Added the integration tests using the module that is now able to both
start conversation and handle them using Go only.
2023-12-14 22:07:50 +01:00
Marco Trevisan (Treviño) 7a073f5ba0 module-transaction: Add support for setting/getting module data
Module data is data associated with a module handle that is available
for the whole module loading time so it can be used also during
different operations.

We use cgo handles to preserve the life of the go objects so any value
can be associated with a pam transaction.
2023-12-14 22:07:50 +01:00
Marco Trevisan (Treviño) 449b2672b9 module-transaction: Add GetUser() method that prompts an user if non-set
We can now finally test this properly both using a mock and through the
interactive module that will do the request for us in various conditions.
2023-12-14 22:07:50 +01:00
Marco Trevisan (Treviño) 6f3af6e9b2 moduler: Move module transaction invoke handling to transaction itself
So we can reduce the generated code and add more unit tests
2023-12-14 22:07:50 +01:00
Marco Trevisan (Treviño) a8c4a14150 pam-moduler: Add first implementation of a Go PAM Module generator
A PAM module can be generated using pam-moduler and implemented fully in
go without having to manually deal with the C setup.

Module can be compiled using go generate, so go:generate directives can be
used to make this process automatic, with a single go generate call as shown
in the example.
2023-12-14 22:07:48 +01:00
Marco Trevisan (Treviño) 11daf4a88d transaction: Add ModuleTransaction type and ModuleHandler interface
This allows to easily define go-handlers for module operations.

We need to expose few more types externally so that it's possible to
create the module transaction handler and return specific transaction
errors
2023-12-01 19:59:59 +01:00