2 .\" This file is part of libsmack
3 .\" Copyright (C) 2012 Samsung Electronics Co.
5 .\" This library is free software; you can redistribute it and/or
6 .\" modify it under the terms of the GNU Lesser General Public License
7 .\" version 2.1 as published by the Free Software Foundation.
9 .\" This library is distributed in the hope that it will be useful, but
10 .\" WITHOUT ANY WARRANTY; without even the implied warranty of
11 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 .\" Lesser General Public License for more details.
14 .\" You should have received a copy of the GNU Lesser General Public
15 .\" License along with this library; if not, write to the Free Software
16 .\" Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 .\" Rafal Krypa <r.krypa@samsung.com>
22 .TH "SMACK_GETLABEL" "3" "07/05/2012" "Libsmack 1\&.0"
24 smack_getlabel, smack_lgetlabel, smack_fgetlabel, smack_setlabel, smack_lsetlabel, smack_fsetlabel \- Manipulation of Smack labels for files
26 .B #include <sys/smack.h>
28 .BI "int smack_getlabel(const char *" path ", char **" label ", enum smack_label_type " type ");"
30 .BI "int smack_lgetlabel(const char *" path ", char **" label ", enum smack_label_type " type ");"
32 .BI "int smack_fgetlabel(int " fd ", char **" label ", enum smack_label_type " type ");"
35 .BI "int smack_setlabel(const char *" path ", const char *" label ", enum smack_label_type " type ");"
37 .BI "int smack_lsetlabel(const char *" path ", const char *" label ", enum smack_label_type " type ");"
39 .BI "int smack_fsetlabel(int " fd ", const char *" label ", enum smack_label_type " type ");"
42 Smack uses extended attributes (xattrs) to store labels on filesystem objects. The attributes are stored in the extended attribute security name space. A process must have CAP_MAC_ADMIN to change any of these attributes.
43 These functions provide an interface for Smack label manipulation on files and file descriptors.
45 There are several types of labels and not all of them are valid for every object. All valid types are defined in enum smack_label_type:
47 .BR SMACK_LABEL_ACCESS :
48 Label used as the object label for Smack access checks when a labeled file is accessed.
50 .BR SMACK_LABEL_EXEC :
51 Label used as the subject label for processes executed from a labeled file by means of
55 .BR SMACK_LABEL_MMAP :
56 Label used as the object label for Smack access checks when a labeled file is mmap-ed (see
59 .BR SMACK_LABEL_TRANSMUTE :
60 Special purpose label for directories. In contrast with all other label types, this one is of boolean type. If set to true on a directory, all files and directories created in that directory will inherit the directory's
61 .BR SMACK_LABEL_ACCESS
62 label. Created subdirectories will also have
63 .BR SMACK_LABEL_ACCESS
64 set to true. The described behavior works only if a subject creating those files and directories has "t" (transmute) permission on the directory's
65 .BR SMACK_LABEL_ACCESS
68 .BR SMACK_LABEL_IPIN :
69 Valid only for socket file descriptors. Used as the object label for packets incoming from the socket.
71 .BR SMACK_LABEL_IPOUT :
72 Valid only for socket file descriptors. Used as the Smack label transmitted with outgoing packets.
74 All of these functions allocate memory for the label contents and assign the pointer to
76 The caller is responsible for freeing the memory.
79 retrieves the label of specified
85 .BR smack_lgetlabel ()
87 .BR smack_getlabel (),
88 except in the case of a symbolic link, where the link itself is interrogated, not the file that it refers to.
90 .BR smack_fgetlabel ()
92 .BR smack_getlabel (),
93 only the open file pointed to by
97 is interrogated in place of
100 These functions work with files and file descriptors in the same way as the get functions described above.
101 They set the label to the value passed in
103 argument. Valid values are:
105 NULL or empty string - will cause removal of the label, if any was present on a file.
108 .BR SMACK_LABEL_TRANSMUTE
109 label type on a directory will turn transmute on or off.
111 Any string not longer than
113 for other label types.
115 On success, zero is returned. On failure, \-1 is returned and
117 is set appropriately.
119 .BR smack_have_access (3),