From: Todd C. Miller Date: Wed, 14 Nov 2018 20:37:46 +0000 (-0700) Subject: Support st_nmtime in struct stat as found in HP-UX. X-Git-Tag: SUDO_1_8_27^2~31 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=716aa6e4ab77c133fa989d01718c7faed46e6ceb;p=sudo Support st_nmtime in struct stat as found in HP-UX. --- diff --git a/config.h.in b/config.h.in index fd99abdaa..8e0f429c9 100644 --- a/config.h.in +++ b/config.h.in @@ -814,6 +814,9 @@ /* Define to 1 if your struct stat has an st_mtimespec member. */ #undef HAVE_ST_MTIMESPEC +/* Define to 1 if your struct stat has an st_nmtime member. */ +#undef HAVE_ST_NMTIME + /* Define to 1 if your struct stat uses an st__tim union. */ #undef HAVE_ST__TIM diff --git a/configure b/configure index 794516296..cb51705f9 100755 --- a/configure +++ b/configure @@ -20975,8 +20975,17 @@ else if test "x$ac_cv_member_struct_stat_st_mtimespec" = xyes; then : $as_echo "#define HAVE_ST_MTIMESPEC 1" >>confdefs.h +else + ac_fn_c_check_member "$LINENO" "struct stat" "st_nmtime" "ac_cv_member_struct_stat_st_nmtime" "$ac_includes_default" +if test "x$ac_cv_member_struct_stat_st_nmtime" = xyes; then : + $as_echo "#define HAVE_ST_NMTIME 1" >>confdefs.h + fi +fi + + + fi # Look for sha2 functions if not using openssl @@ -29141,5 +29150,6 @@ fi + diff --git a/configure.ac b/configure.ac index 86e0627c8..660a206d7 100644 --- a/configure.ac +++ b/configure.ac @@ -2836,9 +2836,14 @@ AC_CHECK_MEMBERS([struct tm.tm_gmtoff], [], [], [ AC_INCLUDES_DEFAULT #include ]) -AC_CHECK_MEMBER([struct stat.st_mtim], [AC_DEFINE(HAVE_ST_MTIM)] +AC_CHECK_MEMBER([struct stat.st_mtim], + [AC_DEFINE(HAVE_ST_MTIM)] [AC_CHECK_MEMBER([struct stat.st_mtim.st__tim], AC_DEFINE(HAVE_ST__TIM))], - [AC_CHECK_MEMBER([struct stat.st_mtimespec], AC_DEFINE([HAVE_ST_MTIMESPEC]))]) + [AC_CHECK_MEMBER([struct stat.st_mtimespec], + [AC_DEFINE([HAVE_ST_MTIMESPEC])], + [AC_CHECK_MEMBER([struct stat.st_nmtime], AC_DEFINE(HAVE_ST_NMTIME))]) + ] +) # Look for sha2 functions if not using openssl if test "$DIGEST" = "digest.lo"; then FOUND_SHA2=no @@ -4578,6 +4583,7 @@ AH_TEMPLATE(HAVE_SOLARIS_AUDIT, [Define to 1 to enable Solaris audit support.]) AH_TEMPLATE(HAVE_ST__TIM, [Define to 1 if your struct stat uses an st__tim union.]) AH_TEMPLATE(HAVE_ST_MTIM, [Define to 1 if your struct stat has an st_mtim member.]) AH_TEMPLATE(HAVE_ST_MTIMESPEC, [Define to 1 if your struct stat has an st_mtimespec member.]) +AH_TEMPLATE(HAVE_ST_NMTIME, [Define to 1 if your struct stat has an st_nmtime member.]) AH_TEMPLATE(HAVE___PROGNAME, [Define to 1 if your crt0.o defines the __progname symbol for you.]) AH_TEMPLATE(HOST_IN_LOG, [Define to 1 if you want the hostname to be entered into the log file.]) AH_TEMPLATE(IGNORE_DOT_PATH, [Define to 1 if you want to ignore '.' and empty PATH elements.]) diff --git a/include/sudo_util.h b/include/sudo_util.h index 2d3f5f185..96cac165d 100644 --- a/include/sudo_util.h +++ b/include/sudo_util.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Todd C. Miller + * Copyright (c) 2013-2018 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -136,6 +136,8 @@ # else # define mtim_get(_x, _y) do { (_y).tv_sec = (_x)->SUDO_ST_MTIM.tv_sec; (_y).tv_nsec = ((_x)->SUDO_ST_MTIM.tv_nsec / 1000) * 1000; } while (0) # endif +#elif defined(HAVE_ST_NMTIME) +# define mtim_get(_x, _y) do { (_y).tv_sec = (_x)->st_mtime; (_y).tv_nsec = (_x)->st_nmtime; } while (0) #else # define mtim_get(_x, _y) do { (_y).tv_sec = (_x)->st_mtime; (_y).tv_nsec = 0; } while (0) #endif /* HAVE_ST_MTIM */ diff --git a/lib/util/utimens.c b/lib/util/utimens.c index 7cbe250f3..579391f14 100644 --- a/lib/util/utimens.c +++ b/lib/util/utimens.c @@ -52,6 +52,9 @@ #elif defined(HAVE_ST_MTIMESPEC) # define ATIME_TO_TIMEVAL(_x, _y) TIMESPEC_TO_TIMEVAL((_x), &(_y)->st_atimespec) # define MTIME_TO_TIMEVAL(_x, _y) TIMESPEC_TO_TIMEVAL((_x), &(_y)->st_mtimespec) +#elif defined(HAVE_ST_NMTIME) +# define ATIME_TO_TIMEVAL(_x, _y) do { (_x)->tv_sec = (_y)->st_atime; (_x)->tv_usec = (_y)->st_natime; } while (0) +# define MTIME_TO_TIMEVAL(_x, _y) do { (_x)->tv_sec = (_y)->st_mtime; (_x)->tv_usec = (_y)->st_nmtime; } while (0) #else # define ATIME_TO_TIMEVAL(_x, _y) do { (_x)->tv_sec = (_y)->st_atime; (_x)->tv_usec = 0; } while (0) # define MTIME_TO_TIMEVAL(_x, _y) do { (_x)->tv_sec = (_y)->st_mtime; (_x)->tv_usec = 0; } while (0)