Lab 8 Solution

$29.99 $18.99

In an application that requires a user to login, the application must be able to read in a user id and password, and validate it to determine whether the login is successful. One approach to validation is to hand the task off to a separate process. In this lab, you are given a program that…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

Rate this product

In an application that requires a user to login, the application must be able to read in a user id and password, and validate it to determine whether the login is successful. One approach to validation is to hand the task off to a separate process.

In this lab, you are given a program that validates user id and passwords, and will apply what you’ve learned about processes and pipes to create a program that runs this validation program in a child process and reports the result of the validation.

validate

You can find the code for the validation program used for this lab in validate.c . 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. You are also given a sample file containing user ids and password combinations, which is used by validate .

After reading the comments at the top of validate.c , you will want to compile it and try running validate directly first.

How many bytes does validate expect to read in each read call? Does it require the input to be null-terminated? What happens in each case?

Notice that this program doesn’t print any output; the only information it provides comes in the exit code of the program.

Use the shell variable $? to refer to the exit code of the last process run (e.g., by running echo $? ).

NOTE: You may not change the validate program.

Your task is to complete checkpasswd.c , which reads a user id and password from stdin , creates a new process to run the validate program, sends it the user id and password, and prints a message to stdout reporting whether the validation is successful.

Your program should use the exit status of the validate program to determine which of the three following messages to print:

Password verified” if the user id and password match.

Invalid password” if the user id exists, but the password does not match.

No such user” if the user id is not recognized

Lab 8 https://q.utoronto.ca/courses/68725/assignments/113163

2页 共2 2019/3/23 14:09