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

keymaker-create-account-for-iam-user path incompatible with pam.d/sshd config #56

Closed
thisdougb opened this issue Jun 12, 2019 · 2 comments

Comments

@thisdougb
Copy link

thisdougb commented Jun 12, 2019

I am using the AWS AMI ami-0fbac225f3afdf632 (eu-central-1, Amazon Linux 2, ECS optimised, etc). The file keymaker-create-account-for-iam-user is installed in /usr/bin by pip. However the pam.d/sshd configuration created by Keymaker (pam_config_line) looks for it in /usr/local/bin.

Workaround is a symlink, created after installing Keymaker:

# yum install -y python2-pip 
# pip install keymaker
# keymaker install
# type keymaker-create-account-for-iam-user 
keymaker-create-account-for-iam-user is /usr/bin/keymaker-create-account-for-iam-user
# ln -s /usr/bin/keymaker-create-account-for-iam-user /usr/local/bin/keymaker-create-account-for-iam-user

but out of the box it's not working.

@kislyuk
Copy link
Owner

kislyuk commented Jun 12, 2019

Thanks for reporting! Yes, this is definitely a bug. /usr/local/bin should not be hardcoded but instead inferred at install time.

@thisdougb
Copy link
Author

thisdougb commented Jun 14, 2019

@kislyuk want me to do a PR, a function along these lines? There's two places the '/usr/local/bin' is hardcoded.

import os

def get_absolute_path(target_file):
    if 'PATH' in os.environ:
      for p in os.environ['PATH'].split(':'):
        test_path = "{0}/{1}".format(p, target_file)
        if os.path.isfile(test_path):
          absolute_path = os.path.abspath(test_path)
          return absolute_path

    return None

keymaker_create_account_path = get_absolute_path("keymaker-create-account-for-iam-user")
if keymaker_create_account_path:
    pam_config_line = "auth optional pam_exec.so stdout {0}".format(keymaker_create_account_path)
else:
    print("error: keymaker-create-account-for-iam-user missing")
    # err_exit()

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