Red Hat Bugzilla – Bug 477185
sudo changes uid before calling SELInux calls, preventing it from setting terminal context when using non priv account
Last modified: 2012-02-20 22:21:13 EST
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.
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:
the sudoers parameters were enough to disrupt the piping.
If I removed the TYPE and ROLE options from sudoers, sudo piping behaves as expected.
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:
Created attachment 530477 [details]
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.
Created attachment 530664 [details]
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.