-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcfengine.h
241 lines (204 loc) · 4.98 KB
/
cfengine.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
// Stripped down version of cf3.defs.h retrieved from https://github.com/cfengine/core/blob/master/libpromises/cf3.defs.h
typedef struct Writer_ Writer;
typedef struct Policy_ Policy;
typedef struct Bundle_ Bundle;
typedef struct Body_ Body;
typedef struct SubType_ SubType;
typedef struct Rlist_ Rlist;
typedef struct Constraint_ Constraint;
typedef struct Item_ Item;
typedef struct CompressedArray_ CompressedArray;
typedef struct Audit_ Audit;
typedef struct Stat_ Stat;
typedef struct _Promise Promise;
typedef enum
{
POLICY_ELEMENT_TYPE_BUNDLE,
POLICY_ELEMENT_TYPE_BODY,
POLICY_ELEMENT_TYPE_SUBTYPE,
POLICY_ELEMENT_TYPE_PROMISE,
POLICY_ELEMENT_TYPE_CONSTRAINT
} PolicyElementType;
enum cfagenttype
{
cf_common,
cf_agent,
cf_server,
cf_monitor,
cf_executor,
cf_runagent,
cf_know,
cf_report,
cf_keygen,
cf_hub,
cf_gendoc,
cf_noagent
};
enum cf_filetype
{
cf_reg,
cf_link,
cf_dir,
cf_fifo,
cf_block,
cf_char,
cf_sock
};
typedef enum
{
REPORT_OUTPUT_TYPE_TEXT,
REPORT_OUTPUT_TYPE_HTML,
REPORT_OUTPUT_TYPE_KNOWLEDGE,
REPORT_OUTPUT_TYPE_MAX
} ReportOutputType;
typedef struct
{
Writer *report_writers[REPORT_OUTPUT_TYPE_MAX];
} ReportContext;
struct CompressedArray_
{
int key;
char *value;
CompressedArray *next;
};
typedef struct
{
char *filename;
Item *file_start;
Item *file_classes;
int num_edits;
int empty_first;
#ifdef HAVE_LIBXML2
xmlDocPtr xmldoc;
#endif
} EditContext;
#define CF_SMALLBUF 128
#define CF_MAX_IP_LEN 64
#define EVP_MAX_MD_SIZE
struct Rlist_
{
void *item;
char type;
Rlist *state_ptr;
Rlist *next;
};
typedef struct
{
size_t start;
size_t end;
size_t line;
size_t context;
} SourceOffset;
struct Audit_
{
char *version;
char *filename;
char *date;
unsigned char digest[100 + 1];
Audit *next;
};
typedef struct
{
void *item;
char rtype;
} Rval;
typedef struct
{
int sd;
int trust;
int authenticated;
int protoversion;
int family;
char username[CF_SMALLBUF];
char localip[CF_MAX_IP_LEN];
char remoteip[CF_MAX_IP_LEN];
unsigned char digest[EVP_MAX_MD_SIZE + 1];
unsigned char *session_key;
char encryption_type;
short error;
} AgentConnection;
struct Stat_
{
char *cf_filename; /* What file are we statting? */
char *cf_server; /* Which server did this come from? */
enum cf_filetype cf_type; /* enum filetype */
mode_t cf_lmode; /* Mode of link, if link */
mode_t cf_mode; /* Mode of remote file, not link */
uid_t cf_uid; /* User ID of the file's owner */
gid_t cf_gid; /* Group ID of the file's group */
off_t cf_size; /* File size in bytes */
time_t cf_atime; /* Time of last access */
time_t cf_mtime; /* Time of last data modification */
time_t cf_ctime; /* Time of last file status change */
char cf_makeholes; /* what we need to know from blksize and blks */
char *cf_readlink; /* link value or NULL */
int cf_failed; /* stat returned -1 */
int cf_nlink; /* Number of hard links */
int cf_ino; /* inode number on server */
dev_t cf_dev; /* device number */
Stat *next;
};
struct _Promise
{
SubType *parent_subtype;
char *classes;
char *ref; /* comment */
char ref_alloc;
char *promiser;
Rval promisee;
char *bundle;
Audit *audit;
Constraint *conlist;
Promise *next;
/* Runtime bus for private flags and work space */
char *agentsubtype; /* cache the promise subtype */
char *bundletype; /* cache the agent type */
char *namespace; /* cache the namespace */
int done; /* this needs to be preserved across runs */
int *donep; /* used by locks to mark as done */
int makeholes;
char *this_server;
int has_subbundles;
Stat *cache;
AgentConnection *conn;
CompressedArray *inode_cache;
EditContext *edcontext;
dev_t rootdevice; /* for caching during work */
const Promise *org_pp; /* A ptr to the unexpanded raw promise */
SourceOffset offset;
};
struct Bundle_
{
Policy *parent_policy;
char *type;
char *name;
char *namespace;
Rlist *args;
SubType *subtypes;
struct Bundle_ *next;
char *source_path;
SourceOffset offset;
};
struct SubType_
{
Bundle *parent_bundle;
char *name;
Promise *promiselist;
SubType *next;
SourceOffset offset;
};
struct Constraint_
{
PolicyElementType type;
union {
Promise *promise;
Body *body;
} parent;
char *lval;
Rval rval;
char *classes; /* only used within bodies */
bool references_body;
Audit *audit;
SourceOffset offset;
Constraint *next;
};