Multiple choice technology security

A program wants to do some activities with root privileges when it starts up and shuts down. Other activities it does can be done as a lesser privileged user. Which of the options given below is most secure?

  1. The program should be started with root privileges. Then it should use setuid(UID) to change privileges between root and another account.

  2. The program should be started with root privileges. Then it should use seteuid(UID) to change privileges between root and another account.

  3. Starting the program as root is a security risk. The program should run with least privileges and obtain root using seteuid(UID) whenever necessary.

  4. The program has to run with root privileges entirely. Once root privileges are dropped they cannot be regained.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The 'seteuid' (set effective user ID) function is more secure for temporary privilege escalation. It allows a process to switch its effective privileges to root to perform specific tasks and then switch back to a lesser privileged UID, following the principle of least privilege.