]> Cypherpunks.ru repositories - nncp.git/commitdiff
Merge branch 'develop' v5.1.2
authorSergey Matveev <stargrave@stargrave.org>
Fri, 13 Dec 2019 15:58:11 +0000 (18:58 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 13 Dec 2019 15:58:11 +0000 (18:58 +0300)
16 files changed:
VERSION
doc/building.texi
doc/download.texi
doc/integrity.texi
doc/news.ru.texi
doc/news.texi
makedist.sh
ports/nncp/Makefile
src/cmd/nncp-bundle/main.go
src/cmd/nncp-cfgnew/main.go
src/cmd/nncp-reass/main.go
src/cmd/nncp-xfer/main.go
src/humanizer.go
src/sp.go
src/tmp.go
src/toss.go

diff --git a/VERSION b/VERSION
index ac14c3dfaa865ea332c62348d1bca867bdbbd1cf..61fcc87350341bc51d640aa9161073ce615703ce 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-5.1.1
+5.1.2
index 3911ae5f19b5579583d75c9208477663fa4ce023..4f30e3e7dfee2f652cb8009de2fd1a6377517f38 100644 (file)
@@ -11,16 +11,16 @@ Make sure that Go is installed. For example to install it from packages:
 @end table
 
 @verbatim
-$ [fetch|wget] http://www.nncpgo.org/download/nncp-5.1.1.tar.xz
-$ [fetch|wget] http://www.nncpgo.org/download/nncp-5.1.1.tar.xz.sig
-$ gpg --verify nncp-5.1.1.tar.xz.sig nncp-5.1.1.tar.xz
-$ xz --decompress --stdout nncp-5.1.1.tar.xz | tar xf -
-$ make -C nncp-5.1.1 all
+$ [fetch|wget] http://www.nncpgo.org/download/nncp-5.1.2.tar.xz
+$ [fetch|wget] http://www.nncpgo.org/download/nncp-5.1.2.tar.xz.sig
+$ gpg --verify nncp-5.1.2.tar.xz.sig nncp-5.1.2.tar.xz
+$ xz --decompress --stdout nncp-5.1.2.tar.xz | tar xf -
+$ make -C nncp-5.1.2 all
 @end verbatim
 
 There is @command{install} make-target respecting @env{DESTDIR}. It will
 install binaries and info-documentation:
 
 @verbatim
-# make -C nncp-5.1.1 install PREFIX=/usr/local
+# make -C nncp-5.1.2 install PREFIX=/usr/local
 @end verbatim
index b6ab1db1dc71e325607b4a744c9747c2256cff49..7997689bb76253073160a608e200758419a75258 100644 (file)
@@ -23,6 +23,10 @@ Tarballs include all necessary required libraries:
 @multitable {XXXXX} {XXXX-XX-XX} {XXXX KiB} {link sign} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
 @headitem Version @tab Date @tab Size @tab Tarball @tab SHA256 checksum
 
+@item @ref{Release 5.1.1, 5.1.1} @tab 2019-12-01 @tab 1103 KiB
+@tab @url{download/nncp-5.1.1.tar.xz, link} @url{download/nncp-5.1.1.tar.xz.sig, sign}
+@tab @code{B9537678 E5B549BA 6FA0D20D 41B2D4A9 4ED31F2C AB9FAF63 A388D95E 7662A93F}
+
 @item @ref{Release 5.1.0, 5.1.0} @tab 2019-11-24 @tab 1103 KiB
 @tab @url{download/nncp-5.1.0.tar.xz, link} @url{download/nncp-5.1.0.tar.xz.sig, sign}
 @tab @code{6F5B74EC 952EAFEC 2A787463 CE1E808E CC990F03 D46F28E9 A89BAB55 5A2C2214}
index 2c2ccb5803383faaa80fdd261914db559875338d..faea7c49ba6219aaf46693227e48a8da05db16fa 100644 (file)
@@ -4,7 +4,7 @@
 You @strong{have to} check downloaded archives integrity and verify
 their signature to be sure that you have got trusted, untampered
 software. For integrity and authentication of downloaded binaries
-@url{https://www.gnupg.org/, The GNU Privacy Guard} is used. You must
+@url{https://www.gnupg.org/, GNU Privacy Guard} is used. You must
 download signature (@file{.sig}) provided with the tarball.
 
 For the very first time you need to import signing public key. It is
@@ -31,5 +31,5 @@ $ gpg --auto-key-locate wkd --locate-keys releases at nncpgo dot org
 
 Then you could verify tarballs signature:
 @verbatim
-$ gpg --verify nncp-5.1.1.tar.xz.sig nncp-5.1.1.tar.xz
+$ gpg --verify nncp-5.1.2.tar.xz.sig nncp-5.1.2.tar.xz
 @end verbatim
index 6cf154b9df23e7af3948851e317a41cd18716482..237af0fbde01a220a31ce2ae776df8d2d1e3e7df 100644 (file)
@@ -1,6 +1,26 @@
 @node Новости
 @section Новости
 
+@node Релиз 5.1.2
+@subsection Релиз 5.1.2
+@itemize
+
+@item
+Исправлена @strong{критичная} уязвимость: аутентификация online нод
+могла приводить к некорректной идентификации удалённой стороны, позволяя
+скачивать чужие зашифрованные пакеты.
+
+@item
+Исправлена ошибка: в новосозданных конфигурационных файлах, приватный
+публичный ключ Noise были поменяны местами, что приводило к
+невозможности online аутентификации нод.
+
+@item
+Явная синхронизация (fsync) директорий для гарантированного
+переименования файлов.
+
+@end itemize
+
 @node Релиз 5.1.1
 @subsection Релиз 5.1.1
 @itemize
index 3e04abb053d7c81487a96d082cad7d404db7c479..62759802b3263c52e89d50c7ccfea40450d9c356 100644 (file)
@@ -3,6 +3,24 @@
 
 See also this page @ref{Новости, on russian}.
 
+@node Release 5.1.2
+@section Release 5.1.2
+@itemize
+
+@item
+@strong{Critical} vulnerability: remote peers authentication could lead
+to incorrect identification of remote side, allowing foreign encrypted
+packets downloading.
+
+@item
+Bugfix: private and public Noise keys were swapped in newly created
+configuration files, that lead to inability to authenticate online peers.
+
+@item
+Explicit directories fsync-ing for guaranteed files renaming.
+
+@end itemize
+
 @node Release 5.1.1
 @section Release 5.1.1
 @itemize
index e3269229ef6a201235ad0d8eb694ef21d817a39e..5e66e0abbd7da029c5a03680c674e2dc4246b945 100755 (executable)
@@ -10,7 +10,7 @@ cd $tmp/nncp-$release
 git checkout v$release
 rm -fr .git
 
-mod_name=go.cypherpunks.ru/nncp/v5
+mod_name=$(sed -n 's/^module //p' src/go.mod)
 mv src src.orig
 mkdir -p src/$mod_name
 mv src.orig/* src/$mod_name
index 5f62b97919b674241f411b46a51f8be581be6bc4..e010e46a0acf0b8a4589e430905b566369f24096 100644 (file)
@@ -1,7 +1,7 @@
 # $FreeBSD: head/net/nncp/Makefile 517819 2019-11-17 11:51:56Z dmgk $
 
 PORTNAME=      nncp
-DISTVERSION=   5.1.1
+DISTVERSION=   5.1.2
 CATEGORIES=    net
 MASTER_SITES=  http://www.nncpgo.org/download/
 
index 380b3917e7e5706253a0cecbd43a4fbc416aac13..60bb1130c83d09559084b633d7f5c3f9cea1c5d7 100644 (file)
@@ -378,6 +378,9 @@ func main() {
                                        if err = os.Rename(tmp.Name(), dstPath); err != nil {
                                                log.Fatalln("Error during renaming:", err)
                                        }
+                                       if err = nncp.DirSync(selfPath); err != nil {
+                                               log.Fatalln("Error during syncing:", err)
+                                       }
                                }
                        }
                        ctx.LogI("nncp-bundle", nncp.SdsAdd(sds, nncp.SDS{
index e2eac99d0c8affde1cdf17aae09de357ea858499..70bd1dcd4d190fb5bea47d8a59312748cb2fd372 100644 (file)
@@ -86,8 +86,8 @@ func main() {
                        nncp.ToBase32(nodeOur.ExchPrv[:]),
                        nncp.ToBase32(nodeOur.SignPub[:]),
                        nncp.ToBase32(nodeOur.SignPrv[:]),
-                       nncp.ToBase32(nodeOur.NoisePub[:]),
                        nncp.ToBase32(nodeOur.NoisePrv[:]),
+                       nncp.ToBase32(nodeOur.NoisePub[:]),
                        nodeOur.Id.String(),
                        nncp.ToBase32(nodeOur.ExchPub[:]),
                        nncp.ToBase32(nodeOur.SignPub[:]),
@@ -220,8 +220,8 @@ func main() {
                        nncp.ToBase32(nodeOur.ExchPrv[:]),
                        nncp.ToBase32(nodeOur.SignPub[:]),
                        nncp.ToBase32(nodeOur.SignPrv[:]),
-                       nncp.ToBase32(nodeOur.NoisePub[:]),
                        nncp.ToBase32(nodeOur.NoisePrv[:]),
+                       nncp.ToBase32(nodeOur.NoisePub[:]),
                        nodeOur.Id.String(),
                        nncp.ToBase32(nodeOur.ExchPub[:]),
                        nncp.ToBase32(nodeOur.SignPub[:]),
index d7d79b082d327d964fc514112bb0c0a2b11c8097..161e86f602ad53961ac2167d503b121f71e0960a 100644 (file)
@@ -238,6 +238,9 @@ func process(ctx *nncp.Ctx, path string, keep, dryRun, stdout, dumpMeta bool) bo
        if err = os.Rename(tmp.Name(), dstPath); err != nil {
                log.Fatalln(err)
        }
+       if err = nncp.DirSync(mainDir); err != nil {
+               log.Fatalln(err)
+       }
        ctx.LogI("nncp-reass", nncp.SDS{"path": path}, "done")
        return !hasErrors
 }
index cfe16b779c6bff49586e34e79808c12a969fba3e..c784b4e6bfade94a0105447ac95a595133f154d2 100644 (file)
@@ -330,6 +330,11 @@ Tx:
                                isBad = true
                                continue
                        }
+                       if err = nncp.DirSync(dstPath); err != nil {
+                               ctx.LogE("nncp-xfer", nncp.SdsAdd(sds, nncp.SDS{"err": err}), "sync")
+                               isBad = true
+                               continue
+                       }
                        os.Remove(filepath.Join(dstPath, pktName+".part"))
                        delete(sds, "tmp")
                        ctx.LogI("nncp-xfer", nncp.SdsAdd(sds, nncp.SDS{
index 5c6989526841fdf4b861216cec4621e3b1edae20..14b615fbfdcc8369872aed37183d71d72c25b003 100644 (file)
@@ -173,7 +173,10 @@ func (ctx *Ctx) Humanize(s string) string {
        case "nncp-rm":
                msg += "removing " + sds["file"]
        case "call-start":
-               msg = fmt.Sprintf("Connected to %s", nodeS)
+               msg = fmt.Sprintf("Connection to %s", nodeS)
+               if err, exists := sds["err"]; exists {
+                       msg += ": " + err
+               }
        case "call-finish":
                rx, err := strconv.ParseUint(sds["rxbytes"], 10, 64)
                if err != nil {
@@ -197,6 +200,26 @@ func (ctx *Ctx) Humanize(s string) string {
                        humanize.IBytes(uint64(rx)), humanize.IBytes(uint64(rxs)),
                        humanize.IBytes(uint64(tx)), humanize.IBytes(uint64(txs)),
                )
+       case "sp-start":
+               if nodeS == "" {
+                       msg += "SP"
+                       if peer, exists := sds["peer"]; exists {
+                               msg += fmt.Sprintf(": %s", peer)
+                       }
+               } else {
+                       nice, err := NicenessParse(sds["nice"])
+                       if err != nil {
+                               return s
+                       }
+                       msg += fmt.Sprintf("SP with %s (nice %s)", nodeS, NicenessFmt(nice))
+               }
+               if len(rem) > 0 {
+                       msg += ": " + rem
+               }
+               if err, exists := sds["err"]; exists {
+                       msg += ": " + err
+               }
+
        case "sp-info":
                nice, err := NicenessParse(sds["nice"])
                if err != nil {
index 540e0e52a22a4f016114ca8a9fed71599802ed54..7b8fc3113b2db7d2111ba68bf7c1f0c346bc98cf 100644 (file)
--- a/src/sp.go
+++ b/src/sp.go
@@ -231,6 +231,10 @@ func (state *SPState) ReadSP(src io.Reader) ([]byte, error) {
        var sp SPRaw
        n, err := xdr.UnmarshalLimited(src, &sp, 1<<17)
        if err != nil {
+               ue := err.(*xdr.UnmarshalError)
+               if ue.Err == io.EOF {
+                       return nil, ue.Err
+               }
                return nil, err
        }
        state.RxLastSeen = time.Now()
@@ -415,8 +419,9 @@ func (state *SPState) StartR(conn ConnDeadlined) error {
        }
 
        var node *Node
-       for _, node = range state.Ctx.Neigh {
-               if subtle.ConstantTimeCompare(state.hs.PeerStatic(), node.NoisePub[:]) == 1 {
+       for _, n := range state.Ctx.Neigh {
+               if subtle.ConstantTimeCompare(state.hs.PeerStatic(), n.NoisePub[:]) == 1 {
+                       node = n
                        break
                }
        }
@@ -838,12 +843,12 @@ func (state *SPState) ProcessSP(payload []byte) ([][]byte, error) {
                        sdsp["xx"] = string(TRx)
                        sdsp["hash"] = ToBase32(file.Hash[:])
                        sdsp["size"] = strconv.Itoa(len(file.Payload))
-                       filePath := filepath.Join(
+                       dirToSync := filepath.Join(
                                state.Ctx.Spool,
                                state.Node.Id.String(),
                                string(TRx),
-                               ToBase32(file.Hash[:]),
                        )
+                       filePath := filepath.Join(dirToSync, ToBase32(file.Hash[:]))
                        state.Ctx.LogD("sp-file", sdsp, "opening part")
                        fd, err := os.OpenFile(
                                filePath+PartSuffix,
@@ -901,7 +906,14 @@ func (state *SPState) ProcessSP(payload []byte) ([][]byte, error) {
                                        return
                                }
                                state.Ctx.LogI("sp-done", SdsAdd(sdsp, SDS{"xx": string(TRx)}), "")
-                               os.Rename(filePath+PartSuffix, filePath)
+                               if err = os.Rename(filePath+PartSuffix, filePath); err != nil {
+                                       state.Ctx.LogE("sp-file", SdsAdd(sdsp, SDS{"err": err}), "rename")
+                                       return
+                               }
+                               if err = DirSync(dirToSync); err != nil {
+                                       state.Ctx.LogE("sp-file", SdsAdd(sdsp, SDS{"err": err}), "sync")
+                                       return
+                               }
                                state.Lock()
                                delete(state.infosTheir, *file.Hash)
                                state.Unlock()
index 95e45ee4a6162a3eb01ea084ecce9c6606f804e6..0784b996eea067656966f6e2b5bfb8a516f31242 100644 (file)
@@ -79,6 +79,19 @@ func (tmp *TmpFileWHash) Cancel() {
        os.Remove(tmp.Fd.Name())
 }
 
+func DirSync(dirPath string) error {
+       fd, err := os.Open(dirPath)
+       if err != nil {
+               return err
+       }
+       err = fd.Sync()
+       if err != nil {
+               fd.Close()
+               return err
+       }
+       return fd.Close()
+}
+
 func (tmp *TmpFileWHash) Commit(dir string) error {
        var err error
        if err = os.MkdirAll(dir, os.FileMode(0777)); err != nil {
@@ -95,5 +108,8 @@ func (tmp *TmpFileWHash) Commit(dir string) error {
        tmp.Fd.Close()
        checksum := ToBase32(tmp.Hsh.Sum(nil))
        tmp.ctx.LogD("tmp", SDS{"src": tmp.Fd.Name(), "dst": checksum}, "commit")
-       return os.Rename(tmp.Fd.Name(), filepath.Join(dir, checksum))
+       if err = os.Rename(tmp.Fd.Name(), filepath.Join(dir, checksum)); err != nil {
+               return err
+       }
+       return DirSync(dir)
 }
index 586f378076746fb689338dd14f0df44b75fc7860..5bc8b7960b79b8d2e904405b1e1aacd7282672d8 100644 (file)
@@ -261,6 +261,10 @@ func (ctx *Ctx) Toss(
                                        ctx.LogE("rx", SdsAdd(sds, SDS{"err": err}), "rename")
                                        isBad = true
                                }
+                               if err = DirSync(*incoming); err != nil {
+                                       ctx.LogE("rx", SdsAdd(sds, SDS{"err": err}), "sync")
+                                       isBad = true
+                               }
                                delete(sds, "tmp")
                        }
                        ctx.LogI("rx", sds, "")