~tieto/+junk/cfengine3

« back to all changes in this revision

Viewing changes to src/mod_common.c

  • Committer: Bazaar Package Importer
  • Author(s): Antonio Radici
  • Date: 2010-06-09 23:14:56 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100609231456-fsfppubmvvx4hntk
Tags: 3.0.5+dfsg-1
* New upstream release
* debian/watch: modified again to catch the newest versions
* debian/patches:
  + all patches: refreshed
  + cf-monitor-pid: removed, it is upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#include "cf3.defs.h"
37
37
#include "cf3.extern.h"
38
38
 
39
 
 
40
 
/*********************************************************/
41
 
/* FnCalls are rvalues in certain promise constraints    */
42
 
/*********************************************************/
43
 
 
44
 
/* see cf3.defs.h enum fncalltype */
45
 
 
46
 
struct FnCallType CF_FNCALL_TYPES[] = 
47
 
   {
48
 
   {"accessedbefore",cf_class,2,"True if arg1 was accessed before arg2 (atime)"},
49
 
   {"accumulated",cf_int,6,"Convert an accumulated amount of time into a system representation"},
50
 
   {"ago",cf_int,6,"Convert a time relative to now to an integer system representation"},
51
 
   {"canonify",cf_str,1,"Convert an abitrary string into a legal class name"},
52
 
   {"changedbefore",cf_class,2,"True if arg1 was changed before arg2 (ctime)"},
53
 
   {"classify",cf_class,1,"True if the canonicalization of the argument is a currently defined class"},
54
 
   {"classmatch",cf_class,1,"True if the regular expression matches any currently defined class"},
55
 
   {"countclassesmatching",cf_int,1,"Count the number of defined classes matching regex arg1"},
56
 
   {"countlinesmatching",cf_int,2,"Count the number of lines matching regex arg1 in file arg2"},
57
 
   {"diskfree",cf_int,1,"Return the free space (in KB) available on the directory's current partition (0 if not found)"},
58
 
   {"escape",cf_str,1,"Escape regular expression characters in a string"},
59
 
   {"execresult",cf_str,2,"Execute named command and assign output to variable"},
60
 
   {"fileexists",cf_class,1,"True if the named file can be accessed"},
61
 
   {"filesexist",cf_class,1,"True if the named list of files can ALL be accessed"},
62
 
   {"getfields",cf_int,4,"Get an array of fields in the lines matching regex arg1 in file arg2, split on regex arg3 as array name arg4"},
63
 
   {"getindices",cf_slist,1,"Get a list of keys to the array whose id is the argument and assign to variable"},
64
 
   {"getenv",cf_str,2,"Return the environment variable named arg1, truncated at arg2 characters"},
65
 
   {"getgid",cf_int,1,"Return the integer group id of the named group on this host"},
66
 
   {"getuid",cf_int,1,"Return the integer user id of the named user on this host"},
67
 
   {"grep",cf_str,2,"Extract the sub-list if items matching the regular expression in arg1 of the list named in arg2"},
68
 
   {"groupexists",cf_class,1,"True if group or numerical id exists on this host"},
69
 
   {"hash",cf_str,2,"Return the hash of arg1, type arg2 and assign to a variable"},
70
 
   {"hashmatch",cf_class,3,"Compute the hash of arg1, of type arg2 and test if it matches the value in arg 3"},
71
 
   {"host2ip",cf_str,1,"Returns the primary name-service IP address for the named host"},
72
 
   {"hostinnetgroup",cf_class,1,"True if the current host is in the named netgroup"},
73
 
   {"hostrange",cf_class,2,"True if the current host lies in the range of enumerated hostnames specified"},
74
 
   {"hostsseen",cf_str,3,"Extract the list of hosts last seen/not seen within the last arg1 minutes"},
75
 
   {"iprange",cf_class,1,"True if the current host lies in the range of IP addresses specified"},
76
 
   {"irange",cf_irange,2,"Define a range of integer values for cfengine internal use"},
77
 
   {"isdir",cf_class,1,"True if the named object is a directory"},
78
 
   {"isgreaterthan",cf_class,2,"True if arg1 is numerically greater than arg2, else compare strings like strcmp"},
79
 
   {"islessthan",cf_class,2,"True if arg1 is numerically less than arg2, else compare strings like NOT strcmp"},
80
 
   {"islink",cf_class,1,"True if the named object is a symbolic link"},
81
 
   {"isnewerthan",cf_class,2,"True if arg1 is newer (modified later) than arg2 (mtime)"},
82
 
   {"isplain",cf_class,1,"True if the named object is a plain/regular file"},
83
 
   {"isvariable",cf_class,1,"True if the named variable is defined"},
84
 
   {"join",cf_str,2,"Join the items of arg2 into a string, using the conjunction in arg1"},
85
 
   {"lastnode",cf_str,2,"Extract the last of a separated string, e.g. filename from a path"},
86
 
   {"ldaparray",cf_class,6,"Extract all values from an ldap record"},
87
 
   {"ldaplist",cf_slist,6,"Extract all named values from multiple ldap records"},
88
 
   {"ldapvalue",cf_str,6,"Extract the first matching named value from ldap"},
89
 
   {"now",cf_int,0,"Convert the current time into system representation"},
90
 
   {"on",cf_int,6,"Convert an exact date/time to an integer system representation"},
91
 
   {"peers",cf_slist,3,"Get a list of peers (not including ourself) from the partition to which we belong"},
92
 
   {"peerleader",cf_str,3,"Get the assigned peer-leader of the partition to which we belong"},
93
 
   {"peerleaders",cf_slist,3,"Get a list of peer leaders from the named partitioning"},
94
 
   {"randomint",cf_int,2,"Generate a random integer between the given limits"},
95
 
   {"readfile",cf_str,2,"Read max number of bytes from named file and assign to variable"},
96
 
   {"readintarray",cf_int,6,"Read an array of integers from a file and assign the dimension to a variable"},
97
 
   {"readintlist",cf_ilist,5,"Read and assign a list variable from a file of separated ints"},
98
 
   {"readrealarray",cf_int,6,"Read an array of real numbers from a file and assign the dimension to a variable"},
99
 
   {"readreallist",cf_rlist,5,"Read and assign a list variable from a file of separated real numbers"},
100
 
   {"readstringarray",cf_int,6,"Read an array of strings from a file and assign the dimension to a variable"},
101
 
   {"readstringlist",cf_slist,5,"Read and assign a list variable from a file of separated strings"},
102
 
   {"readtcp",cf_str,4,"Connect to tcp port, send string and assign result to variable"},
103
 
   {"regarray",cf_class,2,"True if arg1 matches any item in the associative array with id=arg2"},
104
 
   {"regcmp",cf_class,2,"True if arg1 is a regular expression matching that matches string arg2"},
105
 
   {"regextract",cf_class,3,"True if the regular expression in arg 1 matches the string in arg2 and sets a non-empty array of backreferences named arg3"},
106
 
   {"registryvalue",cf_str,2,"Returns a value for an MS-Win registry key,value pair"},
107
 
   {"regline",cf_class,2,"True if the regular expression in arg1 matches a line in file arg2"},
108
 
   {"reglist",cf_class,2,"True if the regular expression in arg2 matches any item in the list whose id is arg1"},
109
 
   {"regldap",cf_class,7,"True if the regular expression in arg6 matches a value item in an ldap search"},
110
 
   {"remotescalar",cf_str,3,"Read a scalar value from a remote cfengine server"},
111
 
   {"remoteclassesmatching",cf_class,4,"Read persistent classes matching a regular expression from a remote cfengine server and add them into local context with prefix"},
112
 
   {"returnszero",cf_class,2,"True if named shell command has exit status zero"},
113
 
   {"rrange",cf_rrange,2,"Define a range of real numbers for cfengine internal use"},
114
 
   {"selectservers",cf_int,6,"Select tcp servers which respond correctly to a query and return their number, set array of names"},
115
 
   {"splayclass",cf_class,2,"True if the first argument's time-slot has arrived, according to a policy in arg2"},
116
 
   {"splitstring",cf_slist,3,"Convert a string in arg1 into a list of max arg3 strings by splitting on a regular expression in arg2"},
117
 
   {"strcmp",cf_class,2,"True if the two strings match exactly"},
118
 
   {"translatepath",cf_str,1,"Translate path separators from Unix style to the host's native"},
119
 
   {"usemodule",cf_class,2,"Execute cfengine module script and set class if successful"},
120
 
   {"userexists",cf_class,1,"True if user name or numerical id exists on this host"},
121
 
   {NULL,cf_notype,0,NULL}
122
 
   };
