Bug 697111 - sudo -l inserts new lines based on terminal width, causing errors when output is piped.
Summary: sudo -l inserts new lines based on terminal width, causing errors when output...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: sudo
Version: 5.6
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Daniel Kopeček
QA Contact: Aleš Mareček
URL:
Whiteboard:
Depends On:
Blocks: 810326
TreeView+ depends on / blocked
 
Reported: 2011-04-15 21:00 UTC by Joel Davis
Modified: 2018-11-27 21:40 UTC (History)
4 users (show)

Fixed In Version: sudo-1.7.2p1-11.el5
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 810326 (view as bug list)
Environment:
Last Closed: 2012-02-21 03:21:52 UTC
Target Upstream Version:


Attachments (Terms of Use)
example sudoers (352 bytes, text/plain)
2011-04-15 21:12 UTC, Joel Davis
no flags Details
proposed patch (796 bytes, patch)
2011-10-26 01:00 UTC, Daniel Kopeček
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2012:0309 0 normal SHIPPED_LIVE Low: sudo security and bug fix update 2012-02-21 07:25:01 UTC

Description Joel Davis 2011-04-15 21:00:55 UTC
Description of problem:
If terminal's columns ("stty cols") is set to a width smaller than the width of the targeted line, then sudo -l inserts a newline at the terminal width before output. If the output is being pipe to grep it will result in only the part of the line with the match on it being returned. 

Version-Release number of selected component (if applicable): appears only in 1.7.2 veresions of the sudo package.


How reproducible: reproducible on any package based on upstream. Reproduced on RHEL5.5 and later without issue. Issue isn't reproducible on earlier versions of the upstream.


Steps to Reproduce:
1. create file larger than 80 characters (example used in my reproduction is attached).
2. manually set terminal to narrower width than large line (ex: stty 40)
3. execute a grep on sudo for a something found after the terminal break (in this example "SCM")
  
Actual results:
Only the line with the string searched for is printed, instead of the whole line.

Expected results:
entire line should be output by the grep command.

Additional info:
reproduced on RHEL 5.5 5.6 and Ubuntu 10.04 all with sudo-1.7.2 version of upstream
Not reproducible on RHEL 5.4 with earlier version of the sudo package (sudo-1.6.9p17-5.el5)

Comment 1 Joel Davis 2011-04-15 21:12:55 UTC
Created attachment 492512 [details]
example sudoers

Comment 4 Daniel Kopeček 2011-10-26 01:00:21 UTC
Created attachment 530206 [details]
proposed patch

Comment 5 Daniel Kopeček 2011-10-26 01:04:06 UTC
(In reply to comment #4)
> Created attachment 530206 [details]
> proposed patch

The attached patch adds a check to get_ttycols to detect whether stdout is a pipe and if so, sets the cols to 0, which effectively disables the internal word wrapping mechanism.

Comment 8 errata-xmlrpc 2012-02-21 03:21:52 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


Note You need to log in before you can comment on or make changes to this bug.