xref: /openbsd-src/usr.bin/doas/doas.h (revision 38599afa1d1d1f14a897b01350e8ce94486e1788)
1*38599afaStedu /* $OpenBSD: doas.h,v 1.20 2024/02/15 18:57:58 tedu Exp $ */
22bab682cSderaadt /*
32bab682cSderaadt  * Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
42bab682cSderaadt  *
52bab682cSderaadt  * Permission to use, copy, modify, and distribute this software for any
62bab682cSderaadt  * purpose with or without fee is hereby granted, provided that the above
72bab682cSderaadt  * copyright notice and this permission notice appear in all copies.
82bab682cSderaadt  *
92bab682cSderaadt  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
102bab682cSderaadt  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
112bab682cSderaadt  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
122bab682cSderaadt  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
132bab682cSderaadt  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
142bab682cSderaadt  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
152bab682cSderaadt  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
162bab682cSderaadt  */
172bab682cSderaadt 
187bfbda14Stedu struct rule {
197bfbda14Stedu 	int action;
207bfbda14Stedu 	int options;
217bfbda14Stedu 	const char *ident;
227bfbda14Stedu 	const char *target;
237bfbda14Stedu 	const char *cmd;
24cb7cef4cSzhuk 	const char **cmdargs;
257bfbda14Stedu 	const char **envlist;
267bfbda14Stedu };
277bfbda14Stedu 
287bfbda14Stedu extern struct rule **rules;
29618b6875Smillert extern size_t nrules;
30cbc92769Stobias extern int parse_error;
317bfbda14Stedu 
32b09050b2Stedu extern const char *formerpath;
33b09050b2Stedu 
34e327fa4eStedu struct passwd;
35e327fa4eStedu 
36e327fa4eStedu char **prepenv(const struct rule *, const struct passwd *,
37e327fa4eStedu     const struct passwd *);
382da8cf98Stedu 
39*38599afaStedu #define PERMIT	-1
407bfbda14Stedu #define DENY	2
417bfbda14Stedu 
427bfbda14Stedu #define NOPASS		0x1
437bfbda14Stedu #define KEEPENV		0x2
440a39d05fStedu #define PERSIST		0x4
45d4bf2b56Skn #define NOLOG		0x8
46960755fcSjcs 
47960755fcSjcs #define AUTH_FAILED	-1
48960755fcSjcs #define AUTH_OK		0
49960755fcSjcs #define AUTH_RETRIES	3
50