PAM module to perform auth and change username

Krishna Kumar2 <[email protected]> Thu, 14 Nov 2013 15:03:42 +0530
Newsgroups gmane.linux.pam,gmane.linux.redhat.general
Message-ID <OF74CFD671.9F44302E-ON65257C23.001D73DA-65257C23.0034AE05@in.ibm.com>
Hi all,

I had a somewhat unique problem relating to PAM on a RHEL system. I hope
someone can take a look and check if there is a way to get this work.

Suppose the Linux box has a user account "A". On the console, I login with
"B",
or "C".  I have written a small PAM module that asks for a PW, and upon
some
internal authentication, it changes the PAM_NAME to "A" and returns
success.
Basically it maps multiple non-existent system logins to a single system
login.
This module is marked "sufficient" and ordered before pam_unix. Now I am
able
to login as "A", but only if "B", or "C", are present in /etc/passwd. If
they are not
present, after my module, the pam_unix module again asks for password, and
returns error at the end of the sequence.

Is it possible to login to a system with a non-existent account by
modifying the
username to a valid account in this manner?

Thanks for any help/pointers!

Regards,

- KK