Skip to content

pam/go/exec: Code cleanup #822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 14, 2025
Merged

pam/go/exec: Code cleanup #822

merged 7 commits into from
Mar 14, 2025

Conversation

3v1n0
Copy link
Collaborator

@3v1n0 3v1n0 commented Mar 3, 2025

Some random cleanups on the exec module, see commits for datails

UDENG-6256

@3v1n0 3v1n0 requested a review from a team as a code owner March 3, 2025 19:47
@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2025

Codecov Report

Attention: Patch coverage is 51.21951% with 20 lines in your changes missing coverage. Please review.

Project coverage is 79.02%. Comparing base (36511cd) to head (5be8884).
Report is 469 commits behind head on main.

Files with missing lines Patch % Lines
...integration-tests/cmd/exec-client/modulewrapper.go 23.52% 13 Missing ⚠️
pam/go-exec/module.c 68.18% 5 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #822      +/-   ##
==========================================
- Coverage   83.43%   79.02%   -4.42%     
==========================================
  Files          83      103      +20     
  Lines        8689    10430    +1741     
  Branches       74       75       +1     
==========================================
+ Hits         7250     8242     +992     
- Misses       1111     1724     +613     
- Partials      328      464     +136     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@3v1n0 3v1n0 force-pushed the exec-cleanups branch 5 times, most recently from e663ed8 to 6e21c34 Compare March 3, 2025 21:36
We may end up modifying it while calling `g_debug` so make sure we're
actually using the real errno on return.
3v1n0 added 3 commits March 12, 2025 17:28
We can safely call g_connection_close multiple times on a valid
connection, while we already have code handling the connection disposal
in action_module_data_cleanup().

As per this, there's no need to do the connection cleanup when the
wait-child thread is done, nor there's risk that we're accessing to a
disposed connection pointer, because at the point the wait-child thread
is running, the action-thread is waiting for it. Just before disposing
the connection.
Since the pointer is shared through different threads it's safer to
always read and set it atomically, even if there are no races here but
the API makes it more explicit.
Also no need to set the exit code in such cases, as it's just a system
failure from the PAM side.
3v1n0 added 3 commits March 12, 2025 18:47
When the child receives signals should ignore them and just return a
generic PAM system error, but still we need to check that they're
properly handled
Sadly some signals such as SIGABRT or SIGSEGV are handled by go and in
the wrong way because it never redirects them as expected, so in such
cases we just fail with a normal exit error instead of because of a
signal.

Reported this upstream and adding comments about.

See: golang/go#72084
@3v1n0 3v1n0 requested a review from adombeck March 12, 2025 18:49
@3v1n0 3v1n0 merged commit 8fb9189 into ubuntu:main Mar 14, 2025
22 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants