the likelihood of a time stamp record being re-used when a user
logs out and back in again. Bug #818.
+ * The "timestamp_type" option now takes a "kernel" value on OpenBSD
+ systems. This causes the tty-based time stamp to be stored in
+ the kernel instead of on the file system. If no tty is present,
+ the time stamp is considered to be invalid.
+
What's new in Sudo 1.8.21p2
* Fixed a bug introduced in version 1.8.21 which prevented sudo
will not require a password for
_\bt_\bi_\bm_\be_\bs_\bt_\ba_\bm_\bp_\b__\bt_\bi_\bm_\be_\bo_\bu_\bt minutes (5 by default).
+ kernel The time stamp is stored in the kernel as an
+ attribute of the terminal device. If no
+ terminal is present, the time stamp is
+ considered to be invalid. This is currently
+ only supported on OpenBSD.
+
The default value is _\bt_\bt_\by.
This setting is only supported by version 1.8.21 or
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
+#include <sys/ioctl.h>
#include <stdio.h>
#include <stdlib.h>
#if defined(HAVE_STDINT_H)
goto bad;
}
+ if (def_timestamp_type == kernel) {
+ fd = open(_PATH_TTY, O_RDWR);
+ if (fd == -1)
+ goto bad;
+ goto done;
+ }
+
/* Sanity check timestamp dir and create if missing. */
if (!ts_secure_dir(def_timestampdir, true, false))
goto bad;
break;
}
+done:
/* Allocate and fill in cookie to store state. */
cookie = malloc(sizeof(*cookie));
if (cookie == NULL) {
debug_return_bool(false);
}
+ if (def_timestamp_type == kernel) {
+ cookie->pos = 0;
+ debug_return_bool(true);
+ }
+
/*
* Take a lock on the "write" record (the first record in the file).
* This will let us seek for the record or extend as needed
goto done;
}
+ if (def_timestamp_type == kernel) {
+#ifdef TIOCCHKVERAUTH
+ int fd = open(_PATH_TTY, O_RDWR);
+ if (fd == -1)
+ goto done;
+ if (ioctl(fd, TIOCCHKVERAUTH) == 0)
+ status = TS_CURRENT;
+ else
+ status = TS_OLD;
+ close(fd);
+#endif
+ goto done;
+ }
+
/* Read the record at the correct position. */
if ((nread = ts_read(cookie, &entry)) != sizeof(entry))
goto done;
goto done;
}
+ if (def_timestamp_type == kernel) {
+#ifdef TIOCSETVERAUTH
+ int fd = open(_PATH_TTY, O_RDWR);
+ if (fd != -1) {
+ int secs = 60 * def_timestamp_timeout;
+ ioctl(fd, TIOCSETVERAUTH, &secs);
+ close(fd);
+ }
+#endif
+ goto done;
+ }
+
/* Update timestamp in key and enable it. */
CLR(cookie->key.flags, TS_DISABLED);
if (sudo_gettime_mono(&cookie->key.ts) == -1) {
char *fname = NULL;
debug_decl(timestamp_remove, SUDOERS_DEBUG_AUTH)
+ if (def_timestamp_type == kernel) {
+#ifdef TIOCCLRVERAUTH
+ fd = open(_PATH_TTY, O_RDWR);
+ if (fd == -1)
+ ret = -1;
+ else
+ ioctl(fd, TIOCCLRVERAUTH);
+#endif
+ goto done;
+ }
+
if (asprintf(&fname, "%s/%s", def_timestampdir, user_name) == -1) {
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
ret = -1;