annotate lib/selinux-at.h @ 17255:d81be792518a

update from texinfo
author Karl Berry <karl@freefriends.org>
date Tue, 01 Jan 2013 15:51:49 -0800
parents e542fd46ad6f
children 344018b6e5d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11787
c51247a03b74 selinux-at: new module
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
1 /* Prototypes for openat-style fd-relative SELinux functions
17249
e542fd46ad6f maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents: 16201
diff changeset
2 Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
11787
c51247a03b74 selinux-at: new module
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
3
c51247a03b74 selinux-at: new module
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
c51247a03b74 selinux-at: new module
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
c51247a03b74 selinux-at: new module
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
6 the Free Software Foundation, either version 3 of the License, or
c51247a03b74 selinux-at: new module
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
7 (at your option) any later version.
c51247a03b74 selinux-at: new module
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
8
c51247a03b74 selinux-at: new module
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
c51247a03b74 selinux-at: new module
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
c51247a03b74 selinux-at: new module
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c51247a03b74 selinux-at: new module
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
12 GNU General Public License for more details.
c51247a03b74 selinux-at: new module
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
13
c51247a03b74 selinux-at: new module
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
c51247a03b74 selinux-at: new module
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c51247a03b74 selinux-at: new module
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
16
c51247a03b74 selinux-at: new module
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
17 #include <selinux/selinux.h>
c51247a03b74 selinux-at: new module
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
18 #include <selinux/context.h>
c51247a03b74 selinux-at: new module
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
19
11792
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
20 /* These are the dir-fd-relative variants of the functions without the
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
21 "at" suffix. For example, getfileconat (AT_FDCWD, file, &c) is usually
11793
d4b2d7a95227 selinux-at: fix typo in a comment
Jim Meyering <meyering@redhat.com>
parents: 11792
diff changeset
22 equivalent to getfilecon (file, &c). The emulation is accomplished
11856
8b0d11ca9d01 build: avoid some compiler warnings
Eric Blake <ebb9@byu.net>
parents: 11793
diff changeset
23 by first attempting getfilecon ("/proc/self/fd/DIR_FD/FILE", &c).
11792
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
24 Failing that, simulate it via save_cwd/fchdir/getfilecon/restore_cwd.
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
25 If either the save_cwd or the restore_cwd fails (relatively unlikely),
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
26 then give a diagnostic and exit nonzero. */
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
27
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
28 /* dir-fd-relative getfilecon. Set *CON to the SELinux security context
11856
8b0d11ca9d01 build: avoid some compiler warnings
Eric Blake <ebb9@byu.net>
parents: 11793
diff changeset
29 of the file specified by DIR_FD and FILE and return the length of *CON.
8b0d11ca9d01 build: avoid some compiler warnings
Eric Blake <ebb9@byu.net>
parents: 11793
diff changeset
30 DIR_FD and FILE are interpreted as for fstatat[*]. A non-NULL *CON
11792
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
31 must be freed with freecon. Upon error, set *CON to NULL, set errno
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
32 and return -1.
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
33 [*] with flags=0 here, with flags=AT_SYMLINK_NOFOLLOW for lgetfileconat */
11856
8b0d11ca9d01 build: avoid some compiler warnings
Eric Blake <ebb9@byu.net>
parents: 11793
diff changeset
34 int getfileconat (int dir_fd, char const *file, security_context_t *con);
11792
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
35
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
36 /* dir-fd-relative lgetfilecon. This function is just like getfileconat,
11856
8b0d11ca9d01 build: avoid some compiler warnings
Eric Blake <ebb9@byu.net>
parents: 11793
diff changeset
37 except when DIR_FD and FILE specify a symlink: lgetfileconat operates on
11792
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
38 the symlink, while getfileconat operates on the referent of the symlink. */
11856
8b0d11ca9d01 build: avoid some compiler warnings
Eric Blake <ebb9@byu.net>
parents: 11793
diff changeset
39 int lgetfileconat (int dir_fd, char const *file, security_context_t *con);
11792
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
40
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
41 /* dir-fd-relative setfilecon. Set the SELinux security context of
11856
8b0d11ca9d01 build: avoid some compiler warnings
Eric Blake <ebb9@byu.net>
parents: 11793
diff changeset
42 the file specified by DIR_FD and FILE to CON. DIR_FD and FILE are
11792
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
43 interpreted as for fstatat[*]. Upon success, return 0.
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
44 Otherwise, return -1 and set errno. */
11856
8b0d11ca9d01 build: avoid some compiler warnings
Eric Blake <ebb9@byu.net>
parents: 11793
diff changeset
45 int setfileconat (int dir_fd, char const *file, security_context_t con);
11792
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
46
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
47 /* dir-fd-relative lsetfilecon. This function is just like setfileconat,
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
48 except that rather than dereferencing a symlink, this function affects it. */
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
49 /* dir-fd-relative lsetfilecon. This function is just like setfileconat,
11856
8b0d11ca9d01 build: avoid some compiler warnings
Eric Blake <ebb9@byu.net>
parents: 11793
diff changeset
50 except when DIR_FD and FILE specify a symlink: lsetfileconat operates on
11792
3f075467f0f5 selinux-at: remove redundant m4 code, add documentation
Jim Meyering <meyering@redhat.com>
parents: 11787
diff changeset
51 the symlink, while setfileconat operates on the referent of the symlink. */
11856
8b0d11ca9d01 build: avoid some compiler warnings
Eric Blake <ebb9@byu.net>
parents: 11793
diff changeset
52 int lsetfileconat (int dir_fd, char const *file, security_context_t con);