9f5db7
diff -up ./src/copy_file.c.symbolic-link-attack-5 ./src/copy_file.c
9f5db7
--- ./src/copy_file.c.symbolic-link-attack-5	2021-02-02 17:18:05.355567274 +0100
9f5db7
+++ ./src/copy_file.c	2021-02-02 17:19:09.904671563 +0100
9f5db7
@@ -128,7 +128,6 @@ write_error:
9f5db7
     }
9f5db7
 }
9f5db7
 
9f5db7
-#ifdef HAVE_SELINUX
9f5db7
 bool
9f5db7
 sudo_check_temp_file(int tfd, const char *tfile, uid_t uid, struct stat *sb)
9f5db7
 {
9f5db7
@@ -158,4 +157,3 @@ sudo_check_temp_file(int tfd, const char
9f5db7
     }
9f5db7
     debug_return_bool(true);
9f5db7
 }
9f5db7
-#endif /* SELINUX */
9f5db7
diff -up ./src/sudo_edit.c.symbolic-link-attack-5 ./src/sudo_edit.c
9f5db7
--- ./src/sudo_edit.c.symbolic-link-attack-5	2021-02-02 17:18:05.355567274 +0100
9f5db7
+++ ./src/sudo_edit.c	2021-02-02 17:18:05.356567260 +0100
9f5db7
@@ -692,24 +692,17 @@ sudo_edit_copy_tfiles(struct command_det
9f5db7
 
9f5db7
     /* Copy contents of temp files to real ones. */
9f5db7
     for (i = 0; i < nfiles; i++) {
9f5db7
-	int rc = -1;
9f5db7
 	sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
9f5db7
 	    "seteuid(%u)", (unsigned int)user_details.uid);
9f5db7
 	if (seteuid(user_details.uid) != 0)
9f5db7
 	    sudo_fatal("seteuid(%u)", (unsigned int)user_details.uid);
9f5db7
 	tfd = sudo_edit_open(tf[i].tfile, O_RDONLY,
9f5db7
 	    S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, NULL);
9f5db7
-	if (tfd != -1)
9f5db7
-	    rc = fstat(tfd, &sb);
9f5db7
-	sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
9f5db7
-	    "seteuid(%u)", ROOT_UID);
9f5db7
 	if (seteuid(ROOT_UID) != 0)
9f5db7
 	    sudo_fatal("seteuid(ROOT_UID)");
9f5db7
-	if (rc == -1 || !S_ISREG(sb.st_mode)) {
9f5db7
-	    if (rc == -1)
9f5db7
-		sudo_warn("%s", tf[i].tfile);
9f5db7
-	    else
9f5db7
-		sudo_warnx(U_("%s: not a regular file"), tf[i].tfile);
9f5db7
+	sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
9f5db7
+	    "seteuid(%u)", ROOT_UID);
9f5db7
+	if (tfd == -1 || !sudo_check_temp_file(tfd, tf[i].tfile, user_details.uid, &sb)) {
9f5db7
 	    sudo_warnx(U_("%s left unmodified"), tf[i].ofile);
9f5db7
 	    if (tfd != -1)
9f5db7
 		close(tfd);