Imported Debian patch 1.6.8p9-2
[debian/sudo] / parse.h
1 /*
2  * Copyright (c) 1996,1998-2000,2004 Todd C. Miller <Todd.Miller@courtesan.com>
3  *
4  * Permission to use, copy, modify, and distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  *
16  * $Sudo: parse.h,v 1.14 2004/08/02 18:44:58 millert Exp $
17  */
18
19 #ifndef _SUDO_PARSE_H
20 #define _SUDO_PARSE_H
21
22 /*
23  * Data structure used in parsing sudoers;
24  * top of stack values are the ones that
25  * apply when parsing is done & can be
26  * accessed by *_matches macros
27  */
28 #define STACKINCREMENT (32)
29 struct matchstack {
30         int user;
31         int cmnd;
32         int host;
33         int runas;
34         int nopass;
35         int noexec;
36 };
37
38 /*
39  * Data structure describing a command in the
40  * sudoers file.
41  */
42 struct sudo_command {
43     char *cmnd;
44     char *args;
45 };
46
47 #define user_matches    (match[top-1].user)
48 #define cmnd_matches    (match[top-1].cmnd)
49 #define host_matches    (match[top-1].host)
50 #define runas_matches   (match[top-1].runas)
51 #define no_passwd       (match[top-1].nopass)
52 #define no_execve       (match[top-1].noexec)
53
54 /*
55  * Structure containing command matches if "sudo -l" is used.
56  */
57 struct command_match {
58     char *runas;
59     size_t runas_len;
60     size_t runas_size;
61     char *cmnd;
62     size_t cmnd_len;
63     size_t cmnd_size;
64     int nopasswd;
65     int noexecve;
66 };
67
68 /*
69  * Structure describing an alias match in parser.
70  */
71 typedef struct {
72     int type;
73     char *name;
74     int val;
75 } aliasinfo;
76
77 /*
78  * Structure containing Cmnd_Alias's if "sudo -l" is used.
79  */
80 struct generic_alias {
81     int type;
82     char *alias;
83     char *entries;
84     size_t entries_size;
85     size_t entries_len;
86 };
87
88 /* The matching stack and number of entries on it. */
89 extern struct matchstack *match;
90 extern int top;
91
92 /*
93  * Prototypes
94  */
95 int addr_matches        __P((char *));
96 int command_matches     __P((char *, char *));
97 int hostname_matches    __P((char *, char *, char *));
98 int netgr_matches       __P((char *, char *, char *, char *));
99 int userpw_matches      __P((char *, char *, struct passwd *));
100 int usergr_matches      __P((char *, char *, struct passwd *));
101
102 #endif /* _SUDO_PARSE_H */