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)  

enterprise_stubs.c
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 #include <cf3.defs.h>
26 #include <known_dirs.h>
27 
28 #include <prototypes3.h>
29 #include <syntax.h>
30 #include <eval_context.h>
31 #include <file_lib.h>
32 
33 #include <enterprise_extension.h>
34 
35 /*
36  * This module contains numeruous functions which don't use all their parameters
37  *
38  * Temporarily, in order to avoid cluttering output with thousands of warnings,
39  * this module is excempted from producing warnings about unused function
40  * parameters.
41  *
42  * Please remove this #pragma ASAP and provide ARG_UNUSED declarations for
43  * unused parameters.
44  */
45 #if defined(__GNUC__)
46 #pragma GCC diagnostic ignored "-Wunused-parameter"
47 #endif
48 
49 extern int PR_KEPT;
50 extern int PR_REPAIRED;
51 extern int PR_NOTKEPT;
52 
54 {
55 }
56 
57 /* all agents: generic_agent.c */
58 
60 {
61  return "cf3";
62 }
63 
64 
65 /* all agents: sysinfo.c */
66 
68 {
69 }
70 
71 
72 /* all agents: logging.c */
73 
74 
75 ENTERPRISE_VOID_FUNC_2ARG_DEFINE_STUB(void, LogTotalCompliance, const char *, version, int, background_tasks)
76 {
77  double total = (double) (PR_KEPT + PR_NOTKEPT + PR_REPAIRED) / 100.0;
78 
79  char string[CF_BUFSIZE] = { 0 };
80 
81  snprintf(string, CF_BUFSIZE,
82  "Outcome of version %s (" CF_AGENTC "-%d): Promises observed to be kept %.2f%%, Promises repaired %.2f%%, Promises not repaired %.2f%%",
83  version, background_tasks,
84  (double) PR_KEPT / total,
85  (double) PR_REPAIRED / total,
86  (double) PR_NOTKEPT / total);
87 
88  Log(LOG_LEVEL_VERBOSE, "Logging total compliance, total '%s'", string);
89 
90  char filename[CF_BUFSIZE];
91  snprintf(filename, CF_BUFSIZE, "%s/%s", GetLogDir(), CF_PROMISE_LOG);
92  MapName(filename);
93 
94  FILE *fout = safe_fopen(filename, "a");
95  if (fout == NULL)
96  {
97  Log(LOG_LEVEL_ERR, "In total compliance logging, could not open file '%s'. (fopen: %s)", filename, GetErrorStr());
98  }
99  else
100  {
101  fprintf(fout, "%jd,%jd: %s\n", (intmax_t)CFSTARTTIME, (intmax_t)time(NULL), string);
102  fclose(fout);
103  }
104 }
105 
106 
107 /* network communication: cf-serverd.c, client_protocol.c, client_code.c, crypto.c */
108 
109 
111 {
112  return CF_BLOWFISHSIZE;
113 }
114 
116 {
117  return 'c';
118 }
119 
120 ENTERPRISE_FUNC_1ARG_DEFINE_STUB(const EVP_CIPHER *, CfengineCipher, char, type)
121 {
122  return EVP_bf_cbc();
123 }
124 
125 /* cf-agent: evalfunction.c */
126 
127 ENTERPRISE_FUNC_6ARG_DEFINE_STUB(char *, GetRemoteScalar, EvalContext *, ctx, char *, proto, char *, handle,
128  const char *, server, int, encrypted, char *, rcv)
129 {
130  Log(LOG_LEVEL_VERBOSE, "Access to server literals is only available in CFEngine Enterprise");
131  return "";
132 }
133 
134 ENTERPRISE_VOID_FUNC_3ARG_DEFINE_STUB(void, CacheUnreliableValue, char *, caller, char *, handle, char *, buffer)
135 {
136  Log(LOG_LEVEL_VERBOSE, "Value fault-tolerance only available in CFEngine Enterprise");
137 }
138 
139 ENTERPRISE_FUNC_3ARG_DEFINE_STUB(int, RetrieveUnreliableValue, char *, caller, char *, handle, char *, buffer)
140 {
141  Log(LOG_LEVEL_VERBOSE, "Value fault-tolerance only available in CFEngine Enterprise");
142  return false;
143 }
144 
145 #if defined(__MINGW32__)
146 ENTERPRISE_FUNC_4ARG_DEFINE_STUB(bool, GetRegistryValue, char *, key, char *, name, char *, buf, int, bufSz)
147 {
148  return 0;
149 }
150 #endif
151 
152 ENTERPRISE_FUNC_6ARG_DEFINE_STUB(void *, CfLDAPValue, char *, uri, char *, dn, char *, filter, char *, name, char *, scope, char *, sec)
153 {
154  Log(LOG_LEVEL_ERR, "LDAP support only available in CFEngine Enterprise");
155  return NULL;
156 }
157 
158 ENTERPRISE_FUNC_6ARG_DEFINE_STUB(void *, CfLDAPList, char *, uri, char *, dn, char *, filter, char *, name, char *, scope, char *, sec)
159 {
160  Log(LOG_LEVEL_ERR, "LDAP support only available in CFEngine Enterprise");
161  return NULL;
162 }
163 
164 ENTERPRISE_FUNC_8ARG_DEFINE_STUB(void *, CfLDAPArray, EvalContext *, ctx, const Bundle *, caller, char *, array, char *, uri, char *, dn,
165  char *, filter, char *, scope, char *, sec)
166 {
167  Log(LOG_LEVEL_ERR, "LDAP support only available in CFEngine Enterprise");
168  return NULL;
169 }
170 
171 ENTERPRISE_FUNC_8ARG_DEFINE_STUB(void *, CfRegLDAP, EvalContext *, ctx, char *, uri, char *, dn, char *, filter, char *, name, char *, scope, char *, regex, char *, sec)
172 {
173  Log(LOG_LEVEL_ERR, "LDAP support only available in CFEngine Enterprise");
174  return NULL;
175 }
176 
177 ENTERPRISE_FUNC_4ARG_DEFINE_STUB(bool, ListHostsWithClass, EvalContext *, ctx, Rlist **, return_list, char *, class_name, char *, return_format)
178 {
179  Log(LOG_LEVEL_ERR, "Host class counting is only available in CFEngine Enterprise");
180  return false;
181 }
182 
183 /* cf-serverd: server_transform.c, cf-serverd.c */
184 
185 ENTERPRISE_VOID_FUNC_2ARG_DEFINE_STUB(void, TranslatePath, char *, new, const char *, old)
186 {
187  strlcpy(new, old, CF_BUFSIZE);
188 }
189 
190 
192  ARG_UNUSED EvalContext *, ctx,
193  ARG_UNUSED const Promise *, pp,
195 {
196 }
197 
199 {
200 }
201 
203 {
204 }
205 
207 {
208  return 0;
209 }
210 
212  ARG_UNUSED const StringSet *, list,
213  ARG_UNUSED const char *, context_name)
214 {
215 }
216 
218  ARG_UNUSED StringSet **, list,
219  ARG_UNUSED bool, enable)
220 {
221 }
ENTERPRISE_VOID_FUNC_1ARG_DEFINE_STUB(void, Nova_TrackExecution, ARG_UNUSED const char *, input_file)
ENTERPRISE_FUNC_8ARG_DEFINE_STUB(PromiseResult, LogFileChange, ARG_UNUSED EvalContext *, ctx, ARG_UNUSED const char *, file, ARG_UNUSED int, change, ARG_UNUSED const Attributes *, attr, ARG_UNUSED const Promise *, pp, ARG_UNUSED CopyRegularFileFunction, CopyRegularFilePtr, ARG_UNUSED const char *, destination, ARG_UNUSED DeleteCompressedArrayFunction, DeleteCompressedArrayPtr)
#define ARG_UNUSED
Definition: cf-net.c:47
#define CF_AGENTC
Definition: cf3.defs.h:391
PromiseResult
Definition: cf3.defs.h:122
#define CF_PROMISE_LOG
Definition: cf3.defs.h:93
time_t CFSTARTTIME
Definition: cf3globals.c:99
#define CF_BUFSIZE
Definition: definitions.h:50
#define CF_BLOWFISHSIZE
Definition: definitions.h:34
#define ENTERPRISE_FUNC_1ARG_DEFINE_STUB(__ret, __func, __t1, __p1)
#define ENTERPRISE_FUNC_0ARG_DEFINE_STUB(__ret, __func)
#define ENTERPRISE_FUNC_4ARG_DEFINE_STUB(__ret, __func, __t1, __p1, __t2, __p2, __t3, __p3, __t4, __p4)
#define ENTERPRISE_VOID_FUNC_0ARG_DEFINE_STUB(__ret, __func)
#define ENTERPRISE_FUNC_6ARG_DEFINE_STUB(__ret, __func, __t1, __p1, __t2, __p2, __t3, __p3, __t4, __p4, __t5, __p5, __t6, __p6)
#define ENTERPRISE_VOID_FUNC_2ARG_DEFINE_STUB(__ret, __func, __t1, __p1, __t2, __p2)
#define ENTERPRISE_FUNC_3ARG_DEFINE_STUB(__ret, __func, __t1, __p1, __t2, __p2, __t3, __p3)
#define ENTERPRISE_VOID_FUNC_3ARG_DEFINE_STUB(__ret, __func, __t1, __p1, __t2, __p2, __t3, __p3)
void LogTotalCompliance(const char *version, int background_tasks)
void Nova_Initialize(EvalContext *ctx)
void * CfLDAPList(char *uri, char *dn, char *filter, char *name, char *scope, char *sec)
void EvalContextLogPromiseIterationOutcome(EvalContext *ctx, const Promise *pp, PromiseResult result)
void * CfLDAPValue(char *uri, char *dn, char *filter, char *name, char *scope, char *sec)
void EnterpriseContext(EvalContext *ctx)
bool ListHostsWithClass(EvalContext *ctx, Rlist **return_list, char *class_name, char *return_format)
char * GetRemoteScalar(EvalContext *ctx, char *proto, char *handle, const char *server, int encrypted, char *rcv)
const char * GetConsolePrefix()
void * CfRegLDAP(EvalContext *ctx, char *uri, char *dn, char *filter, char *name, char *scope, char *regex, char *sec)
void Nova_ClassHistoryEnable(StringSet **list, bool enable)
void Nova_ClassHistoryAddContextName(const StringSet *list, const char *context_name)
int PR_NOTKEPT
Definition: audit.c:34
void CacheUnreliableValue(char *caller, char *handle, char *buffer)
const EVP_CIPHER * CfengineCipher(char type)
void TranslatePath(char *new, const char *old)
int PR_REPAIRED
Definition: audit.c:33
void CheckAndSetHAState(const char *workdir, EvalContext *ctx)
char CfEnterpriseOptions()
int PR_KEPT
Definition: audit.c:32
void ReloadHAConfig()
int RetrieveUnreliableValue(char *caller, char *handle, char *buffer)
size_t EnterpriseGetMaxCfHubProcesses()
int CfSessionKeySize(char type)
void * CfLDAPArray(EvalContext *ctx, const Bundle *caller, char *array, char *uri, char *dn, char *filter, char *scope, char *sec)
FILE * safe_fopen(const char *const path, const char *const mode)
Definition: file_lib.c:812
char * MapName(char *s)
Definition: file_lib.c:441
#define NULL
Definition: getopt1.c:56
const char * GetLogDir(void)
Definition: known_dirs.c:146
const char * GetErrorStr(void)
Definition: logging.c:275
void Log(LogLevel level, const char *fmt,...)
Definition: logging.c:409
@ LOG_LEVEL_ERR
Definition: logging.h:42
@ LOG_LEVEL_VERBOSE
Definition: logging.h:46
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: strlcpy.c:34
Definition: policy.h:70
Definition: rlist.h:35
Definition: set.h:138