Bug 673157

Summary: sudo fails to report error correctly when execv(3) fails
Product: Red Hat Enterprise Linux 5 Reporter: Roy Badami <roy>
Component: sudoAssignee: Daniel Kopeček <dkopecek>
Status: CLOSED ERRATA QA Contact: Aleš Mareček <amarecek>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 5.6CC: amarecek, dkopecek, pvrabec, ralph
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: sudo-1.7.2p1-11.el5 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 828707 828782 (view as bug list) Environment:
Last Closed: 2012-02-21 03:21:47 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 828707, 828782    

Description Roy Badami 2011-01-27 15:14:26 UTC
Description of problem:

sudo fails to report the error correctly when the execv(3) library call fails. This arises due to the sudo audit patch inserting into sudo.c a call to audit_logger() after the calls to execv() and before the call to warning().

The call to audit_logger() clobbers errno, resulting in warning() reporting an incorrect message (usually 'success').

The result is that you see errors such as

sudo: unable to exec <program>: success

Such errors seem to cause frequent confusion as the underlying failure of the execv(3) library call will not be evident. A google search finds several examples of people encountering this problem, usually without being able to determine the root cause.

http://www.google.com/search?source=ig&hl=en&rlz=&=&q=%22sudo%3A+unable+to+execute%22+success&btnG=Google+Search&aq=f&oq= 

The issue has been verified present in RHEL 5.6


Version-Release number of selected component (if applicable): sudo-1.7.2p1-10.el5


How reproducible: Always


Steps to Reproduce:

Perform the following steps:

cat <<EOF >foo
#!/bin/wibble
wibble wobble
EOF

chmod +x foo

#An attempt to exec foo will give an error due to a missing interpreter
#-bash: ./foo: /bin/wibble: bad interpreter: No such file or directory
./foo

#An attempt by sudo to exec foo will give a bogus error due to the issue described above
#sudo: unable to execute ./foo: Success
sudo ./foo

  
Actual results:

sudo: unable to execute ./foo: Success
    (or other incorrect message)


Expected results:

sudo: unable to execute ./foo: No such file or directory
    (or similar)


Additional info:

I believe this is the chunk of sudo-1.7.2p1-audit.patch that causes the problem

@@ -568,11 +586,17 @@ main(argc, argv, envp)
            NewArgv[1] = safe_cmnd;
            execv(_PATH_BSHELL, NewArgv);
        }
+#ifdef WITH_AUDIT
+ audit_logger(AUDIT_USER_CMD, safe_cmnd, user_args, 0);
+#endif
        warning("unable to execute %s", safe_cmnd);
        exit(127);
     } else if (ISSET(validated, FLAG_NO_USER | FLAG_NO_HOST)) {
        audit_failure(NewArgv, "No user or host");
        log_denial(validated, 1);
+#ifdef WITH_AUDIT
+ audit_logger(AUDIT_USER_CMD, safe_cmnd, user_args, 0);
+#endif
        exit(1);
     } else {
        if (def_path_info) {

Comment 3 errata-xmlrpc 2012-02-21 03:21:47 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2012-0309.html