Imported Upstream version 1.6.6
[debian/sudo] / defaults.h
1 /*
2  * Copyright (c) 1999-2001 Todd C. Miller <Todd.Miller@courtesan.com>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * 3. The name of the author may not be used to endorse or promote products
17  *    derived from this software without specific prior written permission.
18  *
19  * 4. Products derived from this software may not be called "Sudo" nor
20  *    may "Sudo" appear in their names without specific prior written
21  *    permission from the author.
22  *
23  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
26  * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  * $Sudo: defaults.h,v 1.23 2001/12/14 19:54:56 millert Exp $
35  */
36
37 #ifndef _SUDO_DEFAULTS_H
38 #define _SUDO_DEFAULTS_H
39
40 struct list_member {
41     char *value;
42     struct list_member *next;
43 };
44
45 enum list_ops {
46     add,
47     delete,
48     freeall
49 };
50
51 /*
52  * Structure describing compile-time and run-time options.
53  */
54 struct sudo_defs_types {
55     char *name;
56     int type;
57     char *desc;
58     union {
59         int flag;
60         int ival;
61         char *str;
62         mode_t mode;
63         struct list_member *list;
64     } sd_un;
65 };
66
67 /*
68  * Four types of defaults: strings, integers, and flags.
69  * Also, T_INT or T_STR may be ANDed with T_BOOL to indicate that
70  * a value is not required.  Flags are boolean by nature...
71  */
72 #undef T_INT
73 #define T_INT           0x001
74 #undef T_UINT
75 #define T_UINT          0x002
76 #undef T_STR
77 #define T_STR           0x003
78 #undef T_FLAG
79 #define T_FLAG          0x004
80 #undef T_MODE
81 #define T_MODE          0x005
82 #undef T_LIST
83 #define T_LIST          0x006
84 #undef T_LOGFAC
85 #define T_LOGFAC        0x007
86 #undef T_LOGPRI
87 #define T_LOGPRI        0x008
88 #undef T_PWFLAG
89 #define T_PWFLAG        0x009
90 #undef T_MASK
91 #define T_MASK          0x0FF
92 #undef T_BOOL
93 #define T_BOOL          0x100
94 #undef T_PATH
95 #define T_PATH          0x200
96
97 /*
98  * Indexes into sudo_defs_table
99  */
100 #include <def_data.h>
101 #define I_LOGFAC        I_SYSLOG_IFAC
102 #define I_GOODPRI       I_SYSLOG_IGOODPRI
103 #define I_BADPRI        I_SYSLOG_IBADPRI 
104
105 /*
106  * Macros for accessing sudo_defs_table.
107  */
108 #define def_flag(_i)    (sudo_defs_table[(_i)].sd_un.flag)
109 #define def_ival(_i)    (sudo_defs_table[(_i)].sd_un.ival)
110 #define def_str(_i)     (sudo_defs_table[(_i)].sd_un.str)
111 #define def_list(_i)    (sudo_defs_table[(_i)].sd_un.list)
112 #define def_mode(_i)    (sudo_defs_table[(_i)].sd_un.mode)
113
114 /*
115  * Prototypes
116  */
117 void dump_default       __P((void));
118 int set_default         __P((char *, char *, int));
119 void init_defaults      __P((void));
120 void list_options       __P((void));
121
122 extern struct sudo_defs_types sudo_defs_table[];
123
124 #endif /* _SUDO_DEFAULTS_H */