Don't write an empty timestamp record when timestamp_timeout is
zero. If we find an empty record in the timestamp file, overwrite it with a good one, truncating the file as needed.
This commit is contained in:
@@ -119,11 +119,13 @@ ts_find_record(int fd, struct timestamp_entry *key, struct timestamp_entry *entr
|
|||||||
*/
|
*/
|
||||||
while (read(fd, &cur, sizeof(cur)) == sizeof(cur)) {
|
while (read(fd, &cur, sizeof(cur)) == sizeof(cur)) {
|
||||||
if (cur.size != sizeof(cur)) {
|
if (cur.size != sizeof(cur)) {
|
||||||
/* wrong size, seek to next record */
|
/* wrong size, seek to start of next record */
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
|
||||||
"wrong sized record, got %hu, expected %zu",
|
"wrong sized record, got %hu, expected %zu",
|
||||||
cur.size, sizeof(cur));
|
cur.size, sizeof(cur));
|
||||||
lseek(fd, (off_t)cur.size - (off_t)sizeof(cur), SEEK_CUR);
|
lseek(fd, (off_t)cur.size - (off_t)sizeof(cur), SEEK_CUR);
|
||||||
|
if (cur.size == 0)
|
||||||
|
break; /* size must be non-zero */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ts_match_record(key, &cur)) {
|
if (ts_match_record(key, &cur)) {
|
||||||
@@ -327,6 +329,10 @@ update_timestamp(struct passwd *pw)
|
|||||||
int fd;
|
int fd;
|
||||||
debug_decl(update_timestamp, SUDO_DEBUG_AUTH)
|
debug_decl(update_timestamp, SUDO_DEBUG_AUTH)
|
||||||
|
|
||||||
|
/* Zero timeout means don't update the time stamp file. */
|
||||||
|
if (def_timestamp_timeout == 0)
|
||||||
|
goto done;
|
||||||
|
|
||||||
/* Check/create parent directories as needed. */
|
/* Check/create parent directories as needed. */
|
||||||
if (!ts_secure_dir(def_timestampdir, true, false))
|
if (!ts_secure_dir(def_timestampdir, true, false))
|
||||||
goto done;
|
goto done;
|
||||||
|
Reference in New Issue
Block a user