Run the editor with the user's real and effective uid and gid.

Fixes a bug introduced in sudo 1.9.5 where the editor was run setuid
root unless SELinux RBAC was in use.
This commit is contained in:
Todd C. Miller
2021-01-11 18:41:19 -07:00
parent ea150d5918
commit 3a13f1bf0c

View File

@@ -709,8 +709,9 @@ sudo_edit(struct command_details *command_details)
nargv[ac] = NULL;
/*
* Run the editor with the invoking user's creds,
* keeping track of the time spent in the editor.
* Run the editor with the invoking user's creds and drop setuid.
* Keep track of the time spent in the editor to distinguish between
* a user editing a file and a program doing it.
* XXX - should run editor with user's context
*/
if (sudo_gettime_real(&times[0]) == -1) {
@@ -719,6 +720,8 @@ sudo_edit(struct command_details *command_details)
}
memcpy(&saved_command_details, command_details, sizeof(struct command_details));
command_details->cred = user_details.cred;
command_details->cred.euid = user_details.cred.uid;
command_details->cred.egid = user_details.cred.gid;
command_details->argv = nargv;
ret = run_command(command_details);
if (sudo_gettime_real(&times[1]) == -1) {