123
 
 
124
 
/*********************************************************/
125
 
 
126
39
struct BodySyntax CF_TRANSACTION_BODY[] =
127
40
   {
128
41
   {"action_policy",cf_opts,"fix,warn,nop","Whether to repair or report about non-kept promises"},
148
61
 
149
62
struct BodySyntax CF_DEFINECLASS_BODY[] =
150
63
   {
151
 
   {"promise_repaired",cf_slist,CF_IDRANGE,"A list of classes to be defined"},
152
 
   {"repair_failed",cf_slist,CF_IDRANGE,"A list of classes to be defined"},
153
 
   {"repair_denied",cf_slist,CF_IDRANGE,"A list of classes to be defined"},
154
 
   {"repair_timeout",cf_slist,CF_IDRANGE,"A list of classes to be defined"},
155
 
   {"promise_kept",cf_slist,CF_IDRANGE,"A list of classes to be defined"},
 
64
   {"promise_repaired",cf_slist,CF_IDRANGE,"A list of classes to be defined globally"},
 
65
   {"repair_failed",cf_slist,CF_IDRANGE,"A list of classes to be defined globally"},
 
66
   {"repair_denied",cf_slist,CF_IDRANGE,"A list of classes to be defined globally"},
 
67
   {"repair_timeout",cf_slist,CF_IDRANGE,"A list of classes to be defined globally"},
 
68
   {"promise_kept",cf_slist,CF_IDRANGE,"A list of classes to be defined globally"},
156
69
   {"cancel_kept",cf_slist,CF_IDRANGE,"A list of classes to be cancelled if the promise is kept"},
157
70
   {"cancel_repaired",cf_slist,CF_IDRANGE,"A list of classes to be cancelled if the promise is repaired"},
158
71
   {"cancel_notkept",cf_slist,CF_IDRANGE,"A list of classes to be cancelled if the promise is not kept for any reason"},
226
139
   {"dryrun",cf_opts,CF_BOOL,"All talk and no action mode"},
227
140
   {"editbinaryfilesize",cf_int,CF_VALRANGE,"Integer limit on maximum binary file size to be edited"},
228
141
   {"editfilesize",cf_int,CF_VALRANGE,"Integer limit on maximum text file size to be edited"},
229
 
   {"environment",cf_slist,"[A-Za-z_]+=.*","List of environment variables to be inherited by children"},
 
142
   {"environment",cf_slist,"[A-Za-z0-9_]+=.*","List of environment variables to be inherited by children"},
230
143
   {"exclamation",cf_opts,CF_BOOL,"true/false print exclamation marks during security warnings"},
231
144
   {"expireafter",cf_int,CF_VALRANGE,"Global default for time before on-going promise repairs are interrupted"},
232
145
   {"files_single_copy",cf_slist,"","List of filenames to be watched for multiple-source conflicts"},
233
146
   {"files_auto_define",cf_slist,"","List of filenames to define classes if copied"},
234
 
   {"fullencryption",cf_opts,CF_BOOL,"Full encryption mode in server connections, includes directory listings"},
235
147
   {"hostnamekeys",cf_opts,CF_BOOL,"true/false label ppkeys by hostname not IP address"},
236
148
   {"ifelapsed",cf_int,CF_VALRANGE,"Global default for time that must elapse before promise will be rechecked"},
237
149
   {"inform",cf_opts,CF_BOOL,"true/false set inform level default"},
238
 
   {"lastseen",cf_opts,CF_BOOL,"true/false record last observed times for each client-server connections for intermittency modelling"},
239
150
   {"intermittency",cf_opts,CF_BOOL,"true/false store detailed recordings of last observed time for all client-server connections for reliability assessment (false)"},
240
151
   {"max_children",cf_int,CF_VALRANGE,"Maximum number of background tasks that should be allowed concurrently"},
241
152
   {"maxconnections",cf_int,CF_VALRANGE,"Maximum number of outgoing connections to cf-serverd"},
264
175
   {"allowconnects",cf_slist,"","List of IPs or hostnames that may connect to the server port"},
265
176
   {"denyconnects",cf_slist,"","List of IPs or hostnames that may NOT connect to the server port"},
266
177
   {"allowallconnects",cf_slist,"","List of IPs or hostnames that may have more than one connection to the server port"},
267
 
   {"trustkeysfrom",cf_slist,"","List of IPs or hostnames from whom we accept public keys on trust"},
 
178
   {"trustkeysfrom",cf_slist,"","List of IPs from whom we accept public keys on trust"},
268
179
   {"allowusers",cf_slist,"","List of usernames who may execute requests from this server"},
269
180
   {"dynamicaddresses",cf_slist,"","List of IPs or hostnames for which the IP/name binding is expected to change"},
270
181
   {"skipverify",cf_slist,"","List of IPs or hostnames for which we expect no DNS binding and cannot verify"},
317
228
 
318
229
struct BodySyntax CFK_CONTROLBODY[] =
319
230
   {
 
231
   {"build_directory",cf_str,".*","The directory in which to generate output files"},
 
232
   {"generate_manual",cf_opts,CF_BOOL,"true/false generate texinfo manual page skeleton for this version"},
 
233
   {"graph_directory",cf_str,CF_PATHRANGE,"Path to directory where rendered .png files will be created"},
 
234
   {"graph_output",cf_opts,CF_BOOL,"true/false generate png visualization of topic map if possible (requires lib)"},
 
235
   {"html_banner",cf_str,"","HTML code for a banner to be added to rendered in html after the header"},
 
236
   {"html_footer",cf_str,"","HTML code for a page footer to be added to rendered in html before the end body tag"},
320
237
   {"id_prefix",cf_str,".*","The LTM identifier prefix used to label topic maps (used for disambiguation in merging)"},
321
 
   {"build_directory",cf_str,".*","The directory in which to generate output files"},
 
238
   {"manual_source_directory",cf_str,CF_PATHRANGE,"Path to directory where raw text about manual topics is found (defaults to build_directory)"},
 
239
   {"query_engine",cf_str,"","Name of a dynamic web-page used to accept and drive queries in a browser"},
 
240
   {"query_output",cf_opts,"html,text","Menu option for generated output format"},
322
241
   {"sql_type",cf_opts,"mysql,postgres","Menu option for supported database type"},
323
242
   {"sql_database",cf_str,"","Name of database used for the topic map"},
324
243
   {"sql_owner",cf_str,"","User id of sql database user"},
325
244
   {"sql_passwd",cf_str,"","Embedded password for accessing sql database"},
326
245
   {"sql_server",cf_str,"","Name or IP of database server (or localhost)"},
327
246
   {"sql_connection_db",cf_str,"","The name of an existing database to connect to in order to create/manage other databases"},
328
 
   {"query_output",cf_opts,"html,text","Menu option for generated output format"},
329
 
   {"query_engine",cf_str,"","Name of a dynamic web-page used to accept and drive queries in a browser"},
330
247
   {"style_sheet",cf_str,"","Name of a style-sheet to be used in rendering html output (added to headers)"},
331
 
   {"html_banner",cf_str,"","HTML code for a banner to be added to rendered in html after the header"},
332
 
   {"html_footer",cf_str,"","HTML code for a page footer to be added to rendered in html before the end body tag"},
333
 
   {"graph_output",cf_opts,CF_BOOL,"true/false generate png visualization of topic map if possible (requires lib)"},
334
 
   {"graph_directory",cf_str,CF_PATHRANGE,"Path to directory where rendered .png files will be created"},
335
 
   {"generate_manual",cf_opts,CF_BOOL,"true/false generate texinfo manual page skeleton for this version"},
336
 
   {"manual_source_directory",cf_str,CF_PATHRANGE,"Path to directory where raw text about manual topics is found (defaults to build_directory)"},
337
248
   {"view_projections",cf_opts,CF_BOOL,"Perform view-projection analytics in graph generation"},
338
249
   {NULL,cf_notype,NULL,NULL}
339
250
   };
352
263
   {"reports",cf_olist,"all,audit,performance,all_locks,active_locks,hashes,classes,last_seen,monitor_now,monitor_history,monitor_summary,compliance,setuid,file_changes,installed_software,software_patches,value,variables","A list of reports that may be generated"},
353
264
   {"report_output",cf_opts,"csv,html,text,xml","Menu option for generated output format. Applies only to text reports, graph data remain in xydy format."},
354
265
   {"style_sheet",cf_str,"","Name of a style-sheet to be used in rendering html output (added to headers)"},
355
 
   {"time_stamps",cf_opts,CF_BOOL,"true/false whether to generate timestamps on the output directory"},
 
266
   {"time_stamps",cf_opts,CF_BOOL,"true/false whether to generate timestamps in the output directory name"},
356
267
   {NULL,cf_notype,NULL,NULL}
357
268
   };
358
269
 
411
322
     {"*","classes",CF_CLASSBODY},
412
323
     {"*","reports",CF_REPORT_BODIES},
413
324
     {"agent","*",CF_COMMON_BODIES},
414
 
     {"edit_line","*",CF_COMMON_EDITBODIES},
415
325
     {NULL,NULL,NULL}
416
326
     };
