From: Darren Tucker Date: Mon, 5 May 2025 10:45:42 +0000 (+1000) Subject: Handle systems that don't have st_mtim. X-Git-Tag: V_10_1_P1~320 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61525ba967ac1bb7394ea0792aa6030bcbbad049;p=thirdparty%2Fopenssh-portable.git Handle systems that don't have st_mtim. Ignores nanoseconds, but it's checking for >1h old so a few nanoseconds shouldn't matter much. Fixes build on Mac OS X. --- diff --git a/misc-agent.c b/misc-agent.c index a8605302e..f13ccdf26 100644 --- a/misc-agent.c +++ b/misc-agent.c @@ -270,7 +270,7 @@ agent_cleanup_stale(const char *homedir, int ignore_hosthash) struct dirent *dp; struct stat sb; char *prefix = NULL, *dirpath, *path; - struct timespec now, sub; + struct timespec now, sub, *mtimp = NULL; /* Only consider sockets last modified > 1 hour ago */ if (clock_gettime(CLOCK_REALTIME, &now) != 0) { @@ -309,7 +309,14 @@ agent_cleanup_stale(const char *homedir, int ignore_hosthash) } if (!S_ISSOCK(sb.st_mode)) continue; - if (timespeccmp(&sb.st_mtim, &now, >)) { +#ifdef HAVE_STRUCT_STAT_ST_MTIM + mtimp = &sb.st_mtim; +#else + sub.tv_sec = sb.st_mtime; + sub.tv_nsec = 0; + mtimp = ⊂ +#endif + if (timespeccmp(mtimp, &now, >)) { debug3_f("Ignoring recent socket \"%s/%s\"", dirpath, dp->d_name); continue;