2 * Copyright (c) 1996, 1998-2000, 2004, 2007-2009
3 * Todd C. Miller <Todd.Miller@courtesan.com>
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.
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.
31 * A command with args. XXX - merge into struct member.
39 * Tags associated with a command.
40 * Possible valus: TRUE, FALSE, UNSPEC.
43 __signed char nopasswd;
50 * SELinux-specific container struct.
51 * Currently just contains a role and type.
59 * The parses sudoers file is stored as a collection of linked lists,
60 * modelled after the yacc grammar.
62 * Other than the alias struct, which is stored in a red-black tree,
63 * the data structure used is basically a doubly-linked tail queue without
64 * a separate head struct--the first entry acts as the head where the prev
65 * pointer does double duty as the tail pointer. This makes it possible
66 * to trivally append sub-lists. In addition, the prev pointer is always
67 * valid (even if it points to itself). Unlike a circle queue, the next
68 * pointer of the last entry is NULL and does not point back to the head.
70 * Note that each list struct must contain a "prev" and "next" pointer as
71 * the first two members of the struct (in that order).
75 * Tail queue list head structure.
84 * Structure describing a user specification and list thereof.
87 struct userspec *prev, *next;
88 struct member_list users; /* list of users */
89 struct privilege_list privileges; /* list of privileges */
93 * Structure describing a privilege specification.
96 struct privilege *prev, *next;
97 struct member_list hostlist; /* list of hosts */
98 struct cmndspec_list cmndlist; /* list of Cmnd_Specs */
102 * Structure describing a linked list of Cmnd_Specs.
105 struct cmndspec *prev, *next;
106 struct member_list runasuserlist; /* list of runas users */
107 struct member_list runasgrouplist; /* list of runas groups */
108 struct member *cmnd; /* command to allow/deny */
109 struct cmndtag tags; /* tag specificaion */
111 char *role, *type; /* SELinux role and type */
116 * Generic structure to hold users, hosts, commands.
119 struct member *prev, *next;
120 char *name; /* member name */
121 short type; /* type (see gram.h) */
122 short negated; /* negated via '!'? */
125 struct runascontainer {
126 struct member *runasusers;
127 struct member *runasgroups;
131 * Generic structure to hold {User,Host,Runas,Cmnd}_Alias
132 * Aliases are stored in a red-black tree, sorted by name and type.
135 char *name; /* alias name */
136 unsigned short type; /* {USER,HOST,RUNAS,CMND}ALIAS */
137 unsigned short seqno; /* sequence number */
138 struct member_list members; /* list of alias members */
142 * Structure describing a Defaults entry and a list thereof.
145 struct defaults *prev, *next;
146 char *var; /* variable name */
147 char *val; /* variable value */
148 struct member_list binding; /* user/host/runas binding */
149 int type; /* DEFAULTS{,_USER,_RUNAS,_HOST} */
150 int op; /* TRUE, FALSE, '+', '-' */
154 * Parsed sudoers info.
156 extern struct userspec_list userspecs;
157 extern struct defaults_list defaults;
160 * Alias sequence number to avoid loops.
162 extern unsigned int alias_seqno;
167 char *alias_add __P((char *, int, struct member *));
168 int addr_matches __P((char *));
169 int cmnd_matches __P((struct member *));
170 int cmndlist_matches __P((struct member_list *));
171 int command_matches __P((char *, char *));
172 int hostlist_matches __P((struct member_list *));
173 int hostname_matches __P((char *, char *, char *));
174 int netgr_matches __P((char *, char *, char *, char *));
175 int no_aliases __P((void));
176 int runaslist_matches __P((struct member_list *, struct member_list *));
177 int userlist_matches __P((struct passwd *, struct member_list *));
178 int usergr_matches __P((char *, char *, struct passwd *));
179 int userpw_matches __P((char *, char *, struct passwd *));
180 int group_matches __P((char *, struct group *));
181 struct alias *alias_find __P((char *, int));
182 struct alias *alias_remove __P((char *, int));
183 void alias_free __P((void *));
184 void alias_apply __P((int (*)(void *, void *), void *));
185 void init_aliases __P((void));
186 void init_lexer __P((void));
187 void init_parser __P((char *, int));
188 int alias_compare __P((const void *, const void *));
190 #endif /* _SUDO_PARSE_H */