tmpdir: Allow trusting of particular groups.
[checkpath] / checkpath.h
CommitLineData
efa7a97b 1/* -*-c-*-
2 *
efa7a97b 3 * Check a path for safety
4 *
5 * (c) 1999 Mark Wooding
6 */
7
8/*----- Licensing notice --------------------------------------------------*
9 *
10 * This file is part of chkpath.
11 *
12 * chkpath is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * chkpath is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with chkpath; if not, write to the Free Software Foundation,
24 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 */
26
d7b5ee0c 27#ifndef CHECKPATH_H
28#define CHECKPATH_H
efa7a97b 29
30#ifdef __cplusplus
31 extern "C" {
32#endif
33
34/*----- Header files ------------------------------------------------------*/
35
36#include <limits.h>
37#include <sys/types.h>
38
39/*----- Data structures ---------------------------------------------------*/
40
41/* --- Search request --- *
42 *
43 * This contains parameters from the caller to control what problems are
44 * looked for, and what to do when they're found.
45 */
46
d7b5ee0c 47struct checkpath {
efa7a97b 48 uid_t cp_uid; /* Uid that's considered OK */
49 gid_t cp_gid[NGROUPS_MAX + 1]; /* Array of groups that are OK */
50 int cp_gids; /* Number of groups in the array */
51 int cp_verbose; /* Verbosity level to spit up */
7868d789 52 unsigned cp_what; /* What things to check for */
d7b5ee0c 53 void (*cp_report)(unsigned /*what*/, int /*verb*/,
efa7a97b 54 const char */*dir*/, const char */*msg*/,
55 void */*p*/);
56 void *cp_arg; /* Argument for cp_report */
57};
58
59/* --- Flags for `@what@' fields in the above --- */
60
d7b5ee0c 61/* Problem types */
62#define CP_PROBLEMS 0x1fu /* Mask of problem bits */
63#define CP_ERROR 0x01u /* Error report */
64#define CP_WRWORLD 0x02u /* Check write by world */
65#define CP_WRGRP 0x04u /* Check write by any group */
66#define CP_WROTHGRP 0x08u /* Check write by other group */
67#define CP_WROTHUSR 0x10u /* Check write by other user */
68
69/* Other flags */
70#define CP_SYMLINK 0x100u /* Report symbolic links */
71#define CP_REPORT 0x200u /* Make user-readable reports */
72#define CP_STICKYOK 0x400u /* Don't care if sticky is set */
efa7a97b 73
74/*----- Functions provided ------------------------------------------------*/
75
d7b5ee0c 76/* --- @checkpath@ --- *
efa7a97b 77 *
78 * Arguments: @const char *p@ = directory name which needs checking
d7b5ee0c 79 * @const struct checkpath *cp@ = parameters for the check
efa7a97b 80 *
81 * Returns: Zero if all is well, otherwise bitmask of problems.
82 *
83 * Use: Scrutinises a directory path to see what evil things other
84 * users could do to it.
85 */
86
d7b5ee0c 87extern unsigned checkpath(const char */*p*/, const struct checkpath */*cp*/);
efa7a97b 88
d7b5ee0c 89/* --- @checkpath_setids@ --- *
efa7a97b 90 *
d7b5ee0c 91 * Arguments: @struct checkpath *cp@ = pointer to block to fill in
efa7a97b 92 *
93 * Returns: ---
94 *
95 * Use: Fills in the user ids and things in the structure.
96 */
97
d7b5ee0c 98extern void checkpath_setids(struct checkpath */*cp*/);
efa7a97b 99
100/*----- That's all, folks -------------------------------------------------*/
101
102#ifdef __cplusplus
103 }
104#endif
105
106#endif