aboutsummaryrefslogtreecommitdiff
path: root/doc/RCS/cap_from_text.3,v
blob: aae380604053cd400d3a3164e40df18a3b6354a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
head	1.3;
access;
symbols;
locks; strict;
comment	@# @;


1.3
date	97.05.24.19.45.28;	author morgan;	state Exp;
branches;
next	1.2;

1.2
date	97.05.04.05.32.50;	author morgan;	state Exp;
branches;
next	1.1;

1.1
date	97.04.28.00.54.52;	author morgan;	state Exp;
branches;
next	;


desc
@zefram's manual
@


1.3
log
@corrections from Aleph1
@
text
@.\"
.\" $Id: cap_from_text.3,v 1.2 1997/05/04 05:32:50 morgan Exp morgan $
.\" written by Andrew Main <zefram@@dcs.warwick.ac.uk>
.\"
.TH CAP_FROM_TEXT 3 "26th May 1997" "" "Linux Programmer's Manual"
.SH NAME
cap_from_text, cap_to_text, _cap_names \- capability state textual representation translation
.SH SYNOPSIS
.B #include <sys/capability.h>
.sp
.BI "cap_t cap_from_text(const char *" buf_p );
.sp
.BI "char *cap_to_text(cap_t " caps ", ssize_t *" length_p );
.sp
.B extern char const *_cap_names[];
.SH USAGE
.br
.B cc ... -lcap
.SH DESCRIPTION
These functions translate a capability state from an internal representation
into a textual one.  The internal representation is managed by the capability
functions in working storage. The textual representation is a structured,
human-readable, string suitable for display.
.PP
.B cap_from_text
allocates and initializes a capability state in working storage. It then
sets the contents of this newly-created capability state to the state
represented by human-readable, null terminated character string pointed to by
.IR buf_p .
It returns a pointer to the newly created capability state.  The
caller should free any releasable memory, when the capability state in working
storage is no longer required, by calling
.B cap_free
with
.I cap_t
as an argument.  The function returns an error if it cannot parse the
contents of the string pointed to by
.I buf_p
or does not recognize any
.I capability_name
or flag character as valid.  The function also returns an error if any flag
is both set and cleared within a single clause.
.PP
.B cap_to_text
converts the capability state in working storage identified by
.I cap_p
into a null terminated human-readable string.  This function allocates any
memory necessary to contain the string, and returns a pointer to the string.  If
the pointer
.I len_p
is not
.BR NULL ,
the function shall also return the full length of the string (not including
the null terminator) in the location pointed to by
.IR len_p .
The capability state in working storage, identified by
.IR cap_p ,
is completely represented in the character string.  The caller should
free any releasable memory, when the capability state in working
storage is no longer required, by calling
.B cap_free
with
.B cap_p
as an argument.
.PP
.B _cap_names
is an array of textual names for capability numbers.  Unnamed capabilities
have a NULL entry.  (This array is not defined by POSIX.1e.)
.SH "TEXTUAL REPRESENTATION"
A textual representation of capability sets consists of one or more
whitespace-separated
.IR clauses .
Each clause specifies some operations to a capability set; the set
starts out with all capabilities lowered, and the meaning of the
string is the state of the capability set after all the clauses have
been applied in order.
.PP
Each clause consists of a list of comma-separated capability names
(or the word
.RB ` all '),
followed by an
.IR action-list .
An action-list consists of a sequence of
.I operator flag
pairs.  Legal operators are:
.RB ` = "', '" + "', and `" - "'."
Legal flags are:
.RB ` e "', `" i "', and `" p "'."
These flags are case-sensitive and specify the Effective, Inheritable
and Permitted sets respectively.
.PP
In the capability name lists, all names are case-insensitive.  The
special name
.RB ` all '
specifies all capabilities; it is equivalent to a list naming every
capability individually.
.PP
Although not defined by POSIX, unnamed capabilities can be specified
by number.
.PP
The
.RB ` = '
operator indicates that the listed capabilities are first reset in
all three capability sets.  The subsequent flags (which are optional
when associated with this operator) indicate that the listed
capabilities for the corresponding set are to be raised.  For example:
"all=p" means lower every capability in the Effective and Inheritable
sets but raise all of the Permitted capabilities;
or, "cap_fowner=ep" means raise the Effective and Permitted
override-file-ownership capability, while lowering this Inheritable
capability.
.PP
In the case that the leading operator is
.RB ` = ',
and no list of capabilities is provided, the action-list is assumed to
refer to `all' capabilities.  For example, the following three
clauses are equivalent to each other (and indicate a completely empty
capability set): "all="; "="; "cap_chown,<every-other-capability>=".
.PP
The operators, `+' and `-' both require an explicit preceding
capability list and one or more explicit trailing flags.  The `+'
operator will raise all of the listed capabilities in the flagged
capability sets.  The `-' operator will lower all of the listed
capabilities in the flagged capability sets.  For example:
"all+p" will raise all of the Permitted capabilities; "cap_fowner+p-i"
will raise the override-file-ownership capability in the Permitted
capability set and lower this Inheritable capability;
"cap_fowner+pe-i" and "cap_fowner=+pe" are equivalent.
.SH "RETURN VALUE"
.B cap_from_text
and
.B cap_to_text
return a non-NULL value on success, and NULL on failure.
.PP
On failure,
.BR errno (3)
is set to 
.BR EINVAL ,
or 
.BR ENOMEM .
.SH "CONFORMING TO"
.B cap_from_text
and
.B cap_to_text
are specified by POSIX.1e.
.B _cap_names
is a Linux extension.
.SH "SEE ALSO"
.IR cap_clear (3),
.IR cap_copy_ext (3),
.IR cap_get_file (3),
.IR cap_get_proc (3),
.IR cap_init (3)
@


1.2
log
@fixed title name and also made consistent with text handling
@
text
@d2 1
a2 1
.\" $Id: cap_from_text.3,v 1.1 1997/04/28 00:54:52 morgan Exp morgan $
d5 1
a5 1
.TH CAP_FROM_TEXT 3 "26th April 1997" "" "Linux Programmer's Manual"
d7 1
a7 1
cap_from_text, cap_to_text, _cap_names \- textual representation of capability sets
d11 1
a11 1
.BI "cap_t cap_from_text(char const *" string );
d20 4
a23 3
These functions provide the interface to a textual representation of
POSIX.1e capabilities, suitable for display to and specification by
users.
d26 17
a42 5
interprets
.I string
and generates the corresponding internal-format capability set.
The return value must eventually be disposed of by passing it to
.BR cap_free .
d45 20
a64 6
formats
.I caps
into a string in a fixed buffer, returning a pointer to the buffer,
and storing the length of the string in
.IR *length_p .
The buffer will be overwritten on the next call.
d73 1
a73 1
Each clause specifies some modification to a capability set; the set
@


