]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
Handle systems that don't have st_mtim.
authorDarren Tucker <dtucker@dtucker.net>
Mon, 5 May 2025 10:45:42 +0000 (20:45 +1000)
committerDarren Tucker <dtucker@dtucker.net>
Mon, 5 May 2025 10:45:42 +0000 (20:45 +1000)
Ignores nanoseconds, but it's checking for >1h old so a few nanoseconds
shouldn't matter much.  Fixes build on Mac OS X.

misc-agent.c

index a8605302ef8ceac7dd26e60b8a3dcef48ca52c02..f13ccdf26b5dc06cd7bddf51f7925ed2eaebced2 100644 (file)
@@ -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 = &sub;
+#endif
+               if (timespeccmp(mtimp, &now, >)) {
                        debug3_f("Ignoring recent socket \"%s/%s\"",
                            dirpath, dp->d_name);
                        continue;