Question: Note: dont run the code give me answer the Question 1 and Question 2 mention in the given behaviour and answers should be 5 to

Note: dont run the code give me answer the Question 1 and Question 2 mention in the given behaviour and answers should be 5 to 7 according to the given scenario plz.

Question1: You should be able to observe two different behaviours in the scenarios described above, even though you are running the same program. Note the different behaviours of the 4 programs here?

Qustuon 2:Explain why the behaviours in the four different programs in Step 2 are different.?

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

1. We will now build a dynamic link library. Create the program as shown in Code Listing 6, and name it mylib.c.

If we run a program that uses our dynamically linked library it will override the default sleep() function in libc and print our text out instead:

#include <stdio.h>

void sleep (int s)

{

/* If this is invoked by a privileged program, you can do damage here! */ printf("I am not sleeping! "); }

Code Listing 6: Dynamic library - sleep() call

2. We can compile the above program using the following commands (in the -lc argument, the second character is a lower case L not a 1/one):

$ 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 so that the system knows about out dynamic link library:

$ export LD_PRELOAD=./libmylib.so.1.0.1

4. Finally, compile the program in Code Listing 7 and call it task8.c. Ensure that it is in the same directory as the above dynamic link library libmylib.so.1.0.1:

/* task8.c */

int main()

{ sleep(1); return 0;

}

Code Listing 7: Program to invoke sleep() system call.

5. Make four copies of the executable. Call them task8-a, task8-b, task8-c, and task8-d

Step 2. After you have done the above, please run the task8 executables under the following conditions, and observe what happens. (NOTE: pay close attention to the instructions!). If the program picks up our dynamic library, it should print our text. If it uses the default system sleep() library, then it will sleep for 1 second and return the CLI prompt without printing anything.

1. Leave task8-a as normal program and run it as the normal uwe user.

2. Change task8-b so that it is a root owned, Set-UIDprogram (Use chown and chmod), and run it as the uweuser.

3. Change task8-c so that it is a ubuntu owned, Set-UIDprogram. (ubuntu is another user that is already present in this VM). Run this program as the uwe user.

4. Change task8-d so that it is a root owned, Set-UIDprogram. Change the shell to the root account using the command sudo su. We are now running this program as the root user in the root account.

Export the LD_PRELOAD environment variable again in the root account and run the task8-d program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!