417
327
 
424
334
 
425
335
struct SubTypeSyntax *CF_ALL_SUBTYPES[CF3_MODULES] =
426
336
   {
427
 
   CF_COMMON_SUBTYPES,     /* Add modules after this, mod_report.c is here */
428
 
   CF_EXEC_SUBTYPES,       /* mod_exec.c */
429
 
   CF_DATABASES_SUBTYPES,  /* mod_databases.c */
430
 
   CF_FILES_SUBTYPES,      /* mod_files.c */
431
 
   CF_INTERFACES_SUBTYPES, /* mod_interfaces.c */
432
 
   CF_METHOD_SUBTYPES,     /* mod_methods.c */
433
 
   CF_PACKAGES_SUBTYPES,   /* mod_packages.c */
434
 
   CF_PROCESS_SUBTYPES,    /* mod_process.c */
435
 
   CF_SERVICES_SUBTYPES,   /* mod_services.c */
436
 
   CF_STORAGE_SUBTYPES,    /* mod_storage.c */
437
 
   CF_REMACCESS_SUBTYPES,  /* mod_access.c */
438
 
   CF_KNOWLEDGE_SUBTYPES,  /* mod_knowledge.c */
439
 
   CF_MEASUREMENT_SUBTYPES,/* mod_measurement.c */
 
337
   CF_COMMON_SUBTYPES,       /* Add modules after this, mod_report.c is here */
 
338
   CF_EXEC_SUBTYPES,         /* mod_exec.c */
 
339
   CF_DATABASES_SUBTYPES,    /* mod_databases.c */
 
340
   CF_ENVIRONMENT_SUBTYPES,  /* mod_environ.c */
 
341
   CF_FILES_SUBTYPES,        /* mod_files.c */
 
342
   CF_INTERFACES_SUBTYPES,   /* mod_interfaces.c */
 
343
   CF_METHOD_SUBTYPES,       /* mod_methods.c */
 
344
   CF_OUTPUTS_SUBTYPES,      /* mod_outputs.c */
 
345
   CF_PACKAGES_SUBTYPES,     /* mod_packages.c */
 
346
   CF_PROCESS_SUBTYPES,      /* mod_process.c */
 
347
   CF_SERVICES_SUBTYPES,     /* mod_services.c */
 
348
   CF_STORAGE_SUBTYPES,      /* mod_storage.c */
 
349
   CF_REMACCESS_SUBTYPES,    /* mod_access.c */
 
350
   CF_KNOWLEDGE_SUBTYPES,    /* mod_knowledge.c */
 
351
   CF_MEASUREMENT_SUBTYPES,  /* mod_measurement.c */
440
352
   
441
353
   /* update CF3_MODULES in cf3.defs.h */
442
354
   };