Skip to content
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

Quotes in pam_exec command #792

Closed
dakhnod opened this issue May 6, 2024 · 4 comments
Closed

Quotes in pam_exec command #792

dakhnod opened this issue May 6, 2024 · 4 comments

Comments

@dakhnod
Copy link

dakhnod commented May 6, 2024

I have set up this configuration line in common-auth:

auth    sufficient                      pam_exec.so debug expose_authtok seteuid /bin/bash -c 'echo "$(cat)"'

This, however, yields the error

"$(cat)"': -c: line 1: unexpected EOF while looking for matching `''

To me, it seems like some parser is getting tangled up in quotes. Does anyone have an Idea on how to solve this?

@stoeckmann
Copy link
Contributor

This should work for you:

auth    sufficient                      pam_exec.so debug expose_authtok seteuid /bin/bash -c [echo "$(cat)"]

The PAM configuration needs square brackets to take single arguments containing whitespaces, instead of single/double quotes you are used from bash.

And don't forget that stdout is required if you actually want to see something. In this case, the entered authentication token ...

@dakhnod
Copy link
Author

dakhnod commented May 9, 2024

Thanks, will try! Just out of curiosity, are those square brackets a common pattern? Why did you chose brackets over quotes?

@stoeckmann
Copy link
Contributor

I've seen this pattern when reading the code a few months ago: https://github.com/linux-pam/linux-pam/blob/master/libpam/pam_misc.c#L66

But it's also documented in pam.conf(5): https://github.com/linux-pam/linux-pam/blob/master/doc/man/pam.conf-syntax.xml#L391

@dakhnod
Copy link
Author

dakhnod commented May 10, 2024

works! thanks!

@dakhnod dakhnod closed this as completed May 10, 2024
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

No branches or pull requests

2 participants