...and another bump. :-) *ping sthen@*
On Sun, Sep 24, 2017 at 07:25:33PM +0200, Jesper Wallin wrote:
> On Sat, Sep 23, 2017 at 11:50:46PM +0200, Jesper Wallin wrote:
> > 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.
>
> ...and hopefully a final version, sorry for the noise.
>
> Changed the order of the pledge promises to their canonical order as
> given by the manual and removed some empty lines. (thanks anton@)
>
> I will of course still bump this once we're out of beta.
>
>
> 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 24 Sep 2017 08:06:26 -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 inet fattr 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,19 @@ 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 24 Sep 2017 08:06:26 -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));
> }
> }
> }