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