1.1
log
@Initial revision
@
text
@d2 1
a2 1
.\" $Id$
d5 1
a5 1
.TH CAP_INIT 3 "26th April 1997" "" "Linux Programmer's Manual"
d20 3
a22 2
These functions provide a textual representation of POSIX.1e capabilities,
suitable for display to and specification by users.
d43 1
a43 1
A textual representation of capability sets consists of zero or more
d46 8
a53 5
Each clause specifies some modification to a capability set; the set starts
out empty, and the meaning of the string is the state of the capability set
after all the clauses have been applied in order.
.PP
Each clause consists of an optional list of comma-separated capability names,
d55 9
a63 3
.IR operation ,
followed by a possibly empty sequence of
.IR flags .
d65 2
a66 1
In the capability name lists, all names are case-insensitive.  The special name
d68 5
a72 27
specifies all capabilities; it is equivalent to a list naming every capability
individually.  If the list is omitted, it defaults to
.RB ` all '.
Unnamed capabilities can be specified by number.
.PP
The sequence of flags specifies a set of capability sets.  The flags
.RB ` e ',
.RB ` i '
and
.RB ` p ',
which are case-sensitive, specify the Effective, Inheritable and Permitted
sets respectively.  The empty sequence of flags specifies none of these sets.
.PP
The operation must be one of
.RB ` + ',
.RB ` - '
or
.RB ` = '.
.PP
If the operation is
.RB ` + ',
then the listed capability flags are
.I set
in the listed capability sets.  Also, as an exception, an
empty capability list is not permitted; if
.RB ` all '
is desired it must be specified explicitly.
d74 11
a84 5
If the operation is
.RB ` - ',
then the listed capability flags are
.I cleared
in the listed capability sets.
d86 1
a86 1
If the operation is
d88 14
a101 5
then the listed capability flags are
.I set
in the listed capability sets and
.I cleared
in all others.
@