Bug 477185 - sudo changes uid before calling SELInux calls, preventing it from setting terminal context when using non priv account
Summary: sudo changes uid before calling SELInux calls, preventing it from setting ter...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: sudo
Version: 5.4
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
: ---
Assignee: Daniel Kopeček
QA Contact: Aleš Mareček
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-12-19 14:41 UTC by Daniel Walsh
Modified: 2012-02-21 03:21 UTC (History)
7 users (show)

Fixed In Version: sudo-1.7.2p1-11.el5
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-02-21 03:21:13 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
proposed patch (90.31 KB, patch)
2011-10-27 12:43 UTC, Daniel Kopeček
no flags Details | Diff
proposed patch (94.25 KB, patch)
2011-10-28 13:23 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 Daniel Walsh 2008-12-19 14:41:36 UTC
Description of problem:

sudo -u pwalsh sh
[sudo] password for dwalsh: 
sudo: unable to open /dev/pts/10: Permission denied
sudo: unable to setup tty context for staff_u:unconfined_r:unconfined_t:s0-s0:c0.c1023: Permission denied

grep dwalsh /etc/sudoers
dwalsh ALL=(ALL) TYPE=unconfined_t ROLE=unconfined_r /bin/sh

The problem is the set_perms call happens before the selinux_exec, selinux_exec tries to setfilecon on the terminal and is denied because sudo is no longer running as root.  

Couple of choices, either split the selinux code up to set the terminal and the execcon separate from the exec and run it before set_perms, or set_perms inside the selinux_exec code when running with selinux.  Looks like you chdir after the set_perms so this might change behaviour.

Comment 1 Ted Rule 2009-02-02 14:47:52 UTC
Another side effect of what I presume to be the same problem appears to be the inability to redirect sudo's output to a file or pipe when the TYPE= and ROLE= operators are used.


When I tried to use this:

%sudoers	ALL=(ALL) TYPE=unconfined_t ROLE=unconfined_r   ALL

in /etc/sudoers, I found that whilst sudo appeared to work Ok, the output of the sudo'ed command was apparently sent directly to the parent shell's tty rather than inheriting STDOUT.


This meant that redirecting to a pipe didn't work.

So this form:

  $ sudo cat longprivatefile | more

just dumped the whole of the file to screen without more'ing it.

Even though id -Z showed that I was already set to:

  unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

the sudoers parameters were enough to disrupt the piping.

If I removed the TYPE and ROLE options from sudoers, sudo piping behaves as expected.

Comment 2 Bug Zapper 2009-11-18 10:31:16 UTC
This message is a reminder that Fedora 10 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 10.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '10'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 10's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 10 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 3 Daniel Kopeček 2011-10-27 12:43:20 UTC
Created attachment 530477 [details]
proposed patch

Backport selinux, audit and related code from 1.7.4p5 to 1.7.2p1. This fixes the reported issues with selinux in the 1.7.2p1 version.

Comment 4 Daniel Kopeček 2011-10-28 13:23:46 UTC
Created attachment 530664 [details]
proposed patch

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