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