From 740d3691d521ac5e4138c06e0446bbb4d85b25a6 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sat, 2 Jun 2018 18:13:30 +0300 Subject: [PATCH] Fixed nncp-bundle workability with Go 1.10+ --- VERSION | 2 +- doc/news.ru.texi | 12 ++++++++++ doc/news.texi | 12 ++++++++++ .../nncp/cmd/nncp-bundle/main.go | 23 +++++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 8c50098..a3ec5a4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.1 +3.2 diff --git a/doc/news.ru.texi b/doc/news.ru.texi index 5061c81..0cc0e7a 100644 --- a/doc/news.ru.texi +++ b/doc/news.ru.texi @@ -1,6 +1,18 @@ @node Новости @section Новости +@node Релиз 3.2 +@subsection Релиз 3.2 +@itemize +@item +@strong{Несовместимое} изменение формата @emph{bundle} архивов и +работоспособность @command{nncp-bundle} команды с Go 1.10+. Bundle +должен быть корректным tar архивом, но Go 1.9 делал его недействительным +из-за длинных путей внутри. NNCP нечаянно был зависим от этой баги. +Явное добавление @file{NNCP/} директории в архив восстанавливает +работоспособность с корректными tar архивами. +@end itemize + @node Релиз 3.1 @subsection Релиз 3.1 @itemize diff --git a/doc/news.texi b/doc/news.texi index f3116d8..ae4c1a9 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -3,6 +3,18 @@ See also this page @ref{Новости, on russian}. +@node Release 3.2 +@section Release 3.2 +@itemize +@item +@strong{Incompatible} @emph{bundle} archive format changes and +@command{nncp-bundle} workability with Go 1.10+. Bundles must be +valid tar archives, but Go 1.9 made them invalid because of long paths +inside. NNCP accidentally was dependant on that bug. Explicit adding of +@file{NNCP/} directory in archive restores workability with valid tar +archives. +@end itemize + @node Release 3.1 @section Release 3.1 @itemize diff --git a/src/cypherpunks.ru/nncp/cmd/nncp-bundle/main.go b/src/cypherpunks.ru/nncp/cmd/nncp-bundle/main.go index f6e0d46..1e5f8f2 100644 --- a/src/cypherpunks.ru/nncp/cmd/nncp-bundle/main.go +++ b/src/cypherpunks.ru/nncp/cmd/nncp-bundle/main.go @@ -119,6 +119,14 @@ func main() { job.Fd.Close() continue } + if err = tarWr.WriteHeader(&tar.Header{ + Format: tar.FormatUSTAR, + Name: nncp.NNCPBundlePrefix, + Mode: 0700, + Typeflag: tar.TypeDir, + }); err != nil { + log.Fatalln("Error writing tar header:", err) + } if err = tarWr.WriteHeader(&tar.Header{ Format: tar.FormatPAX, Name: strings.Join([]string{ @@ -195,6 +203,21 @@ func main() { } continue } + if entry.Typeflag != tar.TypeDir { + ctx.LogD("nncp-bundle", sds, "Expected NNCP/") + continue + } + entry, err = tarR.Next() + if err != nil { + if err != io.EOF { + ctx.LogD( + "nncp-bundle", + nncp.SdsAdd(sds, nncp.SDS{"err": err}), + "error reading tar", + ) + } + continue + } sds["pkt"] = entry.Name if entry.Size < nncp.PktEncOverhead { ctx.LogD("nncp-bundle", sds, "Too small packet") -- 2.48.1