Red Hat Bugzilla – Bug 697111
sudo -l inserts new lines based on terminal width, causing errors when output is piped.
Last modified: 2012-04-05 11:39:19 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)
Created attachment 492512 [details] example sudoers
Created attachment 530206 [details] proposed patch
(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.
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