summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2024-01-31Merge pull request #22 from 3v1n0/prevent-unused-varHEADmasterMike Steinert
transaction: Ignore unused variable warnings
2024-01-19transaction: Ignore unused variable warningsMarco Trevisan (Treviño)
We may get some warnings when generating code as: warning: unused variable ‘_cgo_a’ This is something due to the fact we use `-Wall` that is not something golang upstream suggests. However, since this is the only warning we may have and it's not a super relevant one, we can ensure we ignore it.
2024-01-19ci: Update repositories information before installing packagesMarco Trevisan (Treviño)
Otherwise we may try to download packages that do not exist anymore
2024-01-19test: Only install pam modules from archivesMarco Trevisan (Treviño)
We had to workaround this since the ddebs archive wasn't updated with latest security updates, now it is so just use debug symbols packages from official repositories.
2023-11-30Update README for v2Michael Steinert
2023-11-30Merge pull request #21 from msteinert/v2Mike Steinert
Update module version to v2
2023-11-30Update module version to v2Michael Steinert
2023-11-29Merge pull request #19 from msteinert/codecovMike Steinert
Another try at adding codecov
2023-11-29Another try at adding codecovMichael Steinert
2023-11-29Merge pull request #18 from msteinert/codecovMike Steinert
Add codecov configuration
2023-11-29Add codecov configurationMichael Steinert
2023-11-29Merge pull request #17 from msteinert/update-examplev2.0.0Mike Steinert
Update example code to call Transaction.End
2023-11-29Update example code to call Transaction.EndMichael Steinert
2023-11-29Merge pull request #15 from 3v1n0/safer-transactionMike Steinert
Safer transaction: add End() method and don't use as error
2023-11-30transaction: Fix comment typoMarco Trevisan (Treviño)
2023-11-30transaction: Skip some tests requiring confdir if not availableMarco Trevisan (Treviño)
2023-11-30transaction_test: Add tests checking the loaded services matchMarco Trevisan (Treviño)
2023-11-30transaction: Add missing default PAM item typesMarco Trevisan (Treviño)
2023-11-30transaction: Mark Item, Flags and Style const values as Item, Flags and ↵Marco Trevisan (Treviño)
Style types We redefined various PAM constant values for items, flags and style, but only few of them were marked as being Item's or Flag's. This caused go to just consider them as generic integers instead of the actual subtype.
2023-11-30transaction: Add a test finalizer checking if transaction has endedMarco Trevisan (Treviño)
Check if a transaction is ended in in tests.
2023-11-30transaction: Add End() method and Remove Transaction finalizerMarco Trevisan (Treviño)
A PAM transaction needs to be ended in order to release the associated resources, however this can't be sadly automated as the go finalizers run in goroutines and this could cause problems to modules that we load. In fact a module code may be called back during pam_end (to cleanup data for example) and the module code could not be thread safe. So let's make this more manual, but safer. The transaction status is still preserved in the transaction so end will be automatically called with the last-known status. Closes: #14
2023-11-30transaction: Do not make Transaction to implement error interface anymoreMarco Trevisan (Treviño)
As per previous commit, Transaction can't be used anymore as an error value, but we instead we always return the status code.
2023-11-30transaction: Never return Transaction as errorMarco Trevisan (Treviño)
While transaction does implement error, it's not a valid error implementer because it may have bogous values since it's not thread-safe and so we may read the result of Error() when it's into an invalid state As per this never return it as an error, while always return the Status unless when not available, where we still return pam.Error.
2023-11-30transaction: Use Atomic to store/load the statusMarco Trevisan (Treviño)
Transactions save the status of each operation in a status field, however such field could be written concurrently by various operations, so we need to be sure that: - We always return the status for the current operation - We store the status in a atomic way so that other actions won't create write races In general, in a multi-thread operation one should not rely on Transaction.Error() to get info about the last operation.
2023-11-30transaction: Add an helper function to handle pam functions return statusMarco Trevisan (Treviño)
All the pam functions return an integer with the status of the operation so instead of duplicating the same code everywhere, that is quite error prone, use an helper function. It would have been nice to make this more dynamic, but cgo doesn't allow us to do much magic here. This is enough though.
2023-11-30transaction: Return errors wrapping pam.Error values on failureMarco Trevisan (Treviño)
If the transaction fails during start, there's no way to get the error detail in a programmatic way, so let's wrap the pam.Error to allow more per-type checks.
2023-11-30transaction: Add tests for all the possible Status (and error) valuesMarco Trevisan (Treviño)
Use pam_debug.so to generate pam configurations at test time and check if the returned values expect the ones we want.
2023-11-30transaction: Add PAM Error types Go definitionsMarco Trevisan (Treviño)
And use them instead of C ones. Given that we have strings for them we can easily implement error interfaces for it too.
2023-11-30ci: Use golang-ci linterMarco Trevisan (Treviño)
2023-09-23Run go fmtMichael Steinert
2023-09-22Merge pull request #9 from 3v1n0/binary-protocolv1.2.0Mike Steinert
transaction: Add support for Binary conversation
2023-09-22transaction: Add support for Binary conversationMarco Trevisan (Treviño)
PAM upports binary conversations using private protocols, this can be handled by C but it's not supported here because we implicitly convert all the messages to string, and this may lead to issues when this is not the case (as in binary protocol the pointer could contain zeros that the GoString conversion would consider them the end of the message). So, add another conversation handler implementation that allows to handle the binary protocol, whose function callback accepts a pointer to the struct (we can't use bytes as the length is unknown and may be defined in the header of the pointer itself). However since the binary prompt is not supported by all the platforms we need to do a compile-time check to disable it in case is used when not supported.
2023-09-21Merge pull request #11 from msteinert/transactionMike Steinert
Transaction handler updates
2023-09-21bugfix: Allocate after sanitizing inputsMichael Steinert
2023-09-21Format transaction.c with clang-formatMichael Steinert
To improve readability and encourage consistency in PRs.
2023-09-20Merge pull request #10 from msteinert/ci-matrixMike Steinert
Update CI configuration
2023-09-20Update CI configurationMichael Steinert
2023-09-20Merge pull request #8 from 3v1n0/simpler-callbacksMike Steinert
transaction: Use cgo.Handle to pass callback data to PAM
2023-09-20Merge pull request #7 from 3v1n0/rootless-testsMike Steinert
tests: Add more tests on PAM conversations that can run as user
2023-09-19transaction: Use cgo.Handle to pass callback data to PAMMarco Trevisan (Treviño)
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
2023-09-19transaction_test: Add root-less tests to check pam conversationMarco Trevisan (Treviño)
Use pam_succeed_if to make it implicitly ask for the user name and verify that the provided one is correct. This can safely run as user.
2023-09-19transaction_test: Add more authentication tests to run as userMarco Trevisan (Treviño)
So that it's possible also to verify an info text conversation
2023-09-19transaction_test: Enable conf-dir tests without rootMarco Trevisan (Treviño)
They don't require the `test` user nor being ran as root
2023-09-19tests: Move services to a subdirectoryMarco Trevisan (Treviño)
It makes it cleaner to handle, plus it allows adding more. Also rename the `my-service` to something more self-explanatory.
2023-04-04Merge pull request #6 from msteinert/depsMike Steinert
Update dependencies
2023-04-04Update dependenciesMichael Steinert
2022-09-17Merge pull request #5 from didrocks/start_confdirv1.1.0Mike Steinert
Allow to define confdir
2022-09-16Integration test for confdir handling.Didier Roche
Add tests to cover StartConfDir with custom services path.
2022-09-16Allow to define confdirDidier Roche
PAM has a pam_start_confdir() which allows to define the configuration directory where all services are located. This is useful to define your own service on tests in particular, so that you can control your stack and be independant of the host when running them. Allow defining this configuration directory, with a new StartConfDir function. Also, allow pre-checking for the API availability with CheckPamHasStartConfdir().
2022-08-03Update CI build matrixMichael Steinert