From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20916 invoked from network); 6 Mar 2008 10:23:59 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 6 Mar 2008 10:23:59 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 66691 invoked from network); 6 Mar 2008 10:23:56 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 6 Mar 2008 10:23:56 -0000 Received: (qmail 10070 invoked by alias); 6 Mar 2008 10:23:53 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24689 Received: (qmail 10053 invoked from network); 6 Mar 2008 10:23:52 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 6 Mar 2008 10:23:52 -0000 Received: from cluster-g.mailcontrol.com (cluster-g.mailcontrol.com [85.115.41.190]) by bifrost.dotsrc.org (Postfix) with ESMTP id ED2118029404 for ; Thu, 6 Mar 2008 11:23:47 +0100 (CET) Received: from rly16g.srv.mailcontrol.com (localhost.localdomain [127.0.0.1]) by rly16g.srv.mailcontrol.com (MailControl) with ESMTP id m26AMgpb022470 for ; Thu, 6 Mar 2008 10:22:45 GMT Received: from submission.mailcontrol.com (submission.mailcontrol.com [86.111.216.190]) by rly16g.srv.mailcontrol.com (MailControl) id m26ALPYT019076 for zsh-workers@sunsite.dk; Thu, 6 Mar 2008 10:21:25 GMT Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly16g-eth0.srv.mailcontrol.com (envelope-sender Peter.Stephenson@csr.com) (MIMEDefang) with ESMTP id m26AEHju026329; Thu, 06 Mar 2008 10:21:21 +0000 (GMT) Received: from news01 ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Thu, 6 Mar 2008 10:19:37 +0000 Date: Thu, 6 Mar 2008 10:19:37 +0000 From: Peter Stephenson To: zsh-workers@sunsite.dk Cc: Sven Joachim , 369305@bugs.debian.org Subject: Re: Bug#369305: zsh: failed to write history file /home/sven/.zsh-history: no such file or directory Message-ID: <20080306101937.6e4bd8a7@news01> In-Reply-To: <20080305224158.GB9620@herod.dreamhost.com> References: <87ir01bb68.fsf@gmx.de> <20080305144438.GA9541@scowler.net> <200803051712.m25HCNk6006441@news01.csr.com> <20080305202936.GA24616@scowler.net> <20080305224158.GB9620@herod.dreamhost.com> Organization: CSR X-Mailer: Claws Mail 3.3.1 (GTK+ 2.12.5; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 06 Mar 2008 10:19:37.0444 (UTC) FILETIME=[94CC4240:01C87F73] X-Scanned-By: MailControl A-08-00-04 (www.mailcontrol.com) on 10.71.1.126 X-Virus-Scanned: ClamAV 0.91.2/6147/Thu Mar 6 10:10:48 2008 on bifrost X-Virus-Status: Clean On Wed, 5 Mar 2008 14:41:58 -0800 Wayne Davison wrote: > On Wed, Mar 05, 2008 at 03:29:36PM -0500, Clint Adams wrote: > > As Sven notes, any history added before exiting will make it into the > > history file despite the error message. > > The history being added is the appending going on due to SHARE_HISTORY. > The error is referring to the inability to rewrite the history file on > exit, and it is actually failing (because the write-new, then rename > steps would cause the file to change ownership). If incremental history > updating was not happening, the failed rewrite would indeed not save > anything new. The "no such file or directory" error string is > presumably a left-over errno that Peter noticed. Yes, I've found where... at this point we've already handled the error in the manner you say by simply not trying to write the history, so there's no system error we haven't dealt with and we should reset errno. We could fix both problems by not printing an error if there's no "errno", as below. That's OK in the specific circumstances, but probably not right in all cases. Could we, for example, pass down a flag when savehistfile() is called from itself to do the rewriting and suppress the error message, or make it more anodyne, in that case? If we decide a warning message is still appropriate, given that we've detected exactly what's going on it should probably be more specific than just a vague "failed to write history". I won't commit this until we've resolved the TODO, but you might want to check it does remove the error message. Index: Src/hist.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/hist.c,v retrieving revision 1.70 diff -u -r1.70 hist.c --- Src/hist.c 31 Dec 2007 23:14:17 -0000 1.70 +++ Src/hist.c 6 Mar 2008 10:16:08 -0000 @@ -2207,7 +2207,13 @@ struct stat sb; int old_exists = stat(unmeta(fn), &sb) == 0; + errno = 0; if (old_exists && sb.st_uid != geteuid()) { + /* + * TODO: do we want an error message about changed ownership + * here? Do we want a lesser error message, or none, + * if this call to savehistfile() was just a rewrite? + */ free(tmpfile); tmpfile = NULL; /* Avoid an error about HISTFILE.new */ out = NULL; @@ -2302,7 +2308,7 @@ } else ret = -1; - if (ret < 0 && err) { + if (ret < 0 && err && errno) { if (tmpfile) { zerr("failed to write history file %s.new: %e", fn, errno); free(tmpfile); -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070