f1c89d5f25bd177eeec6c5442544d1a2145fb649
[gnulib.git] / lib / selinux-at.c
1 /* openat-style fd-relative functions for SE Linux
2    Copyright (C) 2007, 2009-2012 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 <http://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 "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
30 #include "save-cwd.h"
31
32 #include "openat-priv.h"
33
34 #define AT_FUNC_NAME getfileconat
35 #define AT_FUNC_F1 getfilecon
36 #define AT_FUNC_POST_FILE_PARAM_DECLS , security_context_t *con
37 #define AT_FUNC_POST_FILE_ARGS        , con
38 #include "at-func.c"
39 #undef AT_FUNC_NAME
40 #undef AT_FUNC_F1
41 #undef AT_FUNC_POST_FILE_PARAM_DECLS
42 #undef AT_FUNC_POST_FILE_ARGS
43
44 #define AT_FUNC_NAME lgetfileconat
45 #define AT_FUNC_F1 lgetfilecon
46 #define AT_FUNC_POST_FILE_PARAM_DECLS , security_context_t *con
47 #define AT_FUNC_POST_FILE_ARGS        , con
48 #include "at-func.c"
49 #undef AT_FUNC_NAME
50 #undef AT_FUNC_F1
51 #undef AT_FUNC_POST_FILE_PARAM_DECLS
52 #undef AT_FUNC_POST_FILE_ARGS
53
54 #define AT_FUNC_NAME setfileconat
55 #define AT_FUNC_F1 setfilecon
56 #define AT_FUNC_POST_FILE_PARAM_DECLS , security_context_t con
57 #define AT_FUNC_POST_FILE_ARGS        , con
58 #include "at-func.c"
59 #undef AT_FUNC_NAME
60 #undef AT_FUNC_F1
61 #undef AT_FUNC_POST_FILE_PARAM_DECLS
62 #undef AT_FUNC_POST_FILE_ARGS
63
64 #define AT_FUNC_NAME lsetfileconat
65 #define AT_FUNC_F1 lsetfilecon
66 #define AT_FUNC_POST_FILE_PARAM_DECLS , security_context_t con
67 #define AT_FUNC_POST_FILE_ARGS        , con
68 #include "at-func.c"
69 #undef AT_FUNC_NAME
70 #undef AT_FUNC_F1
71 #undef AT_FUNC_POST_FILE_PARAM_DECLS
72 #undef AT_FUNC_POST_FILE_ARGS