All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Lautrbach <plautrba@redhat.com>
To: selinux@tycho.nsa.gov
Subject: Rewrite restorecon python method
Date: Thu, 22 Dec 2016 13:43:07 +0100	[thread overview]
Message-ID: <20161222124309.27686-1-plautrba@redhat.com> (raw)

Hi.

selinux.restorecon(path, recursive=True) uses matchpathcon() to get a
label for a file and when the label is defined as <<None>>,it throws a
backtrace with error:

"OSError: [Errno 2] No such file or directory"

It creates a problem for scripts which tries to relabel whole directory tree
when there a subdirectory with a specification like this:

/var/lib/nfs/rpc_pipefs(/.*)?      all files   <<None>>

>>> selinux.restorecon('/var/lib', recursive=True)                                   
Traceback (most recent call last):
  File "/usr/lib64/python3.5/site-packages/selinux/__init__.py", line 114, in restorecon
    status, context = matchpathcon(path, mode)
FileNotFoundError: [Errno 2] No such file or directory


At the same time, there's a rfe to rewrite restorecon() to use
selinux_restorecon() which uses selabel_lookup() instead of deprecated
matchpathcon() - [1]

The following 2 patches tries to address the described problem using the RFE.

First patch exports selinux_restorecon() to SWIG bindings.
Second one rewites python implementation of restorecon() to use it.


[1] https://github.com/SELinuxProject/selinux/issues/29

Petr

             reply	other threads:[~2016-12-22 12:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-22 12:43 Petr Lautrbach [this message]
2016-12-22 12:43 ` [PATCH 1/2] libselinux: Generate SWIG wrappers for selinux_restorecon() Petr Lautrbach
2016-12-22 12:43 ` [PATCH 2/2] libselinux: Rewrite restorecon() python method Petr Lautrbach
2017-01-09 18:26   ` Stephen Smalley

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=20161222124309.27686-1-plautrba@redhat.com \
    --to=plautrba@redhat.com \
    --cc=selinux@tycho.nsa.gov \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.