Article 5K2PA Login program in C ??

Login program in C ??

by
lamonaloo2000
from LinuxQuestions.org on (#5K2PA)
HELLO sory if this Noob question. I want to create C program that is able to login into user and switch user on Linux using username and password input. Basically its a login GUI which ask for user input a string for username and password and then the program logins into the respective user. But i cant find any system calls for login, switching users or authentication. I tryed to study login.c, the source for the standard login command for GNU/Linux, but i still have no clue how it works. It seem to be even more complicated since the password is encrypted in shadow file for obvious security rasons.

One thing I think I can do is simply call the login program(which is called by getty on tty) which ask for username and pass word, using the system() function. But login command is an interactive prompt and you have to be in the shell to be able to input values for username and password. But in my case I want to be able to pass strings indirectly into the login program such as thru an input file. For example i have username and password strings and redirect that into the login program instead of answering the prompt interactively. Dunno if piping will works for login bcs it doesnt seem to be able to read from stdin. What is best approach to acomplish this in a C program ?? Is it even Posible? THANK YOU

DISTRIBUTION: Debian 10(console)
Language: C, Bashlatest?d=yIl2AUoC8zA latest?i=rRQthdDqIWA:iTB4WVHC7SY:F7zBnMy latest?i=rRQthdDqIWA:iTB4WVHC7SY:V_sGLiP latest?d=qj6IDK7rITs latest?i=rRQthdDqIWA:iTB4WVHC7SY:gIN9vFwrRQthdDqIWA
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments