From: Todd C. Miller Date: Fri, 23 Apr 2010 09:56:24 +0000 (-0400) Subject: Lock the tty timestamp when writing. We shouldn't have to lock when X-Git-Tag: SUDO_1_8_0~703 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f7f9def5ef7bf6c0d02a4d6c7c4f0402d83a4e93;p=sudo 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. --- 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); }