Initial revision
[checkpath] / path.h
CommitLineData
efa7a97b 1/* -*-c-*-
2 *
3 * $Id: path.h,v 1.1 1999/04/06 20:12:07 mdw Exp $
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
29/*----- Revision history --------------------------------------------------*
30 *
31 * $Log: path.h,v $
32 * Revision 1.1 1999/04/06 20:12:07 mdw
33 * Initial revision
34 *
35 */
36
37#ifndef PATH_H
38#define PATH_H
39
40#ifdef __cplusplus
41 extern "C" {
42#endif
43
44/*----- Header files ------------------------------------------------------*/
45
46#include <limits.h>
47#include <sys/types.h>
48
49/*----- Data structures ---------------------------------------------------*/
50
51/* --- Search request --- *
52 *
53 * This contains parameters from the caller to control what problems are
54 * looked for, and what to do when they're found.
55 */
56
57struct chkpath {
58 uid_t cp_uid; /* Uid that's considered OK */
59 gid_t cp_gid[NGROUPS_MAX + 1]; /* Array of groups that are OK */
60 int cp_gids; /* Number of groups in the array */
61 int cp_verbose; /* Verbosity level to spit up */
62 int cp_what; /* What things to check for */
63 void (*cp_report)(int /*what*/, int /*verb*/,
64 const char */*dir*/, const char */*msg*/,
65 void */*p*/);
66 void *cp_arg; /* Argument for cp_report */
67};
68
69/* --- Flags for `@what@' fields in the above --- */
70
71#define CP_ERROR 1 /* Error report */
72#define CP_WRWORLD 2 /* Check write by world */
73#define CP_WRGRP 4 /* Check write by any group */
74#define CP_WROTHGRP 8 /* Check write by other group */
75#define CP_WROTHUSR 16 /* Check write by other user */
76#define CP_SYMLINK 32 /* Report symbolic links */
77#define CP_REPORT 64 /* Make user-readable reports */
78#define CP_STICKYOK 128 /* Don't care if sticky is set */
79
80/*----- Functions provided ------------------------------------------------*/
81
82/* --- @path_check@ --- *
83 *
84 * Arguments: @const char *p@ = directory name which needs checking
85 * @struct chkpath *cp@ = caller parameters for the check
86 *
87 * Returns: Zero if all is well, otherwise bitmask of problems.
88 *
89 * Use: Scrutinises a directory path to see what evil things other
90 * users could do to it.
91 */
92
93extern int path_check(const char */*p*/, struct chkpath */*cp*/);
94
95/* --- @path_setids@ --- *
96 *
97 * Arguments: @struct chkpath *cp@ = pointer to block to fill in
98 *
99 * Returns: ---
100 *
101 * Use: Fills in the user ids and things in the structure.
102 */
103
104extern void path_setids(struct chkpath */*cp*/);
105
106/*----- That's all, folks -------------------------------------------------*/
107
108#ifdef __cplusplus
109 }
110#endif
111
112#endif