Created attachment 2425 [details] proposed patch I habitually run "ssh-add -t10h" when I open up my laptop in the morning and then suspend it at the end of the working day, usually a little while before the lifetime of the identities expires. Recently, however, this hasn't worked because the agent still has the identities the following morning. I believe that this is because monotime() uses CLOCK_MONOTONIC but in recent kernels this has changed slightly. From clock_gettime(2): CLOCK_MONOTONIC Clock that cannot be set and represents monotonic time since some unspecified starting point. This clock is not affected by discontinuous jumps in the system time (e.g., if the system administrator manually changes the clock), but is affected by the incremental adjustments performed by adjtime(3) and NTP. CLOCK_BOOTTIME (since Linux 2.6.39; Linux-specific) Identical to CLOCK_MONOTONIC, except it also includes any time that the system is suspended. This allows applica‐ tions to get a suspend-aware monotonic clock without hav‐ ing to deal with the complications of CLOCK_REALTIME, which may have discontinuities if the time is changed using settimeofday(2). The attached patch seems to fix this: if CLOCK_MONOTONIC is available then additionally check for CLOCK_BOOTTIME. CLOCK_BOOTTIME is Linux specific and will never be defined unless CLOCK_MONOTONIC is also defined. So far as I can tell this has not been addressed in the current version.
Created attachment 2427 [details] Try CLOCK_BOOTTIME with fallback It's probably better to try CLOCK_BOOTTIME first and fall back to CLOCK_MONOTONIC, in case the system headers happen to have the former but the kernel lacks support.
I agree, I had thought the same thing overnight. There are possible cases where CLOCK_BOOTIME is defined at compile time but it not available at run time so the fallback is definitely needed. (I actually have the opposite case: CLOCK_BOOTIME is available at run time but not defined at compile time, but that's my problem, not yours.) Your patch has a logical problem though: it won't compile if CLOCK_BOOTTIME is defined but CLOCK_MONOTONIC is. In practice this won't happen, but perhaps you either want to surround the CLOCK_MONOTONIC call with a #ifdef or you want to remove the test for defined(CLOCK_BOOTTIME) from the surrounding #if.
similar patch applied - this will be in openssh-6.7
Close all bugs left open from 6.6 and 6.7 releases.