|Marina Barsky 92bedf84a5 added makefile||2 years ago|
|.gitignore||2 years ago|
|LICENSE||2 years ago|
|Makefile||2 years ago|
|README.md||2 years ago|
|checkpasswd.c||2 years ago|
|pass.txt||2 years ago|
|validate.c||2 years ago|
In a web application that requires a user to login, the user id and password must be validated. One approach to validation is to hand the task off to a separate process. In our case, the program run by the new process is called validate. The validate program reads the user id and password from stdin, because if they were given as command-line arguments they would be visible to programs such as ps that inspect the state of the system. The validate program is given to you in validate.c.
Complete checkpasswd.c that reads a user id and password, creates a new process to run the validate program (found in validate.c), sends it the user id and password, and prints a message "Password verified" if the user id and password matched or either "Invalid password" or "No such user" depending on the return value of the validate program. A sample password file "pass.txt" is provided.
You will find the following system calls useful: fork, exec, pipe, dup2, write, wait (along with WIFEXITED, WEXITSTATUS). A simple Makefile is provided to compile the programs. You may not use popen or pclose in your solution.
Hint: After reading the comments at the top of validate.c, you will want to compile it and you may want to try running it directly. Notice that validate doesn't print any output. The only information it provides comes in the return value of the program. The shell variable $? holds the return value of the last process. That means that from the bash prompt, you can type echo $? to see the return value of the program.
Add the following file:
Commit, and push.