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