1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Add an autoconf test and workaround for futimes(3).

Not every system provides it (e.g. uClibc-ng); if one does not, the
Uppity SFTP server should now degrade sensibly to refusing attempts to
set the utimes on an already-open file.
This commit is contained in:
Simon Tatham 2019-03-26 18:39:40 +00:00
parent e9f0abad2e
commit 94f955fa90
2 changed files with 11 additions and 1 deletions

View File

@ -173,7 +173,7 @@ AC_CHECK_LIB(X11, XOpenDisplay,
[GTK_LIBS="-lX11 $GTK_LIBS"
AC_DEFINE([HAVE_LIBX11],[],[Define if libX11.a is available])])
AC_CHECK_FUNCS([getaddrinfo posix_openpt ptsname setresuid strsignal updwtmpx fstatat dirfd])
AC_CHECK_FUNCS([getaddrinfo posix_openpt ptsname setresuid strsignal updwtmpx fstatat dirfd futimes])
AC_CHECK_DECLS([CLOCK_MONOTONIC], [], [], [[#include <time.h>]])
AC_SEARCH_LIBS([clock_gettime], [rt], [AC_DEFINE([HAVE_CLOCK_GETTIME],[],[Define if clock_gettime() is available])])

View File

@ -412,6 +412,16 @@ static void uss_fstat(SftpServer *srv, SftpReplyBuilder *reply,
}
}
#if !HAVE_FUTIMES
static inline int futimes(int fd, const struct timeval tv[2])
{
/* If the OS doesn't support futimes(3) then we have to pretend it
* always returns failure */
errno = EINVAL;
return -1;
}
#endif
/*
* The guts of setstat and fsetstat, macroised so that they can call
* fchown(fd,...) or chown(path,...) depending on parameters.