4

I would to like to validate a username and password correspond to a valid unix account.

The current solution I have uses expect to wait for a password prompt and then supply the password and see if the login succeeds.

Is there a kernel API or a user space function that can validate a login / password.

I guess part of my confusion is I am not sure if this is a kernel space service?

3 Answers 3

4

You should use pam. On debian/ubuntu you can:

apt-get install python-pam

Simple code in python pamtest.py:

See the /usr/share/doc/python-pam/examples/pamtest.py file. It's really short and does what you want.

To test it, run:

python /usr/share/doc/python-pam/examples/pamtest.py

There is also an example in C pamexample.c.

To test it:

gcc /usr/share/doc/python-pam/examples/pamexample.c -lpam -l pam_misc
./pam_misc theuser
1
  • The links in this answer seam to be dead..
    – comfreak
    Feb 8 at 21:32
3

It's strictly user-space.

2

to check if a user credentials are good you can try logging as him:

su - username

But reading about PAM may be a better route in the long term

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .