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

Missing one char in pam env #34

Open
serpilliere opened this issue Jun 28, 2022 · 2 comments
Open

Missing one char in pam env #34

serpilliere opened this issue Jun 28, 2022 · 2 comments

Comments

@serpilliere
Copy link
Contributor

Hi @1wilkens !
Maybe you already know that, but in last commits you did to support the Pam Environment, there is something odd:
I have a local configuration with a krb5 pam lib, just there to add environment variable and test that.
During my login, the 'input' variable here,

pam/src/env.rs

Line 51 in 1bc5a7e

if input.is_empty() {
is this:

from ptr 0x55a35d6bfdf0
current 0x55a35d6bfdf0
input [80, 65, 77, 95, 75, 82, 66, 53, 67, 67, 78, 65, 77, 69, 61, 47, 116, 109, 112, 47, 107, 114, 98, 53, 99, 99, 95, 112, 97, 109, 95, 107, 77, 120, 101, 50, 109]

In python, this translates to this:

>>> "".join(chr(x) for x in [80, 65, 77, 95, 75, 82, 66, 53, 67, 67, 78, 65, 77, 69, 61, 47, 116, 109, 112, 47, 107, 114, 98, 53, 99, 99, 95, 112, 97, 109, 95, 107, 77, 120, 101, 50, 109])
'PAM_KRB5CCNAME=/tmp/krb5cc_pam_kMxe2m'

But the actual content of the PamEnv is this:

[2022-06-28T15:52:59Z INFO auth_pam] Env [("PAM_KRB5CCNAME=", "tmp/krb5cc_pam_kMxe2m")]

So it seems there are two strange things here:

  • shouldn't the variable name be "PAM_KRB5CCNAME" instead of "PAM_KRB5CCNAME"?
  • same, the value should be "/tmp/krb5cc_pam_kMxe2m" instead of "tmp/krb5cc_pam_kMxe2m"?
@serpilliere
Copy link
Contributor Author

Maybe this can be fixed with:

    let pos = memchr(b'=', input);
    pos.map(|p| {
        (
            OsStringExt::from_vec(input[..p].to_vec()),
            OsStringExt::from_vec(input[p + 1..].to_vec()),
        )
    })

which gives:

 Env [("PAM_KRB5CCNAME", "/tmp/krb5cc_pam_wTAqSQ")]

Do you want me to do a PR on this?

@1wilkens
Copy link
Owner

1wilkens commented Jul 5, 2022

Hey good catch, seems I messed up the indices to cut out the wrong char :) The env support is not fully up to my standards yet anyway, but I'll gladly accept a PR :)

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