tmpdir: Allow trusting of particular groups.
[checkpath] / checkpath.3
CommitLineData
d7b5ee0c 1.\" -*-nroff-*-
2.TH checkpath 3 "25 January 2003" "Local tools"
3.SH NAME
4checkpath \- library for examining path security
5.SH SYNOPSIS
6.nf
7.B "#include <checkpath.h>"
8
9.BI "int checkpath(const char *" path ,
10.BI " const struct checkpath *" cp ");"
11.BI "void checkpath_setids(struct checkpath *" cp ");"
12.fi
13.SH DESCRIPTION
14The
15.B checkpath
16function checks a path for security. It ensures that only acceptble
17users and groups can change the files or file contents accessible
18through the path.
19.PP
20The function is given a
21.I path
22to be checked, and a pointer
23.I cp
24to a parameter block of type
25.BR "struct checkpath" .
26It scans the path and returns a bitmask of problems that it found. It
27may also have invoked a caller-provided reporting function with details
28of the problems.
29.SS "The parameter structure"
30This structure contains the following members:
31.TP
32.B "uid_t cp_uid"
33The user running the check. Files and directories owned by
34.B root
35(uid 0) and by
36.B cp_uid
37are considered safe.
38.TP
39.B "gid_t cp_gid[NGROUPS_MAX + 1]"
40The groups of which the user is a member. Files whose groups are in
41this set may be considered safe, depending on the
42.B cp_what
43configuration. See below.
44.TP
45.B "int cp_gids"
46The number of gids in the
47.B cp_gid
48array.
49.TP
50.B "int cp_verbose"
51The verbosity level. Messages are only given to the reporting function
52if their verbosity level is less than or equal to this setting. As a
53guide, unexpected errors (e.g., nonexistent files) have level 0,
54security concerns about the path have level 1, and other details have
55levels 2 and above. The recommended value is 1.
56.TP
57.B "unsigned cp_what"
58A bitmask of flags determining what conditions are considered problems,
59and other behaviour. See below.
60.TP
61.B "void (*cp_report)(...)"
62The reporting function. See below.
63.TP
64.B "void *cp_arg"
65An argument to be passed to the reporting function
66.BR cp_report .
67.PP
68The members
69.BR cp_uid ,
70.B cp_gid
71and
72.B cp_gids
73can be set up to reflect the current user and group memberships by
74calling
75.B checkpath_setids
76passing the address of the structure to fill in.
77.SS "The cp_what flags"
78The
79.B cp_what
80flags are as follows.
81.TP
82.B CP_ERROR
83Some kind of operating system error occurred while checking the path.
84.TP
85.B CP_WRWORLD
86A path element is world writable.
87.TP
88.B CP_WRGRP
89A path element is group-writable.
90.TP
91.B CP_WROTHGRP
92A path element is group-writable, and its group is not listed in
93.BR cp_gid .
94.TP
95.B CP_WROTHUSR
96A path element is owned by another user.
97.TP
98.B CP_SYMLINK
99Report traversal of a symbolic link while checking the path.
100.TP
101.B CP_REPORT
102Format a user-readable message string when reporting problems.
103.TP
104.B CP_STICKYOK
105Don't complain if the object designated by the path is a sticky
106directory, as long as the owner is trustworthy (i.e., either
107.B root
108or
109.BR cp_uid ).
110This is useful when testing candidate temporary directories for
111suitability.
112.PP
113The flags
114.BR CP_ERROR ,
115.BR CP_WRWORLD ,
116.BR CP_WRGRP ,
117.BR CP_WROTHGRP ,
118and
119.B CP_WROTHUSR
120are collectively the
121.I problem
122flags. The mask
123.B CP_PROBLEMS
124has only these bits set. A problem is reported (and returned) only if
125its bit is set in the
126.B cp_what
127structure member. Note that it's possible that a problem might fit into
128multiple categories, e.g., a group-writable directory might be reported
129as
130.B CP_WRGRP
131or
132.BR CP_WROTHGRP ;
133in this case, the most specific problem is used (in this case
134.BR CP_WROTHGRP ).
135.SS "The reporting function"
136The reporting function is passed the following arguments:
137.TP
138.BI "unsigned " what
139A flag inidicating the kind of notification this is. It will be a
140problem flag or
141.BR CP_SYMLINK .
142.TP
143.BI "int " verb
144The verbosity level of this message.
145.TP
146.BI "const char *" path
147The full pathname of the object which caused this report to be issued.
148The pathname will not contain symbolic links (except as the last
149element, and then only if this is a
150.B CP_SYMLINK
151notification).
152.TP
153.BI "const char *" msg
154A human-readable message describing this notification in detail. This
155is only generated if
156.B CP_REPORT
157is set in the
158.B cp_what
159flags.
160.TP
161.BI "void *" p
162The
163.B cp_arg
164member of the parameter structure, provided as a context pointer for the
165reporting function.
166.SH BUGS
167None known.
168.SH SEE ALSO
169.BR chkpath (1),
170.BR tmpdir (1).
171.SH AUTHOR
172Mark Wooding (mdw@nsict.org).