From f7f9def5ef7bf6c0d02a4d6c7c4f0402d83a4e93 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 23 Apr 2010 05:56:24 -0400 Subject: [PATCH] Lock the tty timestamp when writing. We shouldn't have to lock when reading since the file is updated via a single write system call. --- plugins/sudoers/check.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/sudoers/check.c b/plugins/sudoers/check.c index 1e6d4c2c3..7ad06eeac 100644 --- a/plugins/sudoers/check.c +++ b/plugins/sudoers/check.c @@ -230,10 +230,11 @@ update_timestamp(char *timestampdir, char *timestampfile) /* * Store tty info in timestamp file */ - int fd = open(timestampfile, O_WRONLY|O_CREAT|O_TRUNC, 0600); + int fd = open(timestampfile, O_WRONLY|O_CREAT, 0600); if (fd == -1) log_error(NO_EXIT|USE_ERRNO, "Can't open %s", timestampfile); else { + lock_file(fd, SUDO_LOCK); write(fd, &tty_info, sizeof(tty_info)); close(fd); } -- 2.40.0