Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Note: No need to the run the code plz just give me answer of the question related to given scenrio answer should be 5 to

Note: No need to the run the code plz just give me answer of the question related to given scenrio answer should be 5 to 6 lines.thanks

Question: Will the file /etc/uwe be modified? Please explain your observation as to why or why not the file is able to be modified.

#include stdio.h>

#include stdlib.h> #include fcntl.h>

#include unistd.h>

void main()

{ int fd;

/* Assume that /etc/uwe is an important system file,

* and it is owned by root with permission 0644.
* Before running this program, you should create
* the file /etc/uwe first. */ fd = open("/etc/uwe", O_RDWR | O_APPEND); if (fd == -1) { printf("Cannot open /etc/uwe "); exit(0);

}

/* Simulate the tasks conducted by the program */ sleep(1);

/* After the task, the root privileges are no longer

* needed, its time to relinquish the root privileges
* permanently. */

setuid(getuid()); /* getuid() returns the real uid */

if (fork()) { /* In the parent process */ close (fd); exit(0);

} else { /* in the child process */

/* Now, assume that the child process is compromised,

* malicious attackers have injected the following
* statements into this process */ write (fd, "Malicious Data ", 15); close (fd);

}

}

image text in transcribed
To follow the Principle of Least Privilege, Set-UID programs often permanently relinquish their root privileges if such privileges are not needed anymore. Moreover, sometimes, the program needs to hand over its control to the user, in this case, root privileges must be revoked. The setuid() system call can be used to revoke the privileges. According to the manual, setuid() sets the effective user ID of the calling process. If the effective UID of the caller is root, the real UID and saved set-user-ID are also set". Therefore, if a Set-UID program with effective UID O calls setuid (n), the process will become a normal process, with all its UIDs being set to n. When revoking the privilege, one of the common mistakes is capability leaking. The process may have gained some privileged capabilities when it was still privileged; when the privilege is downgraded, if the program does not clean up those capabilities, they may still be accessible by the non-privileged process. In other words, although the effective user ID of the process becomes nonprivileged, the process is still privileged because it possesses privileged capabilities. Compile the program in Code Listing 9, change its owner to root, and make it a Set-UID program. Run the program as the uwe user and describe what you have observed. Before running this program, you should create the file /etc/uwe file first. $ sudo touch /etc/uwe $ sudo chmod 644 /etc/uwe Question: Will the file /etc/uwe be modified? Please explain your observation as to why or why not the file is able to be modified include catdio.h> include tanclude include void main() Lint idi Assume that lete/uwe la an important system file, and it is owned by root with permission 0644. Before running this program, you should create the file /etc/uwe first. Id open(/etc/uwe" O_RDWR 1 O_APPEND): 16 --1) print(Cannot open /etc/uwen"); exit(0)

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_2

Step: 3

blur-text-image_3

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

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago