master
xv6 branch from the class repository.
root 0 user1 1 user2 2 ...Here, the first line (root 1) is mandatory. For the purpose of this homework, there is no need to actually check the password. Ask for a username and password, and simply verify that the user name is valid.
exit
command to sh
to take the user back to the login prompt. The most straightforward design here is to have login fork
before running sh
, then wait
for sh
to finish before presenting another login prompt.
struct proc
to track the user responsible for each process, and update xv6 so that this field contains the correct value. The login
program should run as user root
.
You will need to introduce a system call setuid()
to allow login to change identity from root
to the appropriate user after a successful login. Important: only root may use the setuid()
system call. Hence, if the user id in struct proc
is not 0, setuid()
should return an error and not change the user id.
Note that multiple users may be running processes simultaneously, and conceptually also be logged in simultaneously (though we only have a single console at this point). Hence, you can't use globals to track which user is logged in.
struct inode
to indicate the owner of the file. Add a system call chown(path,userid)
for changing the owner of a file.
sudo
command which allows the user to execute programs as superuser, assuming they have the appropriate permissions. For this homework, we will simplify this, and there are no permissions checked - if a user runs "sudo", we pretend they have the correct permissions and proceed with executing the remainder of the command as root
.
Interestingly, since only processes running as root
may change their user id, it is not (currently) possible for sudo
to change id to root. To make this possible, add another field to struct inode
: setuid_allowed
. If setuid_allowed=1
, then this particular program may use setuid
even if it is not running as root. Introduce a new system call allow_setuid(path, yesorno)
to modify this field. For this to be safe, only programs running as root
may use allow_setuid
. Create a binary called enablesetuid
that uses the system call.
Finally, create the sudo
program, which runs the specified command as root. Use enablesetuid
when logged in as root to allow sudo
to do this, then test it when logged in as a regular user. Copyright 2016 The Board of Trustees of the University of Illinois.webmaster@cs.uic.edu |
WISEST Helping Women Faculty Advance Funded by NSF | ![]() | ![]() |