* [PATCH] Add chcon method to libselinux python bindings
@ 2010-06-07 21:40 Steve Lawrence
2010-06-08 11:58 ` Daniel J Walsh
2010-06-10 21:04 ` Chad Sellers
0 siblings, 2 replies; 3+ messages in thread
From: Steve Lawrence @ 2010-06-07 21:40 UTC (permalink / raw)
To: selinux
Adds a chcon method to the libselinux python bindings to change the
context of a file/directory tree.
---
libselinux/src/selinuxswig_python.i | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/libselinux/src/selinuxswig_python.i b/libselinux/src/selinuxswig_python.i
index 8b34c99..dea0e80 100644
--- a/libselinux/src/selinuxswig_python.i
+++ b/libselinux/src/selinuxswig_python.i
@@ -21,6 +21,14 @@ def restorecon(path, recursive=False):
map(restorecon, [os.path.join(dirname, fname)
for fname in fnames]), None)
+def chcon(path, context, recursive=False):
+ """ Set the SELinux context on a given path """
+ lsetfilecon(path, context)
+ if recursive:
+ for root, dirs, files in os.walk(path):
+ for name in files + dirs:
+ lsetfilecon(os.path.join(root,name), context)
+
def copytree(src, dest):
""" An SELinux-friendly shutil.copytree method """
shutil.copytree(src, dest)
--
1.6.2.5
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Add chcon method to libselinux python bindings
2010-06-07 21:40 [PATCH] Add chcon method to libselinux python bindings Steve Lawrence
@ 2010-06-08 11:58 ` Daniel J Walsh
2010-06-10 21:04 ` Chad Sellers
1 sibling, 0 replies; 3+ messages in thread
From: Daniel J Walsh @ 2010-06-08 11:58 UTC (permalink / raw)
To: Steve Lawrence; +Cc: selinux
I like it, I have basically the same code in sandbox. and would move to
this implementation if it is added to libselinux.
On 06/07/2010 05:40 PM, Steve Lawrence wrote:
> Adds a chcon method to the libselinux python bindings to change the
> context of a file/directory tree.
> ---
> libselinux/src/selinuxswig_python.i | 8 ++++++++
> 1 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/libselinux/src/selinuxswig_python.i b/libselinux/src/selinuxswig_python.i
> index 8b34c99..dea0e80 100644
> --- a/libselinux/src/selinuxswig_python.i
> +++ b/libselinux/src/selinuxswig_python.i
> @@ -21,6 +21,14 @@ def restorecon(path, recursive=False):
> map(restorecon, [os.path.join(dirname, fname)
> for fname in fnames]), None)
>
> +def chcon(path, context, recursive=False):
> + """ Set the SELinux context on a given path """
> + lsetfilecon(path, context)
> + if recursive:
> + for root, dirs, files in os.walk(path):
> + for name in files + dirs:
> + lsetfilecon(os.path.join(root,name), context)
> +
> def copytree(src, dest):
> """ An SELinux-friendly shutil.copytree method """
> shutil.copytree(src, dest)
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Add chcon method to libselinux python bindings
2010-06-07 21:40 [PATCH] Add chcon method to libselinux python bindings Steve Lawrence
2010-06-08 11:58 ` Daniel J Walsh
@ 2010-06-10 21:04 ` Chad Sellers
1 sibling, 0 replies; 3+ messages in thread
From: Chad Sellers @ 2010-06-10 21:04 UTC (permalink / raw)
To: Steve Lawrence, selinux
On 6/7/10 5:40 PM, "Steve Lawrence" <slawrence@tresys.com> wrote:
> Adds a chcon method to the libselinux python bindings to change the
> context of a file/directory tree.
> ---
> libselinux/src/selinuxswig_python.i | 8 ++++++++
> 1 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/libselinux/src/selinuxswig_python.i
> b/libselinux/src/selinuxswig_python.i
> index 8b34c99..dea0e80 100644
> --- a/libselinux/src/selinuxswig_python.i
> +++ b/libselinux/src/selinuxswig_python.i
> @@ -21,6 +21,14 @@ def restorecon(path, recursive=False):
> map(restorecon, [os.path.join(dirname, fname)
> for fname in fnames]), None)
>
> +def chcon(path, context, recursive=False):
> + """ Set the SELinux context on a given path """
> + lsetfilecon(path, context)
> + if recursive:
> + for root, dirs, files in os.walk(path):
> + for name in files + dirs:
> + lsetfilecon(os.path.join(root,name), context)
> +
> def copytree(src, dest):
> """ An SELinux-friendly shutil.copytree method """
> shutil.copytree(src, dest)
Acked-by: Chad Sellers <csellers@tresys.com>
Merged as of libselinux 2.0.95
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-06-10 21:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-07 21:40 [PATCH] Add chcon method to libselinux python bindings Steve Lawrence
2010-06-08 11:58 ` Daniel J Walsh
2010-06-10 21:04 ` Chad Sellers
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.