Date: Mon, 16 Jun 2003 17:04:03 +0200 (CEST) From: Cejka Rudolf <cejkar@fit.vutbr.cz> To: FreeBSD-gnats-submit@FreeBSD.org Cc: markm@FreeBSD.org Subject: bin/53377: [PATCH] su does not return exit status of executed command Message-ID: <200306161504.h5GF43CC089479@kazi.fit.vutbr.cz> Resent-Message-ID: <200306161510.h5GFA6J3017315@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200306161504.h5GF43CC089479>