NetBSD Problem Report #45672
From river@RT.UK.EU.ORG Wed Nov 30 16:20:22 2011
Return-Path: <river@RT.UK.EU.ORG>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by www.NetBSD.org (Postfix) with ESMTP id C8ED363D8FB
for <gnats-bugs@gnats.NetBSD.org>; Wed, 30 Nov 2011 16:20:21 +0000 (UTC)
Message-Id: <20111130162017.D4E9E40FBD@TAMARA.RT.UK.EU.ORG>
Date: Wed, 30 Nov 2011 16:20:17 +0000 (GMT)
From: river@rt.uk.eu.org
Reply-To: river@rt.uk.eu.org
To: gnats-bugs@gnats.NetBSD.org
Subject: usr.sbin/user generates incorrect error messages
X-Send-Pr-Version: 3.95
>Number: 45672
>Category: bin
>Synopsis: usr.sbin/user generates incorrect error messages
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Nov 30 16:25:00 +0000 2011
>Closed-Date: Sat Dec 10 15:22:13 +0000 2011
>Last-Modified: Sat Dec 10 15:22:13 +0000 2011
>Originator: River Tarnell
>Release: NetBSD 5.1.0_PATCH
>Organization:
RT.UK.EU.ORG
>Environment:
System: NetBSD tamara.rt.uk.eu.org 5.1.0_PATCH NetBSD 5.1.0_PATCH (TAMARA) #2: Thu Aug 4 18:30:08 UTC 2011 root@tamara.tcx.org.uk:/usr/src/sys/arch/amd64/compile/TAMARA amd64
Architecture: x86_64
Machine: amd64
>Description:
usr.sbin/user/user.c contains this error handling code in asystem():
if ((ret = system(buf)) != 0) {
warn("Error running `%s'", buf);
}
This will print the errno value if system() returns >0, which is wrong, because
errno is not set in this case, so a junk error message will be output.
>How-To-Repeat:
Code inspection.
>Fix:
switch (ret = system(buf)) {
case 0: break;
case -1: warn("Error running `%s'", buf); break;
default: warnx("Error running `%s'", buf); break;
}
>Release-Note:
>Audit-Trail:
From: "David A. Holland" <dholland@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/45672 CVS commit: src/usr.sbin/user
Date: Thu, 1 Dec 2011 00:26:45 +0000
Module Name: src
Committed By: dholland
Date: Thu Dec 1 00:26:45 UTC 2011
Modified Files:
src/usr.sbin/user: user.c
Log Message:
Handle return value from system() properly.
PR 45672 from River Tarnell.
To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/usr.sbin/user/user.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Thu, 01 Dec 2011 00:35:57 +0000
State-Changed-Why:
Fixed in HEAD - if you have a test case in mind please give it a try. Also,
do you need this on the netbsd-5 branch? I'm not convinced it's worth the
trouble.
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: bin/45672 (usr.sbin/user generates incorrect error messages)
Date: Sat, 10 Dec 2011 14:48:47 +0000
(sent to gnats-admin instead of gnats-bugs)
------
From: River Tarnell <river@RT.UK.EU.ORG>
To: dholland@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: bin/45672 (usr.sbin/user generates incorrect error messages)
Date: Wed, 7 Dec 2011 19:18:17 +0000
dholland@NetBSD.org:
> Fixed in HEAD - if you have a test case in mind please give it a try.
I don't, but without testing, I imagine something like "PATH= useradd
..." would work.
> Also, do you need this on the netbsd-5 branch? I'm not convinced it's
> worth the trouble.
No, I only noticed it while looking at the code for an unrelated
problem.
--
-- river. | Free Usenet: http://news.rt.uk.eu.org/
Non-Reciprocal Laws of Expectations: | PGP: 2B9CE6F2
Negative expectations yield negative results.
Positive expectations yield negative results.
State-Changed-From-To: feedback->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 10 Dec 2011 15:22:13 +0000
State-Changed-Why:
Fixed.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.