Question: Task 5 : Environment Variable and Set - UID Programs Set - UID is an important security mechanism in Unix operating systems. When a Set
Task : Environment Variable and SetUID Programs
SetUID is an important security mechanism in Unix operating systems. When a SetUID program
runs, it assumes the owners privileges. For example, if the programs owner is root, when anyone runs
this program, the program gains the roots privileges during its execution. SetUID allows us to do many
interesting things, but since it escalates the users privilege, it is quite risky. Although the behaviors of
SetUID programs are decided by their program logic, not by users, users can indeed affect the behav
iors via environment variables. To understand how SetUID programs are affected, let us first figure out
whether environment variables are inherited by the SetUID programs process from the users process.
Step Writethe following program that can print out all the environment variables in the current process.
#include
#include
extern char environ;
int main
int i ;
while environi NULL
printfs
environi;
i;
Step Compile the above program, change its ownership to root, and make it a SetUID program.
Assume the programs name is foo
$ sudo chown root foo
$ sudo chmod foo
Environment Variable and SetUID Program Lab
CIS
Step In your shell you need to be in a normal user account, not the root account use the export
command to set the following environment variables they may have already exist:
PATH
LD
LIBRARY
ANY
PATH
NAME this is an environment variable defined by you, so pick whatever name you want
These environment variables are set in the users shell process. Now, run the SetUID program from
Step in your shell. After you type the name of the program in your shell, the shell forks a child process,
and uses the child process to run the program. Please check whether all the environment variables you set
in the shell process parent get into the SetUID child process. Describe your observation. If there are
surprises to you, describe them.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
