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 .\" .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 .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,=". .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. @