* If the file/dir exists, check its mtime.
*/
if (status == TS_OLD) {
- now = time(NULL);
- if (def_ival(I_TIMESTAMP_TIMEOUT) &&
- now - sb.st_mtime < 60 * def_ival(I_TIMESTAMP_TIMEOUT)) {
- /*
- * Check for bogus time on the stampfile. The clock may
- * have been set back or someone could be trying to spoof us.
- */
- if (sb.st_mtime > now + 60 * def_ival(I_TIMESTAMP_TIMEOUT) * 2) {
- log_error(NO_EXIT,
- "timestamp too far in the future: %20.20s",
- 4 + ctime(&sb.st_mtime));
- if (timestampfile)
- (void) unlink(timestampfile);
- else
- (void) rmdir(timestampdir);
- status = TS_MISSING;
- } else
- status = TS_CURRENT;
+ /* Negative timeouts only expire manually (sudo -k). */
+ if (def_ival(I_TS_TIMEOUT) < 0 && sb.st_mtime != 0)
+ status = TS_CURRENT;
+ else {
+ now = time(NULL);
+ if (def_ival(I_TIMESTAMP_TIMEOUT) &&
+ now - sb.st_mtime < 60 * def_ival(I_TIMESTAMP_TIMEOUT)) {
+ /*
+ * Check for bogus time on the stampfile. The clock may
+ * have been set back or someone could be trying to spoof us.
+ */
+ if (sb.st_mtime > now + 60 * def_ival(I_TIMESTAMP_TIMEOUT) * 2) {
+ log_error(NO_EXIT,
+ "timestamp too far in the future: %20.20s",
+ 4 + ctime(&sb.st_mtime));
+ if (timestampfile)
+ (void) unlink(timestampfile);
+ else
+ (void) rmdir(timestampdir);
+ status = TS_MISSING;
+ } else
+ status = TS_CURRENT;
+ }
}
}
* Local prototypes.
*/
static int store_int __P((char *, struct sudo_defs_types *, int));
+static int store_uint __P((char *, struct sudo_defs_types *, int));
static int store_str __P((char *, struct sudo_defs_types *, int));
static int store_syslogfac __P((char *, struct sudo_defs_types *, int));
static int store_syslogpri __P((char *, struct sudo_defs_types *, int));
putchar('\n');
}
break;
+ case T_UINT:
case T_INT:
(void) printf(cur->desc, cur->sd_un.ival);
putchar('\n');
return(FALSE);
}
break;
+ case T_UINT:
+ if (!val) {
+ /* Check for bogus boolean usage or lack of a value. */
+ if (!(cur->type & T_BOOL) || op != FALSE) {
+ (void) fprintf(stderr,
+ "%s: no value specified for `%s' on line %d\n", Argv[0],
+ var, sudolineno);
+ return(FALSE);
+ }
+ }
+ if (!store_uint(val, cur, op)) {
+ (void) fprintf(stderr,
+ "%s: value '%s' is invalid for option '%s'\n", Argv[0],
+ val, var);
+ return(FALSE);
+ }
+ break;
case T_MODE:
if (!val) {
/* Check for bogus boolean usage or lack of a value. */
char *endp;
long l;
+ if (op == FALSE) {
+ def->sd_un.ival = 0;
+ } else {
+ l = strtol(val, &endp, 10);
+ if (*endp != '\0')
+ return(FALSE);
+ /* XXX - should check against INT_MAX */
+ def->sd_un.ival = (unsigned int)l;
+ }
+ return(TRUE);
+}
+
+static int
+store_uint(val, def, op)
+ char *val;
+ struct sudo_defs_types *def;
+ int op;
+{
+ char *endp;
+ long l;
+
if (op == FALSE) {
def->sd_un.ival = 0;
} else {