Skip to content

auth_pam: pass password via PAM conversation data, remove global state#22

Merged
arkq merged 3 commits into
arkq:masterfrom
nabbi:pam_password
Jan 5, 2026
Merged

auth_pam: pass password via PAM conversation data, remove global state#22
arkq merged 3 commits into
arkq:masterfrom
nabbi:pam_password

Conversation

@nabbi

@nabbi nabbi commented Dec 28, 2025

Copy link
Copy Markdown

Stop storing the authentication password in a global variable. Instead, pass the caller-owned password buffer to the PAM conversation function via pam_conv.appdata_ptr, as intended by the PAM API.

This reduces password lifetime and scope, avoids stale or dangling global
pointers, and improves correctness and security without changing authentication behavior.

Stop storing the authentication password in a global variable. Instead,
pass the caller-owned password buffer to the PAM conversation function
via pam_conv.appdata_ptr, as intended by the PAM API.

This reduces password lifetime and scope, avoids stale or dangling
global
pointers, and improves correctness and security without changing
authentication behavior.

Signed-off-by: Nic Boet <nic@boet.cc>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the security and correctness of the PAM authentication module by eliminating global state for password storage. Instead of using a global password variable, the password is now passed directly to the PAM conversation function through the appdata_ptr field, as intended by the PAM API design.

Key changes:

  • Removed the global static const char *password variable
  • Modified the conversation function to retrieve the password from appdata_ptr parameter
  • Added NULL checking for the password with appropriate handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Repository owner deleted a comment from Copilot AI Jan 5, 2026
Repository owner deleted a comment from nabbi Jan 5, 2026

@arkq arkq left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small explanation why your reply to Copilot comment is gone:

I wanted to add small suggestion (to use ternary) to your PR by I was not able to... I thought that the problem was Copilot comment on that line so I've removed it... but it did not help, so I've pushed a commit with a suggestion manually...

Comment thread src/auth_pam.c Outdated
@arkq arkq merged commit ef652c4 into arkq:master Jan 5, 2026
4 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