guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/04: daemon: Flush the sink upon 'exportPath' errors.


From: Ludovic Courtès
Subject: 01/04: daemon: Flush the sink upon 'exportPath' errors.
Date: Mon, 17 Jul 2017 09:14:16 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 2e009ae7cdaee4ce871b3a79d50118762ee29fb6
Author: Jan Nieuwenhuizen <address@hidden>
Date:   Mon Jul 17 15:00:01 2017 +0200

    daemon: Flush the sink upon 'exportPath' errors.
    
    Prior to this change, errors such as wrong permissions on
    /etc/guix/signing-key.sec would give:
    
      guix-daemon: nix/libutil/serialise.cc:15: virtual 
nix::BufferedSink::~BufferedSink(): Assertion `!bufPos' failed.
    
    This patch correctly propagates the error to the client and thus changes
    that to:
    
      error: build failed: file `/etc/guix/signing-key.sec' should be secret 
(inaccessible to everybody else)!
    
    * nix/nix-daemon/nix-daemon.cc (performOp): Wrap 'exportPath' call in
    'try' block.
    
    Co-authored-by: Ludovic Courtès <address@hidden>
---
 nix/nix-daemon/nix-daemon.cc | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/nix/nix-daemon/nix-daemon.cc b/nix/nix-daemon/nix-daemon.cc
index 7d26b61..deb7003 100644
--- a/nix/nix-daemon/nix-daemon.cc
+++ b/nix/nix-daemon/nix-daemon.cc
@@ -436,7 +436,15 @@ static void performOp(bool trusted, unsigned int 
clientVersion,
         bool sign = readInt(from) == 1;
         startWork();
         TunnelSink sink(to);
-        store->exportPath(path, sign, sink);
+       try {
+           store->exportPath(path, sign, sink);
+       }
+       catch (Error &e) {
+           /* Flush SINK beforehand or its destructor will rightfully trigger
+              an assertion failure.  */
+           sink.flush();
+           throw e;
+       }
         sink.flush();
         stopWork();
         writeInt(1, to);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]