Bug 697111 - sudo -l inserts new lines based on terminal width, causing errors when output is piped.
sudo -l inserts new lines based on terminal width, causing errors when output...
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: sudo (Show other bugs)
Unspecified Unspecified
medium Severity medium
: rc
: ---
Assigned To: Daniel Kopeček
Aleš Mareček
Depends On:
Blocks: 810326
  Show dependency treegraph
Reported: 2011-04-15 17:00 EDT by Joel Davis
Modified: 2012-04-05 11:39 EDT (History)
4 users (show)

See Also:
Fixed In Version: sudo-1.7.2p1-11.el5
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 810326 (view as bug list)
Last Closed: 2012-02-20 22:21:52 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

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

  None (edit)
Description Joel Davis 2011-04-15 17:00:55 EDT
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 17:12:55 EDT
Created attachment 492512 [details]
example sudoers
Comment 4 Daniel Kopeček 2011-10-25 21:00:21 EDT
Created attachment 530206 [details]
proposed patch
Comment 5 Daniel Kopeček 2011-10-25 21:04:06 EDT
(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-20 22:21:52 EST
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.


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