1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Prototypes for openat-style fd-relative SELinux functions
4 Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #include <selinux/selinux.h>
20 #include <selinux/context.h>
22 /* These are the dir-fd-relative variants of the functions without the
23 "at" suffix. For example, getfileconat (AT_FDCWD, file, &c) is usually
24 equivalent to getfilecon (file, &c). The emulation is accomplished
25 by first attempting getfilecon ("/proc/self/fd/DIR_FD/FILE", &c).
26 Failing that, simulate it via save_cwd/fchdir/getfilecon/restore_cwd.
27 If either the save_cwd or the restore_cwd fails (relatively unlikely),
28 then give a diagnostic and exit nonzero. */
30 /* dir-fd-relative getfilecon. Set *CON to the SELinux security context
31 of the file specified by DIR_FD and FILE and return the length of *CON.
32 DIR_FD and FILE are interpreted as for fstatat[*]. A non-NULL *CON
33 must be freed with freecon. Upon error, set *CON to NULL, set errno
35 [*] with flags=0 here, with flags=AT_SYMLINK_NOFOLLOW for lgetfileconat */
36 int getfileconat (int dir_fd, char const *file, security_context_t *con);
38 /* dir-fd-relative lgetfilecon. This function is just like getfileconat,
39 except when DIR_FD and FILE specify a symlink: lgetfileconat operates on
40 the symlink, while getfileconat operates on the referent of the symlink. */
41 int lgetfileconat (int dir_fd, char const *file, security_context_t *con);
43 /* dir-fd-relative setfilecon. Set the SELinux security context of
44 the file specified by DIR_FD and FILE to CON. DIR_FD and FILE are
45 interpreted as for fstatat[*]. Upon success, return 0.
46 Otherwise, return -1 and set errno. */
47 int setfileconat (int dir_fd, char const *file, security_context_t con);
49 /* dir-fd-relative lsetfilecon. This function is just like setfileconat,
50 except that rather than dereferencing a symlink, this function affects it. */
51 /* dir-fd-relative lsetfilecon. This function is just like setfileconat,
52 except when DIR_FD and FILE specify a symlink: lsetfileconat operates on
53 the symlink, while setfileconat operates on the referent of the symlink. */
54 int lsetfileconat (int dir_fd, char const *file, security_context_t con);