1 /* selinux - core functions for maintaining SELinux labeling
2    Copyright (C) 2012-2018 Free Software Foundation, Inc.
3 
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8 
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13 
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
16 
17 /* Written by Daniel Walsh <dwalsh@redhat.com> */
18 
19 #ifndef COREUTILS_SELINUX_H
20 # define COREUTILS_SELINUX_H
21 
22 /* Return true if ERR corresponds to an unsupported request,
23    or if there is no context or it's inaccessible.  */
24 static inline bool
ignorable_ctx_err(int err)25 ignorable_ctx_err (int err)
26 {
27   return err == ENOTSUP || err == ENODATA;
28 }
29 
30 # if HAVE_SELINUX_SELINUX_H
31 
32 extern bool
33 restorecon (char const *path, bool recurse, bool preserve);
34 extern int
35 defaultcon (char const *path, mode_t mode);
36 
37 # else
38 
39 static inline bool
restorecon(char const * path,bool recurse,bool preserve)40 restorecon (char const *path, bool recurse, bool preserve)
41 { errno = ENOTSUP; return false; }
42 
43 static inline int
defaultcon(char const * path,mode_t mode)44 defaultcon (char const *path, mode_t mode)
45 { errno = ENOTSUP; return -1; }
46 
47 # endif
48 
49 #endif
50