selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: selinux@vger.kernel.org
Subject: Re: question about selinux_restore_tty() in sudo's selinux.c
Date: Fri, 27 Sep 2019 09:02:08 -0400	[thread overview]
Message-ID: <d3fbc1ce-15ac-adcf-8128-fdb152e5d399@tycho.nsa.gov> (raw)
In-Reply-To: <20190927082401.GB20555@seamus.lan>

On 9/27/19 4:24 AM, Dominick Grift wrote:
> On Fri, Sep 27, 2019 at 09:55:07AM +0200, Dominick Grift wrote:
>> sudo does not reset the role of my tty properly [1], and i was wondering if anyone is able to determine what is causing this [2]
>>
>> [1] https://bugzilla.sudo.ws/show_bug.cgi?id=898
>> [2] https://www.sudo.ws/repos/sudo/file/tip/src/selinux.c
> 
> Does fgetfilecon() get the context from the actual path or does it get it from file_contexts?
> If it does the latter then i guess that would explain it as pty/tty contexts are customizable and thus have no entry in file_contexts:
> 
> # matchpathcon /dev/pts/0
> /dev/pts/0      <<none>>
> 
> In that case i guess it skips the relabel?

I don't think that's relevant.  fgetfilecon() is a wrapper for 
fgetxattr(2); it gets the actual context set on the file, not something 
from file_contexts (you would use selabel_lookup(3) or matchpathcon(3) 
for the latter).

The behavior you describe suggests that sudo is never calling 
selinux_restore_tty() in this case (or there is some bug causing it to 
abort before reaching the fsetfilecon, or causing that to fail).

Don't know if you can turn up verbosity/logging and/or use strace or 
autrace or something to get more info.



  reply	other threads:[~2019-09-27 13:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-27  7:55 question about selinux_restore_tty() in sudo's selinux.c Dominick Grift
2019-09-27  8:24 ` Dominick Grift
2019-09-27 13:02   ` Stephen Smalley [this message]
2019-09-27 12:59 ` Stephen Smalley
2019-09-27 13:08   ` Dominick Grift
2019-09-27 13:33     ` Stephen Smalley
2019-09-27 13:49       ` Dominick Grift
2019-09-27 13:51         ` Stephen Smalley
2019-09-27 13:57           ` Dominick Grift
2019-09-27 14:01             ` Stephen Smalley
2019-09-27 14:17               ` Stephen Smalley
2019-09-27 14:28                 ` Dominick Grift
2019-09-27 14:32                   ` Dominick Grift
2019-09-27 14:49                   ` Stephen Smalley
2019-09-27 14:53                     ` Stephen Smalley
2019-09-27 14:57                     ` Dominick Grift

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d3fbc1ce-15ac-adcf-8128-fdb152e5d399@tycho.nsa.gov \
    --to=sds@tycho.nsa.gov \
    --cc=selinux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).