How do I drop all elevated privileges through the terminal?

I did some authentication mounting where I added code like timestamp_timeout on sudoer.

This setting will effect every mounting, where you must enter the user password. After entering the password correctly, an indicator is shown, with an option to "Drop all elevated privileges".

How do I drop elevated privileges using the terminal (CLI)?


Solution 1:

I'm not quite sure I understood your question right. Could you clarify whether you have access to the console that granted the right to mount?

sudo privileges can be revoked with -k and -K switches.

Quoting man sudo:

-K The -K (sure kill) option is like -k except that it removes the user's timestamp entirely and may not be used in conjunction with a command or other option. This option does not require a password.

-k When used by itself, the -k (kill) option to sudo invalidates the user's timestamp by setting the time on it to the Epoch. The next time sudo is run a password will be required. This option does not require a password and was added to allow a user to revoke sudo permissions from a .logout file.

This won't work with gksudo.

Solution 2:

exec su -l dmendeleev

Where dmendeleev is the username that you what to drop to.

This will replace the current process with a new shell and set the process uid, gid, euid, and egid to non-root.