Marco Trevisan (Treviño)
3e4f7f5e4b
transaction: Add an helper function to handle pam functions return status
...
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-30 01:16:39 +01:00
Marco Trevisan (Treviño)
a5f5ad6470
transaction: Return errors wrapping pam.Error values on failure
...
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-30 01:16:39 +01:00
Marco Trevisan (Treviño)
ea51cc0fe4
transaction: Add tests for all the possible Status (and error) values
...
Use pam_debug.so to generate pam configurations at test time and
check if the returned values expect the ones we want.
2023-11-30 01:16:39 +01:00
Marco Trevisan (Treviño)
6bb315c571
transaction: Add PAM Error types Go definitions
...
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-30 01:16:39 +01:00
Marco Trevisan (Treviño)
44c364e364
ci: Use golang-ci linter
2023-11-30 01:16:38 +01:00
Michael Steinert
a85a609bbe
Run go fmt
2023-09-23 10:38:09 -05:00
Mike Steinert
2e7b8b76d5
Merge pull request #9 from 3v1n0/binary-protocol
...
transaction: Add support for Binary conversation
2023-09-22 09:16:15 -05:00
Marco Trevisan (Treviño)
b9265b1c6a
transaction: Add support for Binary conversation
...
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-22 04:05:16 +02:00
Mike Steinert
08dbc65c91
Merge pull request #11 from msteinert/transaction
...
Transaction handler updates
2023-09-21 08:27:18 -05:00
Michael Steinert
b324e2b31b
bugfix: Allocate after sanitizing inputs
2023-09-21 08:24:04 -05:00
Michael Steinert
df9e70a6d7
Format transaction.c with clang-format
...
To improve readability and encourage consistency in PRs.
2023-09-21 08:23:39 -05:00
Mike Steinert
d9b3ff918f
Merge pull request #10 from msteinert/ci-matrix
...
Update CI configuration
2023-09-20 19:25:24 -05:00
Michael Steinert
736c9ebebe
Update CI configuration
2023-09-20 19:22:43 -05:00
Mike Steinert
e0a2c7ba60
Merge pull request #8 from 3v1n0/simpler-callbacks
...
transaction: Use cgo.Handle to pass callback data to PAM
2023-09-20 08:54:38 -05:00
Mike Steinert
718a0b9deb
Merge pull request #7 from 3v1n0/rootless-tests
...
tests: Add more tests on PAM conversations that can run as user
2023-09-20 08:46:09 -05:00
Marco Trevisan (Treviño)
78ffef4acd
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
2023-09-19 20:06:38 +02:00
Marco Trevisan (Treviño)
a22a1abf3f
transaction_test: Add root-less tests to check pam conversation
...
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-19 18:46:25 +02:00
Marco Trevisan (Treviño)
1cab6e699c
transaction_test: Add more authentication tests to run as user
...
So that it's possible also to verify an info text conversation
2023-09-19 18:46:25 +02:00
Marco Trevisan (Treviño)
ca3e79e605
transaction_test: Enable conf-dir tests without root
...
They don't require the `test` user nor being ran as root
2023-09-19 18:18:56 +02:00
Marco Trevisan (Treviño)
d0c0c8bf18
tests: Move services to a subdirectory
...
It makes it cleaner to handle, plus it allows adding more.
Also rename the `my-service` to something more self-explanatory.
2023-09-19 18:17:54 +02:00
Mike Steinert
5253f659f3
Merge pull request #6 from msteinert/deps
...
Update dependencies
2023-04-04 15:44:11 -05:00
Michael Steinert
2c8b026146
Update dependencies
2023-04-04 15:44:38 -05:00
Mike Steinert
313ea6f3ba
Merge pull request #5 from didrocks/start_confdir
...
Allow to define confdir
2022-09-17 16:16:24 -05:00
Didier Roche
376af17c46
Integration test for confdir handling.
...
Add tests to cover StartConfDir with custom services path.
2022-09-16 08:50:03 +02:00
Didier Roche
bc958bdbd7
Allow to define confdir
...
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-09-16 08:09:26 +02:00
Michael Steinert
f401703daf
Update CI build matrix
2022-08-03 16:07:21 -05:00
Michael Steinert
39406aafe4
Attempt to modernize the repo
2021-12-03 12:05:27 -06:00
Michael Steinert
e613721261
Update CI build matrix
2020-11-30 11:06:57 -06:00
Mike Steinert
913b8f8cdf
Merge pull request #3 from andy-js/solaris-fix
...
Fix build on Solaris
2020-08-10 15:48:41 -05:00
Andrew Stormont
b29ac23417
Fix build on Solaris
2020-08-10 21:32:58 +01:00
Michael Steinert
f29b9f28d6
Update CI build matrix & fix some lint
2019-02-15 12:06:59 -06:00
Michael Steinert
f4cd9f5e29
Update CI build matrix
2017-08-30 10:59:15 -05:00
Mike Steinert
2c288b3ef8
Merge pull request #2 from msteinert/skip-coverage
...
Skip coverage report for pull requests
2017-07-05 09:26:45 -05:00
Michael Steinert
1a9eb8fe8b
Skip coverage report for pull requests
2017-07-05 09:18:20 -05:00
Michael Steinert
db23a9ef3f
Update CI build matrix
2017-06-12 11:01:45 -05:00
Michael Steinert
02ccfbfaf0
[ci skip] Update documentation
2015-12-04 10:05:44 -06:00
Michael Steinert
1d0c8bc60c
Fix lint
2015-12-04 09:46:42 -06:00
Michael Steinert
7f5fc62ba4
Remove dead code
2015-12-04 09:21:38 -06:00
Michael Steinert
4314ed7dcc
Update example code
2015-12-04 09:21:17 -06:00
Michael Steinert
a245f1098c
Fix a memory leak
2015-12-04 09:03:39 -06:00
Michael Steinert
8ec1202046
Stop passing Go pointers to C
2015-12-03 14:59:51 -06:00
Michael Steinert
6534f23b39
[ci skip] Update link to official documentation
2015-09-03 15:12:29 -05:00
Michael Steinert
9a42d39dbf
Update example
2015-04-11 13:27:31 -05:00
Michael Steinert
8b3b6781b0
Test some failure conditions
2015-04-10 15:28:23 -05:00
Michael Steinert
d5d607bc17
Add Go Report Card badge
2015-04-10 15:11:06 -05:00
Michael Steinert
61a0e177d2
Fix golint warnings
2015-04-10 15:04:52 -05:00
Michael Steinert
b60415a968
Another stab at goveralls
2015-04-09 14:21:10 -05:00
Michael Steinert
7ad21d5bbc
Add Coveralls.io
2015-04-09 13:44:52 -05:00
Michael Steinert
9d2ea3b16d
Install cover before running tests
2015-04-09 13:16:32 -05:00
Michael Steinert
b4414b73f0
Improve test coverage
2015-04-09 11:37:39 -05:00