In sudoedit, use sudo_check_temp_file() for non-SELinux too.
This commit is contained in:
@@ -137,7 +137,6 @@ write_error:
|
|||||||
debug_return_int(-1);
|
debug_return_int(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SELINUX
|
|
||||||
bool
|
bool
|
||||||
sudo_check_temp_file(int tfd, const char *tfile, uid_t uid, struct stat *sb)
|
sudo_check_temp_file(int tfd, const char *tfile, uid_t uid, struct stat *sb)
|
||||||
{
|
{
|
||||||
@@ -166,4 +165,3 @@ sudo_check_temp_file(int tfd, const char *tfile, uid_t uid, struct stat *sb)
|
|||||||
}
|
}
|
||||||
debug_return_bool(true);
|
debug_return_bool(true);
|
||||||
}
|
}
|
||||||
#endif /* SELINUX */
|
|
||||||
|
@@ -667,24 +667,17 @@ sudo_edit_copy_tfiles(struct command_details *command_details,
|
|||||||
|
|
||||||
/* Copy contents of temp files to real ones. */
|
/* Copy contents of temp files to real ones. */
|
||||||
for (i = 0; i < nfiles; i++) {
|
for (i = 0; i < nfiles; i++) {
|
||||||
int rc = -1;
|
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
|
||||||
"seteuid(%u)", (unsigned int)user_details.uid);
|
"seteuid(%u)", (unsigned int)user_details.uid);
|
||||||
if (seteuid(user_details.uid) != 0)
|
if (seteuid(user_details.uid) != 0)
|
||||||
sudo_fatal("seteuid(%u)", (unsigned int)user_details.uid);
|
sudo_fatal("seteuid(%u)", (unsigned int)user_details.uid);
|
||||||
tfd = sudo_edit_open(tf[i].tfile, O_RDONLY,
|
tfd = sudo_edit_open(tf[i].tfile, O_RDONLY,
|
||||||
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, NULL);
|
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, NULL);
|
||||||
if (tfd != -1)
|
|
||||||
rc = fstat(tfd, &sb);
|
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
|
|
||||||
"seteuid(%u)", ROOT_UID);
|
|
||||||
if (seteuid(ROOT_UID) != 0)
|
if (seteuid(ROOT_UID) != 0)
|
||||||
sudo_fatal("seteuid(ROOT_UID)");
|
sudo_fatal("seteuid(ROOT_UID)");
|
||||||
if (rc == -1 || !S_ISREG(sb.st_mode)) {
|
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
|
||||||
if (rc == -1)
|
"seteuid(%u)", ROOT_UID);
|
||||||
sudo_warn("%s", tf[i].tfile);
|
if (tfd == -1 || !sudo_check_temp_file(tfd, tf[i].tfile, user_details.uid, &sb)) {
|
||||||
else
|
|
||||||
sudo_warnx(U_("%s: not a regular file"), tf[i].tfile);
|
|
||||||
sudo_warnx(U_("%s left unmodified"), tf[i].ofile);
|
sudo_warnx(U_("%s left unmodified"), tf[i].ofile);
|
||||||
if (tfd != -1)
|
if (tfd != -1)
|
||||||
close(tfd);
|
close(tfd);
|
||||||
|
Reference in New Issue
Block a user