bin/53377: [PATCH] su does not return exit status of executed command

Cejka Rudolf cejkar at fit.vutbr.cz
Mon Jun 16 08:10:07 PDT 2003


>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:


More information about the freebsd-bugs mailing list