From owner-freebsd-bugs@FreeBSD.ORG Mon Jun 16 08:10:07 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 59BC837B401 for ; Mon, 16 Jun 2003 08:10:07 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4C7A643FBD for ; Mon, 16 Jun 2003 08:10:06 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h5GFA6Up017316 for ; Mon, 16 Jun 2003 08:10:06 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h5GFA6J3017315; Mon, 16 Jun 2003 08:10:06 -0700 (PDT) Resent-Date: Mon, 16 Jun 2003 08:10:06 -0700 (PDT) Resent-Message-Id: <200306161510.h5GFA6J3017315@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Cejka Rudolf Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C3ADB37B401; Mon, 16 Jun 2003 08:04:07 -0700 (PDT) Received: from kazi.fit.vutbr.cz (kazi.fit.vutbr.cz [147.229.8.12]) by mx1.FreeBSD.org (Postfix) with ESMTP id 92A7843F85; Mon, 16 Jun 2003 08:04:06 -0700 (PDT) (envelope-from cejkar@fit.vutbr.cz) Received: from kazi.fit.vutbr.cz (localhost [127.0.0.1]) by kazi.fit.vutbr.cz (8.12.9/8.12.9) with ESMTP id h5GF43Ca089480 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Mon, 16 Jun 2003 17:04:03 +0200 (CEST) Received: (from cejkar@localhost) by kazi.fit.vutbr.cz (8.12.9/8.12.5/Submit) id h5GF43CC089479; Mon, 16 Jun 2003 17:04:03 +0200 (CEST) Message-Id: <200306161504.h5GF43CC089479@kazi.fit.vutbr.cz> Date: Mon, 16 Jun 2003 17:04:03 +0200 (CEST) From: Cejka Rudolf To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 cc: markm@FreeBSD.org Subject: bin/53377: [PATCH] su does not return exit status of executed command X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Cejka Rudolf List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jun 2003 15:10:07 -0000 >Number: 53377 >Category: bin >Synopsis: [PATCH] su does not return exit status of executed command >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Jun 16 08:10:05 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Rudolf Cejka >Release: FreeBSD 5.1-RELEASE i386 >Organization: FIT, Brno University of Technology, Czech Republic >Environment: FreeBSD 5.1-RELEASE FreeBSD 5.1-RELEASE #0: Tue Jun 10 14:27:40 CEST 2003 and all 5.x systems. >Description: Command su does not return exit status of executed commands. It returns 0 (or maybe "undefined value"), because there is directly called exit(statusp) without any statusp conversion returned from waitpid(). This bug for example breaks error detections in scripts on some systems like my... The problem is since su.c:1.36, so all 5.x systems are affected. >How-To-Repeat: # su -m root -c "true" ; echo $? 0 # su -m root -c "false" ; echo $? 0 # should be 1 # su -m root -c "exit 63" ; echo $? 0 # should be 63 >Fix: $ FreeBSD: src/usr.bin/su/su.c,v 1.68 2003/04/08 16:59:53 des Exp $ --- su.c.orig Mon Jun 16 16:35:22 2003 +++ su.c Mon Jun 16 16:46:17 2003 @@ -378,7 +378,7 @@ if (pid == -1) err(1, "waitpid"); PAM_END(); - exit(statusp); + exit(WEXITSTATUS(statusp)); case -1: err(1, "fork"); PAM_END(); >Release-Note: >Audit-Trail: >Unformatted: