No Description

Marina Barsky 92bedf84a5 added makefile 2 years ago
.gitignore 26a0fb229d Initial commit 2 years ago
LICENSE 26a0fb229d Initial commit 2 years ago
Makefile 92bedf84a5 added makefile 2 years ago
README.md c5b2117c5e Update 'README.md' 2 years ago
checkpasswd.c 7f4feefd46 added checkpasswd.c starter 2 years ago
pass.txt 6f79d281bf added pass.txt 2 years ago
validate.c 3cebab11c2 added validate.c 2 years ago

README.md

Pipe Lab

Exercise 23

Introduction

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.

Finally

Add the following file:

  • checkpasswd.c

Commit, and push.