Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 7:(Please explain how to Set-UID in Detail. attach the code. also how to create the user1(all steps)) The LD PRELOAD environment variable and Set-UID

Task 7:(Please explain how to Set-UID in Detail. attach the code. also how to create the user1(all steps))

The LD PRELOAD environment variable and Set-UID Programs In this task, we study how Set-UID programs deal with some of the environment variables. Several en- vironment variables, including LD PRELOAD, LD LIBRARY PATH, and other LD * influence the behavior of dynamic loader/linker. A dynamic loader/linker is the part of an operating system (OS) that loads (from persistent storage to RAM) and links the shared libraries needed by an executable at run time. In Linux, ld.so or ld-linux.so, are the dynamic loader/linker (each for different types of binary). Among the environment variables that affect their behaviors, LD LIBRARY PATH and LD PRELOAD are the two that we are concered in this lab. In Linux, LD LIBRARY PATH is a colon-separated set of directories where libraries should be searched for first, before the standard set of directories. LD PRELOAD specifies a list of additional, user-specified, shared libraries to be loaded before all others. In this task, we will only study LD PRELOAD.

Step 1. First, we will see how these environment variables influence the behavior of dynamic loader/linker when running a normal program. Please follow these steps:

1. Let us build a dynamic link library. Create the following program, and name it mylib.c. It basically overrides the sleep() function in libc:

#include

void sleep (int s)

{

/* If this is invoked by a privileged program, you can do damages here! */

printf("I am not sleeping! ");

}

2. We can compile the above program using the following commands (in the -lc argment, the second character is l):

% gcc -fPIC -g -c mylib.c

% gcc -shared -o libmylib.so.1.0.1 mylib.o -lc

3. Now, set the LD PRELOAD environment variable:

% export LD_PRELOAD=./libmylib.so.1.0.1 4.

Finally, compile the following program myprog, and it in the same directory as the above dynamic link library libmylib.so.1.0.1:

/* myprog.c */

int main()

{

sleep(1);

return 0;

}

step2. After you have done the above, please run myprog under the following conditions, and observe what happens.

Make myprog a regular program, and run it as a normal user.

Make myprog a Set-UID root program, and run it as a normal user.

Make myprog a Set-UID root program, export the LD PRELOAD environment variable again in the root account and run it.

Make myprog a Set-UID user1 program (i.e., the owner is user1, which is another user account), export the LD PRELOAD environment variable again in a different users account (not-root user) and run it.

Step 3. You should be able to observe different behaviors in the scenarios described above, even though you are running the same program. You need to figure out what causes the difference. Environment variables play a role here. Please design an experiment to figure out the main causes, and explain why the behaviors in Step 2 are different. (Hint: the child process may not inherit the LD * environment variables).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data In Just 7 Chapters

Authors: Prof Marcus Vinicius Pinto

1st Edition

B09NZ7ZX72, 979-8787954036

More Books

Students also viewed these Databases questions

Question

what are the provisions in the absence of Partnership Deed?

Answered: 1 week ago

Question

1. What is called precipitation?

Answered: 1 week ago

Question

1.what is dew ?

Answered: 1 week ago

Question

explain the need for human resource strategies in organisations

Answered: 1 week ago

Question

describe the stages involved in human resource planning

Answered: 1 week ago