1 /* openat-style fd-relative functions for SE Linux
2    Copyright (C) 2007, 2009-2021 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 Jim Meyering */
18 
19 #include <config.h>
20 
21 #include "selinux-at.h"
22 #include "openat.h"
23 
24 #include <stdlib.h>
25 #include <unistd.h>
26 #include <errno.h>
27 #include <fcntl.h>
28 
29 #include "save-cwd.h"
30 
31 #include "openat-priv.h"
32 
33 #define AT_FUNC_NAME getfileconat
34 #define AT_FUNC_F1 getfilecon
35 #define AT_FUNC_POST_FILE_PARAM_DECLS , char **con
36 #define AT_FUNC_POST_FILE_ARGS        , con
37 #include "at-func.c"
38 #undef AT_FUNC_NAME
39 #undef AT_FUNC_F1
40 #undef AT_FUNC_POST_FILE_PARAM_DECLS
41 #undef AT_FUNC_POST_FILE_ARGS
42 
43 #define AT_FUNC_NAME lgetfileconat
44 #define AT_FUNC_F1 lgetfilecon
45 #define AT_FUNC_POST_FILE_PARAM_DECLS , char **con
46 #define AT_FUNC_POST_FILE_ARGS        , con
47 #include "at-func.c"
48 #undef AT_FUNC_NAME
49 #undef AT_FUNC_F1
50 #undef AT_FUNC_POST_FILE_PARAM_DECLS
51 #undef AT_FUNC_POST_FILE_ARGS
52 
53 #define AT_FUNC_NAME setfileconat
54 #define AT_FUNC_F1 setfilecon
55 #define AT_FUNC_POST_FILE_PARAM_DECLS , char const *con
56 #define AT_FUNC_POST_FILE_ARGS        , con
57 #include "at-func.c"
58 #undef AT_FUNC_NAME
59 #undef AT_FUNC_F1
60 #undef AT_FUNC_POST_FILE_PARAM_DECLS
61 #undef AT_FUNC_POST_FILE_ARGS
62 
63 #define AT_FUNC_NAME lsetfileconat
64 #define AT_FUNC_F1 lsetfilecon
65 #define AT_FUNC_POST_FILE_PARAM_DECLS , char const *con
66 #define AT_FUNC_POST_FILE_ARGS        , con
67 #include "at-func.c"
68 #undef AT_FUNC_NAME
69 #undef AT_FUNC_F1
70 #undef AT_FUNC_POST_FILE_PARAM_DECLS
71 #undef AT_FUNC_POST_FILE_ARGS
72