Skip to content

Authentication only works for the user python is running as in Ubuntu Precise (vagrant VM) #2

@usernamenumber

Description

@usernamenumber

This may be due to something in my PAM config, but since as far as I know I'm using the default setup for Ubuntu Precise (I'm in a VM with Vagrant's default image for that OS), it seems worth posting here either way...

I am finding that python-pam can only successfully authenticate the user that python is running as. To illustrate, I created a testuser account, and can authenticate it when logged in as that user:

$ id
uid=1022(testuser) gid=1024(testuser) groups=1024(testuser)

$ python
Python 2.7.3 (default, Feb 27 2014, 19:58:35)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pam
>>> p = pam.pam()
>>> p.authenticate('testuser','testpw')
True

...but if I log in as another user and try the same thing, it fails:

$ id
uid=1000(vagrant) gid=1000(vagrant) groups=1000(vagrant),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),110(sambashare),999(admin)

$ python
Python 2.7.3 (default, Feb 27 2014, 19:58:35)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pam
>>> p = pam.pam()
>>> p.authenticate('testuser','testpw')
False

Similarly, authenticating vagrant suceeds when logged in as vagrant, and fails when logged in as testuser .

If I log in as vagrant but start python with sudo -u testuser python, I go back to being able to authenticate testuser, but not vagrant.

Here's what I see in my auth.log when authentication fails (in this case, authenticating testuser while logged in as vagrant):

Jan  6 18:26:59 precise64 unix_chkpwd[19889]: check pass; user unknown
Jan  6 18:26:59 precise64 unix_chkpwd[19889]: password check failed for user (testuser)
Jan  6 18:26:59 precise64 python: pam_unix(login:auth): authentication failure; logname= uid=1000 euid=1000 tty= ruser= rhost=  user=testuser

Maybe unrelated, but I also see an error (and nothing else) on successful authentication:

Jan  6 18:27:54 precise64 python: pam_group(login:setcred): unable to set the group membership for user: Operation not permitted

Any idea what the problem might be?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions