1 /* Include and determine availability of smack routines
2    Copyright (C) 2013-2023 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 /* Here we replace or wrap the most common smack functions used by coreutils.
18    Others will need to be protected by HAVE_SMACK.  */
19 
20 #ifdef HAVE_SMACK
21 # include <sys/smack.h>
22 #else
23 static inline ssize_t
smack_new_label_from_self(char ** label)24 smack_new_label_from_self (char **label)
25 {
26   return -1;
27 }
28 
29 static inline int
smack_set_label_for_self(char const * label)30 smack_set_label_for_self (char const *label)
31 {
32   return -1;
33 }
34 #endif
35 
36 static inline bool
is_smack_enabled(void)37 is_smack_enabled (void)
38 {
39 #ifdef HAVE_SMACK
40   return smack_smackfs_path () != nullptr;
41 #else
42   return false;
43 #endif
44 }
45