> On Sat, Sep 23, 2017 at 09:43:12AM +0200, Jesper Wallin wrote:
> Yeah, fully understandable. I'll bump this once 6.2 is out.
>
> I'll apply the changes Philip suggested (thanks!) and then build a
> release to verify that everything works.
>
>
Woups, seems like I managed to break ftp(1) in the installer due to
pledge being a bit too tight. Here is an updated version of the patch
and with Philips changes as well.
Index: fetch.c
===================================================================
RCS file: /cvs/src/usr.bin/ftp/fetch.c,v
retrieving revision 1.163
diff -u -p -r1.163 fetch.c
--- fetch.c 7 Mar 2017 08:00:23 -0000 1.163
+++ fetch.c 23 Sep 2017 21:28:49 -0000
@@ -210,6 +210,7 @@ url_get(const char *origline, const char
int status;
int save_errno;
const size_t buflen = 128 * 1024;
+ time_t mtime = -1;
direction = "received";
@@ -647,7 +648,7 @@ noslash:
if (pledge("stdio rpath inet dns tty", NULL) == -1)
err(1, "pledge");
} else {
- if (pledge("stdio rpath wpath cpath inet dns tty",
NULL) == -1)
+ if (pledge("stdio rpath wpath cpath fattr inet dns
tty", NULL) == -1)
err(1, "pledge");
}
}
@@ -860,6 +861,12 @@ noslash:
if (restart_point)
filesize += restart_point;
#endif /* !SMALL */
+#define LASTMOD "Last-Modified: "
+ } else if (strncasecmp(cp, LASTMOD, sizeof(LASTMOD) - 1) == 0) {
+ struct tm tm;
+ cp += sizeof(LASTMOD) - 1;
+ if (strptime(cp, "%a, %d %b %Y %T %z", &tm) != NULL)
+ mtime = mktime(&tm);
#define LOCATION "Location: "
} else if (isredirect &&
strncasecmp(cp, LOCATION, sizeof(LOCATION) - 1) == 0) {
@@ -1043,8 +1050,21 @@ cleanup_url_get:
fclose(fin);
else if (s != -1)
close(s);
- if (out >= 0 && out != fileno(stdout))
+ if (out >= 0 && out != fileno(stdout)) {
+
+ if (mtime != -1) {
+ struct timespec tv[2];
+ tv[0].tv_nsec = UTIME_NOW;
+ tv[1].tv_sec = mtime;
+ tv[1].tv_nsec = 0;
+ if (futimens(out, tv) == -1)
+ fprintf(ttyout,
+ "Can't change modification time on %s to %s\n",
+ savefile, ctime(&mtime));
+ }
+
close(out);
+ }
free(buf);
free(proxyhost);
free(proxyurl);
Index: ftp.c
===================================================================
RCS file: /cvs/src/usr.bin/ftp/ftp.c,v
retrieving revision 1.100
diff -u -p -r1.100 ftp.c
--- ftp.c 22 Aug 2016 16:27:00 -0000 1.100
+++ ftp.c 23 Sep 2017 21:28:49 -0000
@@ -1217,8 +1217,8 @@ break2:
ut.modtime = mtime;
if (utime(local, &ut) == -1)
fprintf(ttyout,
- "Can't change modification time on %s to %s",
- local, asctime(localtime(&mtime)));
+ "Can't change modification time on %s to %s\n",
+ local, ctime(&mtime));
}
}
}