CSCI 311 Test 2 Spring 2016


  1. Passwords and the Password File.
    1. [3 points] Describe how passwords are stored on a linux system.
      • Location
      • Format
    2. [5 points] How can a programmer verify a user's password is correct? Assume that the user has been prompted for, and has typed in their clear text password. Further assume that the user is running the process. Your discussion should include pseudo code to accomplish this task, including system calls. You do not need to worry about the parameters or return values of the system calls.
    3. [2 points] You are the administrator of a linux system and a user approaches you to help with a lost password. They demand you provide the clear text version of their password. How do you respond this request (avoiding conflict)?
  2. File Information

    The stat family of functions returns information about a file.

    1. [2 points] This does not include the file name, Why?
    2. [3 points] This does include mode_t st_mode that contains the file type and file permissions
      • Give a likely basic C/C++ type for mode_t
      • Describe how information relating to the file is extracted from this data. You need not give specific code/functions/macros/..., but describe the process.
  3. [5 points] Describe the actions performed by the symlink(const char * filepath, const char * linkpath); system call. This discussion should clearly indicate the material covered in this class (ie "It makes a symbolic link" is insufficient).
  4. Signal Basics
    1. [2 points] What is a signal? (What sends and what receives a signal?)
    2. [2 points] Name or describe and discuss two signals.
    3. [2 points] What are two possible default actions for signals?
    4. [2 points] What is a signal handler
    5. [2 points] If a process receives a signal, for which a signal handler has been registered, what happens?
  5. [10 points] The library function system(const char* command) will attempt to invokes the command processor to execute a command. The return value for this library function is the return value of the command if the command is not NULL. How could this library function be implemented? Your discussion should include pseudo code to accomplish this task, including system calls. You do not need to worry about the parameters or return values of the system calls.
  6. Pipes
    1. [2 points] What does the system call pipe(int filedes[2]) do?
    2. [2 points] What is required for two processes to communicate via a pipe?
    3. [6 points] Provide pseudo code for how a shell might implement the command cmd1 | cmd2. Assume cmd1 and cmd2 are strings containing the information needed for a call to execv. (You may ignore arguments)