summaryrefslogtreecommitdiff
path: root/src/selinux.h
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2013-12-04 19:10:37 +0000
committerPádraig Brady <P@draigBrady.com>2013-12-05 00:18:36 +0000
commit0013de3e603162081c4464ea1f7ad3285f633d78 (patch)
treed93f83bc57d79b098b7d20d9cb60cf1b8296779e /src/selinux.h
parentb53b0fd940382497e58a9e912f1262c2084fe534 (diff)
downloadcoreutils-0013de3e603162081c4464ea1f7ad3285f633d78.tar.xz
selinux: fix --context=CTX for cp and diagnose defaultcon() errors
* src/selinux.h (ignorable_ctx_err): A new function used to determine if a warning should be given after a call to defaultcon() or restorecon(). * src/cp.c (main): Fix the setfscreatecon() call to use the argument passed by the user. * src/mkdir.c (make_ancestor): Show all but "ignoreable" errors from defaultcon() and restorecon(). * tests/misc/selinux.sh: Add a test run as root in selinux enforcing mode, to ensure cp --context=invalid is honored and fails immediately.
Diffstat (limited to 'src/selinux.h')
-rw-r--r--src/selinux.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/selinux.h b/src/selinux.h
index 31771632e..e4ded8466 100644
--- a/src/selinux.h
+++ b/src/selinux.h
@@ -19,6 +19,14 @@
#ifndef COREUTILS_SELINUX_H
# define COREUTILS_SELINUX_H
+/* Return true if ERR corresponds to an unsupported request,
+ or if there is no context or it's inaccessible. */
+static inline bool
+ignorable_ctx_err (int err)
+{
+ return err == ENOTSUP || err == ENODATA;
+}
+
# if HAVE_SELINUX_SELINUX_H
extern bool restorecon (char const *path, bool recurse, bool preserve);