cfengine  3.15.4
About: CFEngine is a configuration management system for configuring and maintaining Unix-like computers (using an own high level policy language). Community version.
  Fossies Dox: cfengine-3.15.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

generic_agent.h
Go to the documentation of this file.
1 /*
2  Copyright 2019 Northern.tech AS
3 
4  This file is part of CFEngine 3 - written and maintained by Northern.tech AS.
5 
6  This program is free software; you can redistribute it and/or modify it
7  under the terms of the GNU General Public License as published by the
8  Free Software Foundation; version 3.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
18 
19  To the extent this program is licensed as part of the Enterprise
20  versions of CFEngine, the applicable Commercial Open Source License
21  (COSL) may apply to this file if you as a licensee so wish it. See
22  included file COSL.txt.
23 */
24 
25 #ifndef CFENGINE_GENERIC_AGENT_H
26 #define CFENGINE_GENERIC_AGENT_H
27 
28 #include <cf3.defs.h>
29 
30 #include <policy.h>
31 #include <set.h>
32 
33 #define GENERIC_AGENT_CHECKSUM_SIZE ((2*CF_SHA1_LEN) + 1)
34 #define GENERIC_AGENT_CHECKSUM_METHOD HASH_METHOD_SHA1
35 
37 {
43 };
44 
45 typedef struct
46 {
48 
50 
52  char *input_file;
53  char *input_dir;
55 
58 
62 
63  bool tty_interactive; // agent is running interactively, via tty/terminal interface
64  bool color;
65 
67 
68  // agent state
71 
72  struct
73  {
74  struct
75  {
76  enum generic_agent_config_common_policy_output_format policy_output_format;
77  unsigned int parser_warnings;
78  unsigned int parser_warnings_error;
80  char *show_classes;
82  } common;
83  struct
84  {
88  char *bootstrap_ip;
93 
94  // BODY AGENT CONTROL
96  } agent;
97  struct
98  {
99  /* Time of the last validated_at timestamp seen. */
101  } daemon; /* execd, serverd etc */
102  } agent_specific;
103 
105 
107 const char *GenericAgentResolveInputPath(const GenericAgentConfig *config, const char *input_file);
109 void GenericAgentDiscoverContext(EvalContext *ctx, GenericAgentConfig *config, const char *program_name);
110 bool GenericAgentCheckPolicy(GenericAgentConfig *config, bool force_validation, bool write_validated_file);
111 
117 time_t ReadTimestampFromPolicyValidatedFile(const GenericAgentConfig *config, const char *maybe_dirname);
118 
120 
121 void CloseLog(void);
122 Seq *ControlBodyConstraints(const Policy *policy, AgentType agent);
123 
124 void SetFacility(const char *retval);
125 void CheckBundleParameters(char *scope, Rlist *args);
126 void WritePID(char *filename);
127 
128 bool GenericAgentConfigParseArguments(GenericAgentConfig *config, int argc, char **argv);
129 bool GenericAgentConfigParseWarningOptions(GenericAgentConfig *config, const char *warning_options);
130 bool GenericAgentConfigParseColor(GenericAgentConfig *config, const char *mode);
131 
132 Policy *SelectAndLoadPolicy(GenericAgentConfig *config, EvalContext *ctx, bool validate_policy, bool write_validated_file);
133 GenericAgentConfig *GenericAgentConfigNewDefault(AgentType agent_type, bool tty_interactive);
134 bool GetTTYInteractive(void);
136 void GenericAgentConfigApply(EvalContext *ctx, const GenericAgentConfig *config);
137 
138 bool CheckAndGenerateFailsafe(const char *inputdir, const char *input_file);
139 void GenericAgentConfigSetInputFile(GenericAgentConfig *config, const char *inputdir, const char *input_file);
140 void GenericAgentConfigSetBundleSequence(GenericAgentConfig *config, const Rlist *bundlesequence);
141 bool GenericAgentTagReleaseDirectory(const GenericAgentConfig *config, const char *dirname, bool write_validated, bool write_release);
142 
143 void GetReleaseIdFile(const char *base_path, char *filename, size_t max_size);
144 
145 bool GenericAgentPostLoadInit(const EvalContext *ctx);
146 
147 void SetupSignalsForAgent(void);
148 
149 void LoadAugments(EvalContext *ctx, GenericAgentConfig *config);
150 
151 void GenericAgentShowContextsFormatted(EvalContext *ctx, const char *regexp);
152 void GenericAgentShowVariablesFormatted(EvalContext *ctx, const char *regexp);
153 
154 #endif
AgentType
Definition: cf3.defs.h:400
#define ENTERPRISE_VOID_FUNC_2ARG_DECLARE(__ret, __func, __t1, __p1, __t2, __p2)
#define ENTERPRISE_VOID_FUNC_1ARG_DECLARE(__ret, __func, __t1, __p1)
bool GenericAgentConfigParseWarningOptions(GenericAgentConfig *config, const char *warning_options)
void GenericAgentConfigSetInputFile(GenericAgentConfig *config, const char *inputdir, const char *input_file)
void SetFacility(const char *retval)
bool GenericAgentArePromisesValid(const GenericAgentConfig *config)
bool GenericAgentIsPolicyReloadNeeded(const GenericAgentConfig *config)
GenericAgentConfig * GenericAgentConfigNewDefault(AgentType agent_type, bool tty_interactive)
bool GenericAgentPostLoadInit(const EvalContext *ctx)
Policy * SelectAndLoadPolicy(GenericAgentConfig *config, EvalContext *ctx, bool validate_policy, bool write_validated_file)
bool GenericAgentCheckPolicy(GenericAgentConfig *config, bool force_validation, bool write_validated_file)
void GenericAgentConfigSetBundleSequence(GenericAgentConfig *config, const Rlist *bundlesequence)
void CheckBundleParameters(char *scope, Rlist *args)
void SetupSignalsForAgent(void)
void GenericAgentSetDefaultDigest(HashMethod *digest, int *digest_len)
void WritePID(char *filename)
void GetReleaseIdFile(const char *base_path, char *filename, size_t max_size)
Gets the release_id file name in the given base_path.
const char * GenericAgentResolveInputPath(const GenericAgentConfig *config, const char *input_file)
time_t ReadTimestampFromPolicyValidatedFile(const GenericAgentConfig *config, const char *maybe_dirname)
void GenericAgentShowContextsFormatted(EvalContext *ctx, const char *regexp)
Seq * ControlBodyConstraints(const Policy *policy, AgentType agent)
void CloseLog(void)
void GenericAgentConfigDestroy(GenericAgentConfig *config)
void LoadAugments(EvalContext *ctx, GenericAgentConfig *config)
void GenericAgentFinalize(EvalContext *ctx, GenericAgentConfig *config)
generic_agent_config_common_policy_output_format
Definition: generic_agent.h:37
@ GENERIC_AGENT_CONFIG_COMMON_POLICY_OUTPUT_FORMAT_JSON_FULL
Definition: generic_agent.h:42
@ GENERIC_AGENT_CONFIG_COMMON_POLICY_OUTPUT_FORMAT_CF_FULL
Definition: generic_agent.h:41
@ GENERIC_AGENT_CONFIG_COMMON_POLICY_OUTPUT_FORMAT_JSON
Definition: generic_agent.h:40
@ GENERIC_AGENT_CONFIG_COMMON_POLICY_OUTPUT_FORMAT_NONE
Definition: generic_agent.h:38
@ GENERIC_AGENT_CONFIG_COMMON_POLICY_OUTPUT_FORMAT_CF
Definition: generic_agent.h:39
bool GenericAgentTagReleaseDirectory(const GenericAgentConfig *config, const char *dirname, bool write_validated, bool write_release)
Writes the policy validation file and release ID to a directory.
bool CheckAndGenerateFailsafe(const char *inputdir, const char *input_file)
void GenericAgentDiscoverContext(EvalContext *ctx, GenericAgentConfig *config, const char *program_name)
void GenericAgentShowVariablesFormatted(EvalContext *ctx, const char *regexp)
void GenericAgentInitialize(EvalContext *ctx, GenericAgentConfig *config)
void MarkAsPolicyServer(EvalContext *ctx)
void GenericAgentAddEditionClasses(EvalContext *ctx)
bool GenericAgentConfigParseArguments(GenericAgentConfig *config, int argc, char **argv)
bool GetTTYInteractive(void)
bool GenericAgentConfigParseColor(GenericAgentConfig *config, const char *mode)
void GenericAgentConfigApply(EvalContext *ctx, const GenericAgentConfig *config)
void GenericAgentWriteVersion(Writer *w)
HashMethod
Definition: hash_method.h:36
ProtocolVersion
unsigned int parser_warnings
Definition: generic_agent.h:77
StringSet * heap_soft
Definition: generic_agent.h:59
char * show_evaluated_variables
Definition: generic_agent.h:92
char * original_input_file
Definition: generic_agent.h:51
bool check_not_writable_by_others
Definition: generic_agent.h:56
AgentType agent_type
Definition: generic_agent.h:47
ProtocolVersion protocol_version
Definition: generic_agent.h:66
StringSet * heap_negated
Definition: generic_agent.h:60
char * show_evaluated_classes
Definition: generic_agent.h:91
unsigned int parser_warnings_error
Definition: generic_agent.h:78
Definition: policy.h:53
Definition: rlist.h:35
Sequence data-structure.
Definition: sequence.h:50
Definition: set.h:138
Definition: writer.c:45