Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Classify global variables

  • Loading branch information...
commit 38f725ce00fbf2c559a37a502865b0747aa08053 1 parent 89d29e6
Mikhail Gusarov dottedmag authored
Showing with 215 additions and 161 deletions.
  1. +54 −0 GLOBALS
  2. +7 −7 cf-agent/cf-agent.c
  3. +1 −1  cf-agent/files_links.c
  4. +1 −1  cf-agent/files_properties.c
  5. +3 −3 cf-agent/files_repository.c
  6. +2 −2 cf-agent/nfs.c
  7. +1 −1  cf-agent/verify_files_hashes.c
  8. +4 −4 cf-agent/verify_files_utils.c
  9. +7 −7 cf-agent/verify_packages.c
  10. +2 −2 cf-agent/verify_storage.c
  11. +4 −4 cf-execd/cf-execd.c
  12. +1 −1  cf-key/cf-key-functions.c
  13. +8 −8 cf-key/cf-key.c
  14. +10 −10 cf-runagent/cf-runagent.c
  15. +1 −1  cf-serverd/cf-serverd-functions.c
  16. +11 −11 cf-serverd/server.c
  17. +2 −2 cf-serverd/tls_server.c
  18. +3 −3 libcfnet/client_code.c
  19. +1 −1  libcfnet/client_protocol.c
  20. +3 −3 libcfnet/tls_client.c
  21. +1 −1  libenv/unix_iface.c
  22. +7 −7 libpromises/audit.c
  23. +34 −34 libpromises/cf3globals.c
  24. +1 −1  libpromises/conversion.c
  25. +2 −2 libpromises/crypto.c
  26. +3 −3 libpromises/dbm_api.c
  27. +1 −1  libpromises/dbm_tokyocab.c
  28. +2 −2 libpromises/extensions.c
  29. +1 −1  libpromises/files_lib.c
  30. +2 −2 libpromises/files_names.c
  31. +3 −3 libpromises/generic_agent.c
  32. +1 −1  libpromises/granules.c
  33. +3 −3 libpromises/known_dirs.c
  34. +5 −5 libpromises/locks.c
  35. +1 −1  libpromises/matching.c
  36. +6 −6 libpromises/mutex.c
  37. +1 −1  libpromises/parser.c
  38. +2 −2 libpromises/pipes_unix.c
  39. +1 −1  libpromises/policy.c
  40. +1 −1  libpromises/processes_select.c
  41. +2 −2 libpromises/signals.c
  42. +3 −3 libpromises/syslog_client.c
  43. +1 −1  libutils/buffer.c
  44. +5 −5 libutils/logging.c
54 GLOBALS
View
@@ -0,0 +1,54 @@
+This is a WiP classification of global variables in CFEngine created with the
+purpose of getting rid of them.
+
+GLOBAL_A
+--------
+
+Globals filled in during arguments parsing.
+
+Plan of attack: Move to ArgContext.
+
+GLOBAL_C
+--------
+
+Globals filled in during startup and not changed afterwards.
+
+Plan of attack: ?
+
+GLOBAL_E
+--------
+
+Globals filled in during environment detection and updated every time
+environment is re-read.
+
+Plan of attack: Move to EnvContext.
+
+GLOBAL_P
+--------
+
+Description: Globals filled in during policy parsing and/or body * control
+reading, and updated every time policy is re-read.
+
+Plan of attack: Move to evaluation time resolution as much as possible. Clearly
+state in documentation which variables cannot be resolved at evaluation
+time. Keep those in EvalContext (?).
+
+GLOBAL_R
+--------
+
+Static buffers used for returning values from functions.
+
+Plan of attack: allocate and return values instead of storing them in temporary
+variables.
+
+GLOBAL_T
+--------
+
+Mutexes, condition variables, once-controls and thread parameters.
+
+Plan of attack: change algorithms to share-nothing.
+
+GLOBAL_X
+--------
+
+All other unclassified globals.
14 cf-agent/cf-agent.c
View
@@ -109,16 +109,16 @@ extern int PR_KEPT;
extern int PR_REPAIRED;
extern int PR_NOTKEPT;
-static bool ALLCLASSESREPORT;
-static bool ALWAYS_VALIDATE;
-static bool CFPARANOID = false;
+static bool ALLCLASSESREPORT; /* GLOBAL_P */
+static bool ALWAYS_VALIDATE; /* GLOBAL_P */
+static bool CFPARANOID = false; /* GLOBAL_P */
-static Rlist *ACCESSLIST;
+static Rlist *ACCESSLIST; /* GLOBAL_P */
-static int CFA_BACKGROUND = 0;
-static int CFA_BACKGROUND_LIMIT = 1;
+static int CFA_BACKGROUND = 0; /* GLOBAL_X */
+static int CFA_BACKGROUND_LIMIT = 1; /* GLOBAL_P */
-static Item *PROCESSREFRESH;
+static Item *PROCESSREFRESH; /* GLOBAL_P */
static const char *const AGENT_TYPESEQUENCE[] =
{
2  cf-agent/files_links.c
View
@@ -678,7 +678,7 @@ static char *AbsLinkPath(const char *from, const char *relto)
and find the absolute name of the to object */
{
int pop = 1;
- static char destination[CF_BUFSIZE];
+ static char destination[CF_BUFSIZE]; /* GLOBAL_R */
if (IsAbsoluteFileName(relto))
{
2  cf-agent/files_properties.c
View
@@ -28,7 +28,7 @@
#include <files_interfaces.h>
#include <item_lib.h>
-static Item *SUSPICIOUSLIST = NULL;
+static Item *SUSPICIOUSLIST = NULL; /* GLOBAL_P */
void AddFilenameToListOfSuspicious(const char *pattern)
{
6 cf-agent/files_repository.c
View
@@ -34,9 +34,9 @@
/*********************************************************************/
-static Item *VREPOSLIST;
-static char REPOSCHAR;
-static char *VREPOSITORY = NULL;
+static Item *VREPOSLIST; /* GLOBAL_X */
+static char REPOSCHAR; /* GLOBAL_P */
+static char *VREPOSITORY = NULL; /* GLOBAL_P */
/*********************************************************************/
4 cf-agent/nfs.c
View
@@ -43,8 +43,8 @@
/* seconds */
#define RPCTIMEOUT 60
-static int FSTAB_EDITS;
-static Item *FSTABLIST = NULL;
+static int FSTAB_EDITS; /* GLOBAL_X */
+static Item *FSTABLIST = NULL; /* GLOBAL_X */
static void AugmentMountInfo(Seq *list, char *host, char *source, char *mounton, char *options);
static int MatchFSInFstab(char *match);
2  cf-agent/verify_files_hashes.c
View
@@ -367,7 +367,7 @@ void LogHashChange(const char *file, FileState status, char *msg, const Promise
char fname[CF_BUFSIZE];
time_t now = time(NULL);
mode_t perm = 0600;
- static char prevFile[CF_MAXVARSIZE] = { 0 };
+ static char prevFile[CF_MAXVARSIZE] = { 0 }; /* GLOBAL_X */
// we might get called twice..
if (strcmp(file, prevFile) == 0)
8 cf-agent/verify_files_utils.c
View
@@ -65,12 +65,12 @@
#define CF_RECURSION_LIMIT 100
-static Rlist *AUTO_DEFINE_LIST;
+static Rlist *AUTO_DEFINE_LIST; /* GLOBAL_P */
-Item *VSETUIDLIST;
+Item *VSETUIDLIST; /* GLOBAL_X */
-Rlist *SINGLE_COPY_LIST = NULL;
-static Rlist *SINGLE_COPY_CACHE = NULL;
+Rlist *SINGLE_COPY_LIST = NULL; /* GLOBAL_P */
+static Rlist *SINGLE_COPY_CACHE = NULL; /* GLOBAL_X */
static bool TransformFile(EvalContext *ctx, char *file, Attributes attr, const Promise *pp, PromiseResult *result);
static PromiseResult VerifyName(EvalContext *ctx, char *path, struct stat *sb, Attributes attr, const Promise *pp);
14 cf-agent/verify_packages.c
View
@@ -81,8 +81,8 @@ ENTERPRISE_VOID_FUNC_1ARG_DEFINE_STUB(void, ReportPatches, ARG_UNUSED PackageMan
/*****************************************************************************/
-PackageManager *PACKAGE_SCHEDULE = NULL;
-PackageManager *INSTALLED_PACKAGE_LISTS = NULL;
+PackageManager *PACKAGE_SCHEDULE = NULL; /* GLOBAL_X */
+PackageManager *INSTALLED_PACKAGE_LISTS = NULL; /* GLOBAL_X */
#define PACKAGE_LIST_COMMAND_WINAPI "/Windows_API"
@@ -2326,7 +2326,7 @@ static void DeletePackageManagers(PackageManager *newlist)
char *PrefixLocalRepository(Rlist *repositories, char *package)
{
- static char quotedPath[CF_MAXVARSIZE];
+ static char quotedPath[CF_MAXVARSIZE]; /* GLOBAL_R */
Rlist *rp;
struct stat sb;
char path[CF_BUFSIZE];
@@ -2570,10 +2570,10 @@ static int PrependPatchItem(EvalContext *ctx, PackageItem ** list, char *item, P
static int PrependMultiLinePackageItem(EvalContext *ctx, PackageItem ** list, char *item, int reset, const char *default_arch,
Attributes a, const Promise *pp)
{
- static char name[CF_MAXVARSIZE];
- static char arch[CF_MAXVARSIZE];
- static char version[CF_MAXVARSIZE];
- static char vbuff[CF_MAXVARSIZE];
+ static char name[CF_MAXVARSIZE]; /* GLOBAL_X */
+ static char arch[CF_MAXVARSIZE]; /* GLOBAL_X */
+ static char version[CF_MAXVARSIZE]; /* GLOBAL_X */
+ static char vbuff[CF_MAXVARSIZE]; /* GLOBAL_X */
if (reset)
{
4 cf-agent/verify_storage.c
View
@@ -42,7 +42,7 @@
#include <ornaments.h>
#include <eval_context.h>
-bool CF_MOUNTALL;
+bool CF_MOUNTALL; /* GLOBAL_X */
static PromiseResult FindStoragePromiserObjects(EvalContext *ctx, const Promise *pp);
static PromiseResult VerifyFileSystem(EvalContext *ctx, char *name, Attributes a, const Promise *pp);
@@ -59,7 +59,7 @@ static PromiseResult VerifyMountPromise(EvalContext *ctx, char *file, Attributes
Seq *GetGlobalMountedFSList(void)
{
- static Seq *mounted_fs_list = NULL;
+ static Seq *mounted_fs_list = NULL; /* GLOBAL_X */
if (!mounted_fs_list)
{
mounted_fs_list = SeqNew(100, free);
8 cf-execd/cf-execd.c
View
@@ -55,11 +55,11 @@
#define CF_EXEC_IFELAPSED 0
#define CF_EXEC_EXPIREAFTER 1
-static int NO_FORK;
-static int ONCE;
-static int WINSERVICE = true;
+static int NO_FORK; /* GLOBAL_A */
+static int ONCE; /* GLOBAL_A */
+static int WINSERVICE = true; /* GLOBAL_A */
-static pthread_attr_t threads_attrs;
+static pthread_attr_t threads_attrs; /* GLOBAL_T */
/*******************************************************************/
2  cf-key/cf-key-functions.c
View
@@ -39,7 +39,7 @@
#include <cf-key-functions.h>
-static const char *passphrase = "Cfengine passphrase";
+static const char *const passphrase = "Cfengine passphrase";
RSA* LoadPublicKey(const char* filename)
{
16 cf-key/cf-key.c
View
@@ -39,14 +39,14 @@
#include <cf-key-functions.h>
-int SHOWHOSTS = false;
-bool REMOVEKEYS = false;
-bool LICENSE_INSTALL = false;
-char LICENSE_SOURCE[MAX_FILENAME];
-const char *remove_keys_host;
-static char *print_digest_arg = NULL;
-static char *trust_key_arg = NULL;
-static char *KEY_PATH;
+int SHOWHOSTS = false; /* GLOBAL_A */
+bool REMOVEKEYS = false; /* GLOBAL_A */
+bool LICENSE_INSTALL = false; /* GLOBAL_A */
+char LICENSE_SOURCE[MAX_FILENAME]; /* GLOBAL_A */
+const char *remove_keys_host; /* GLOBAL_A */
+static char *print_digest_arg = NULL; /* GLOBAL_A */
+static char *trust_key_arg = NULL; /* GLOBAL_A */
+static char *KEY_PATH; /* GLOBAL_A */
static GenericAgentConfig *CheckOpts(int argc, char **argv);
20 cf-runagent/cf-runagent.c
View
@@ -132,16 +132,16 @@ static const char *const HINTS[] =
extern const ConstraintSyntax CFR_CONTROLBODY[];
-int INTERACTIVE = false;
-int OUTPUT_TO_FILE = false;
-char OUTPUT_DIRECTORY[CF_BUFSIZE];
-int BACKGROUND = false;
-int MAXCHILD = 50;
-char REMOTE_AGENT_OPTIONS[CF_MAXVARSIZE];
-
-Rlist *HOSTLIST = NULL;
-char SENDCLASSES[CF_MAXVARSIZE];
-char DEFINECLASSES[CF_MAXVARSIZE];
+int INTERACTIVE = false; /* GLOBAL_A */
+int OUTPUT_TO_FILE = false; /* GLOBAL_P */
+char OUTPUT_DIRECTORY[CF_BUFSIZE]; /* GLOBAL_P */
+int BACKGROUND = false; /* GLOBAL_P GLOBAL_A */
+int MAXCHILD = 50; /* GLOBAL_P GLOBAL_A */
+char REMOTE_AGENT_OPTIONS[CF_MAXVARSIZE]; /* GLOBAL_A */
+
+Rlist *HOSTLIST = NULL; /* GLOBAL_P GLOBAL_A */
+char SENDCLASSES[CF_MAXVARSIZE]; /* GLOBAL_A */
+char DEFINECLASSES[CF_MAXVARSIZE]; /* GLOBAL_A */
/*****************************************************************************/
2  cf-serverd/cf-serverd-functions.c
View
@@ -45,7 +45,7 @@
#include <file_lib.h>
static const size_t QUEUESIZE = 50;
-int NO_FORK = false;
+int NO_FORK = false; /* GLOBAL_A */
/*******************************************************************/
/* Command line options */
22 cf-serverd/server.c
View
@@ -51,20 +51,20 @@
//******************************************************************
int CLOCK_DRIFT = 3600; /* 1hr */
-int ACTIVE_THREADS;
+int ACTIVE_THREADS; /* GLOBAL_X */
-int CFD_MAXPROCESSES = 0;
-bool DENYBADCLOCKS = true;
+int CFD_MAXPROCESSES = 0; /* GLOBAL_P */
+bool DENYBADCLOCKS = true; /* GLOBAL_P */
-int MAXTRIES = 5;
-bool LOGENCRYPT = false;
-int COLLECT_INTERVAL = 0;
-int COLLECT_WINDOW = 10;
-bool SERVER_LISTEN = true;
+int MAXTRIES = 5; /* GLOBAL_P */
+bool LOGENCRYPT = false; /* GLOBAL_P */
+int COLLECT_INTERVAL = 0; /* GLOBAL_P */
+int COLLECT_WINDOW = 10; /* GLOBAL_P */
+bool SERVER_LISTEN = true; /* GLOBAL_P */
-ServerAccess SV;
+ServerAccess SV; /* GLOBAL_P */
-char CFRUNCOMMAND[CF_BUFSIZE] = { 0 };
+char CFRUNCOMMAND[CF_BUFSIZE] = { 0 }; /* GLOBAL_P */
//******************************************************************/
// LOCAL CONSTANTS
@@ -84,7 +84,7 @@ static int AuthenticationDialogue(ServerConnectionState *conn, char *recvbuffer,
// LOCAL STATE
//******************************************************************/
-static int TRIES = 0;
+static int TRIES = 0; /* GLOBAL_X */
/*******************************************************************/
4 cf-serverd/tls_server.c
View
@@ -36,8 +36,8 @@
#include <cf-serverd-enterprise-stubs.h>
#include <connection_info.h>
-static SSL_CTX *SSLSERVERCONTEXT = NULL;
-static X509 *SSLSERVERCERT = NULL;
+static SSL_CTX *SSLSERVERCONTEXT = NULL; /* GLOBAL_X */
+static X509 *SSLSERVERCERT = NULL; /* GLOBAL_X */
/**
6 libcfnet/client_code.c
View
@@ -65,7 +65,7 @@ typedef struct
/* With this lock we ensure we read the list head atomically, but we don't
* guarantee anything about the queue's contents. It should be OK since we
* never remove elements from the queue, only prepend to the head.*/
-static pthread_mutex_t cft_serverlist = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
+static pthread_mutex_t cft_serverlist = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; /* GLOBAL_T */
static void NewClientCache(Stat *data, AgentConnection *conn);
static void CacheServerConnection(AgentConnection *conn, const char *server);
@@ -82,7 +82,7 @@ static AgentConnection *ServerConnection(const char *server, FileCopy fc, int *e
int TryConnect(AgentConnection *conn, struct timeval *tvp, struct sockaddr *cinp, int cinpSz);
-ProtocolVersion SELECTED_PROTOCOL = CF_PROTOCOL_TLS; /* TODO command line / body common control policy option */
+ProtocolVersion SELECTED_PROTOCOL = CF_PROTOCOL_TLS; /* TODO command line / body common control policy option */ /* GLOBAL_P */
/**
@@ -102,7 +102,7 @@ static Seq *GetGlobalServerList(void)
{
/* Only ip address strings are stored in this list, so don't put any
* hostnames. TODO convert to list of (sockaddr_storage *) to enforce this. */
- static Seq *server_list = NULL;
+ static Seq *server_list = NULL; /* GLOBAL_X */
if (!server_list)
{
server_list = SeqNew(100, free);
2  libcfnet/client_protocol.c
View
@@ -45,7 +45,7 @@ extern char VFQNAME[];
/*********************************************************************/
-static int SKIPIDENTIFY;
+static int SKIPIDENTIFY; /* GLOBAL_P */
/*********************************************************************/
6 libcfnet/tls_client.c
View
@@ -39,8 +39,8 @@ extern char CFWORKDIR[];
/* Global SSL context for client connections over new TLS protocol. */
-static SSL_CTX *SSLCLIENTCONTEXT = NULL;
-static X509 *SSLCLIENTCERT = NULL;
+static SSL_CTX *SSLCLIENTCONTEXT = NULL; /* GLOBAL_X */
+static X509 *SSLCLIENTCERT = NULL; /* GLOBAL_X */
/**
@@ -49,7 +49,7 @@ static X509 *SSLCLIENTCERT = NULL;
bool TLSClientInitialize()
{
int ret;
- static bool is_initialised = false;
+ static bool is_initialised = false; /* GLOBAL_X */
if (is_initialised)
{
2  libenv/unix_iface.c
View
@@ -75,7 +75,7 @@ static bool IgnoreJailInterface(int ifaceidx, struct sockaddr_in *inaddr);
static bool IgnoreInterface(char *name);
static void InitIgnoreInterfaces(void);
-static Rlist *IGNORE_INTERFACES = NULL;
+static Rlist *IGNORE_INTERFACES = NULL; /* GLOBAL_E */
/*********************************************************************/
14 libpromises/audit.c
View
@@ -28,15 +28,15 @@
#include <logging.h>
#include <string_lib.h>
-int PR_KEPT;
-int PR_REPAIRED;
-int PR_NOTKEPT;
+int PR_KEPT; /* GLOBAL_X */
+int PR_REPAIRED; /* GLOBAL_X */
+int PR_NOTKEPT; /* GLOBAL_X */
-static double VAL_KEPT;
-static double VAL_REPAIRED;
-static double VAL_NOTKEPT;
+static double VAL_KEPT; /* GLOBAL_X */
+static double VAL_REPAIRED; /* GLOBAL_X */
+static double VAL_NOTKEPT; /* GLOBAL_X */
-static bool END_AUDIT_REQUIRED = false;
+static bool END_AUDIT_REQUIRED = false; /* GLOBAL_X */
#define CF_VALUE_LOG "cf_value.log"
68 libpromises/cf3globals.c
View
@@ -28,54 +28,54 @@
/* flags */
/*****************************************************************************/
-int SHOWREPORTS = false;
+int SHOWREPORTS = false; /* GLOBAL_A */
/*****************************************************************************/
/* operational state */
/*****************************************************************************/
-bool FIPS_MODE = false;
+bool FIPS_MODE = false; /* GLOBAL_P */
-struct utsname VSYSNAME;
+struct utsname VSYSNAME; /* GLOBAL_E */
-int CFA_MAXTHREADS = 10;
-int CF_PERSISTENCE = 10;
+int CFA_MAXTHREADS = 10; /* GLOBAL_P */
+int CF_PERSISTENCE = 10; /* GLOBAL_P */
-AgentType THIS_AGENT_TYPE;
+AgentType THIS_AGENT_TYPE; /* GLOBAL_C */
-Item *PROCESSTABLE = NULL;
+Item *PROCESSTABLE = NULL; /* GLOBAL_X */
Item *ROTATED = NULL;
/*****************************************************************************/
/* Internal data structures */
/*****************************************************************************/
-int LASTSEENEXPIREAFTER = SECONDS_PER_WEEK;
+int LASTSEENEXPIREAFTER = SECONDS_PER_WEEK; /* GLOBAL_P */
-char POLICY_SERVER[CF_MAX_IP_LEN] = { 0 };
+char POLICY_SERVER[CF_MAX_IP_LEN] = { 0 }; /* GLOBAL_X */
/*****************************************************************************/
/* Compatability infrastructure */
/*****************************************************************************/
-int IGNORELOCK = false;
-bool DONTDO = false;
+int IGNORELOCK = false; /* GLOBAL_A */
+bool DONTDO = false; /* GLOBAL_A */
-char VFQNAME[CF_MAXVARSIZE] = { 0 };
-char VUQNAME[CF_MAXVARSIZE] = { 0 };
-char VDOMAIN[CF_MAXVARSIZE] = { 0 };
+char VFQNAME[CF_MAXVARSIZE] = { 0 }; /* GLOBAL_E GLOBAL_P */
+char VUQNAME[CF_MAXVARSIZE] = { 0 }; /* GLOBAL_E */
+char VDOMAIN[CF_MAXVARSIZE] = { 0 }; /* GLOBAL_E GLOBAL_P */
-char VYEAR[5] = { 0 };
-char VDAY[3] = { 0 };
-char VMONTH[4] = { 0 };
-char VSHIFT[12] = { 0 };
+char VYEAR[5] = { 0 }; /* GLOBAL_E */
+char VDAY[3] = { 0 }; /* GLOBAL_E */
+char VMONTH[4] = { 0 }; /* GLOBAL_E */
+char VSHIFT[12] = { 0 }; /* GLOBAL_E */
-char CFWORKDIR[CF_BUFSIZE] = { 0 };
+char CFWORKDIR[CF_BUFSIZE] = { 0 }; /* GLOBAL_C */
/*
Default value for copytype attribute. Loaded by cf-agent from body control
*/
-char *DEFAULT_COPYTYPE = NULL;
+char *DEFAULT_COPYTYPE = NULL; /* GLOBAL_P */
/*
Keys for the agent. Loaded by GAInitialize (and hence every time policy is
@@ -83,7 +83,7 @@ char *DEFAULT_COPYTYPE = NULL;
Used in network protocol and leaked to language.
*/
-RSA *PRIVKEY = NULL, *PUBKEY = NULL;
+RSA *PRIVKEY = NULL, *PUBKEY = NULL; /* GLOBAL_X */
/*
First IP address discovered by DetectEnvironment (hence reloaded every policy
@@ -92,15 +92,15 @@ RSA *PRIVKEY = NULL, *PUBKEY = NULL;
Used somewhere in cf-execd, superficially in old-style protocol handshake and
sporadically in other situations.
*/
-char VIPADDRESS[CF_MAX_IP_LEN] = { 0 };
+char VIPADDRESS[CF_MAX_IP_LEN] = { 0 }; /* GLOBAL_E */
/*
Edition-time constant (MD5 for community, something else for Enterprise)
Used as a default hash everywhere (not only in network protocol)
*/
-HashMethod CF_DEFAULT_DIGEST;
-int CF_DEFAULT_DIGEST_LEN;
+HashMethod CF_DEFAULT_DIGEST; /* GLOBAL_C */
+int CF_DEFAULT_DIGEST_LEN; /* GLOBAL_C */
/*
Holds the "now" time captured at the moment of policy load (and in response to
@@ -108,55 +108,55 @@ int CF_DEFAULT_DIGEST_LEN;
Utilized everywhere "now" start time is needed
*/
-time_t CFSTARTTIME;
+time_t CFSTARTTIME; /* GLOBAL_E */
/*
Set in cf-serverd (from control body)/GenericAgentInitialize (defaults)
Used in network code
*/
-int CFENGINE_PORT;
+int CFENGINE_PORT; /* GLOBAL_P GLOBAL_E */
/*
Set in cf-agent/cf-runagent (from control body).
Used as a timeout for socket operations in network code.
*/
-time_t CONNTIMEOUT = 30; /* seconds */
+time_t CONNTIMEOUT = 30; /* seconds */ /* GLOBAL_A GLOBAL_P */
/*
Internal detail of timeout operations. Due to historical reasons
is defined here, not in libpromises/timeout.c
*/
-pid_t ALARM_PID = -1;
+pid_t ALARM_PID = -1; /* GLOBAL_X */
/*
Set in cf-agent (from control body).
Used as a default value for maxfilesize attribute in policy
*/
-int EDITFILESIZE = 10000;
+int EDITFILESIZE = 10000; /* GLOBAL_P */
/*
Set in cf-agent (from control body) and GenericAgentInitialize.
Used as a default value for ifelapsed attribute in policy.
*/
-int VIFELAPSED = 1;
+int VIFELAPSED = 1; /* GLOBAL_P */
/*
Set in cf-agent (from control body) and GenericAgentInitialize.
Used as a default value for expireafter attribute in policy.
*/
-int VEXPIREAFTER = 120;
+int VEXPIREAFTER = 120; /* GLOBAL_P */
/*
Set in cf-agent/cf-serverd (from control body).
Utilized in server/client code to bind sockets.
*/
-char BINDINTERFACE[CF_BUFSIZE] = { 0 };
+char BINDINTERFACE[CF_BUFSIZE] = { 0 }; /* GLOBAL_P */
/*
Set in cf-*.c:CheckOpts and GenericAgentConfigParseArguments.
@@ -166,7 +166,7 @@ char BINDINTERFACE[CF_BUFSIZE] = { 0 };
- GenericAgentCheckPolicy
- GenericAgentLoadPolicy (ReadPolicyValidatedFile)
*/
-bool MINUSF = false;
+bool MINUSF = false; /* GLOBAL_A */
/* Set in libenv/sysinfo.c::DetectEnvironment (called every time environment
reload is performed).
@@ -174,4 +174,4 @@ bool MINUSF = false;
Utilized all over the place, usually to look up OS-specific command/option to
call external utility
*/
-PlatformContext VSYSTEMHARDCLASS;
+PlatformContext VSYSTEMHARDCLASS; /* GLOBAL_E? */
2  libpromises/conversion.c
View
@@ -774,7 +774,7 @@ const char *CommandArg0(const char *execstr)
* WARNING: Not thread-safe.
**/
{
- static char arg[CF_BUFSIZE];
+ static char arg[CF_BUFSIZE]; /* GLOBAL_R */
const char *start;
char end_delimiter;
4 libpromises/crypto.c
View
@@ -60,7 +60,7 @@ static char *CFPRIVKEYFILE;
* lastseen db. */
-static bool crypto_initialized = false;
+static bool crypto_initialized = false; /* GLOBAL_X */
void CryptoInitialize()
{
@@ -483,7 +483,7 @@ const char *PrivateKeyFile(const char *workdir)
* Only pthread support - we don't create threads with any other API *
*********************************************************************/
-static pthread_mutex_t *cf_openssl_locks;
+static pthread_mutex_t *cf_openssl_locks; /* GLOBAL_T */
#ifndef __MINGW32__
unsigned long ThreadId_callback(void)
6 libpromises/dbm_api.c
View
@@ -61,11 +61,11 @@ struct DBCursor_
* This lock protects on-demand initialization of db_handles[i].lock and
* db_handles[i].name.
*/
-static pthread_mutex_t db_handles_lock = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
+static pthread_mutex_t db_handles_lock = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; /* GLOBAL_T */
-static DBHandle db_handles[dbid_max] = { { 0 } };
+static DBHandle db_handles[dbid_max] = { { 0 } }; /* GLOBAL_X */
-static pthread_once_t db_shutdown_once = PTHREAD_ONCE_INIT;
+static pthread_once_t db_shutdown_once = PTHREAD_ONCE_INIT; /* GLOBAL_T */
/******************************************************************************/
2  libpromises/dbm_tokyocab.c
View
@@ -117,7 +117,7 @@ static bool OpenTokyoDatabase(const char *filename, TCHDB **hdb)
return false;
}
- static int threshold = -1;
+ static int threshold = -1; /* GLOBAL_X */
if (threshold == -1)
{
4 libpromises/extensions.c
View
@@ -57,8 +57,8 @@
#ifndef BUILTIN_EXTENSIONS
-static bool enable_extension_libraries = true;
-static bool attempted_loading = false;
+static bool enable_extension_libraries = true; /* GLOBAL_X */
+static bool attempted_loading = false; /* GLOBAL_X */
void extension_libraries_disable()
{
2  libpromises/files_lib.c
View
@@ -36,7 +36,7 @@
#include <string_lib.h>
-static Item *ROTATED = NULL;
+static Item *ROTATED = NULL; /* GLOBAL_X */
/*********************************************************************/
4 libpromises/files_names.c
View
@@ -429,7 +429,7 @@ void TransformNameInPlace(char *s, char from, char to)
char *CanonifyName(const char *str)
{
- static char buffer[CF_BUFSIZE];
+ static char buffer[CF_BUFSIZE]; /* GLOBAL_R */
strncpy(buffer, str, CF_BUFSIZE);
CanonifyNameInPlace(buffer);
@@ -440,7 +440,7 @@ char *CanonifyName(const char *str)
char *CanonifyChar(const char *str, char ch)
{
- static char buffer[CF_BUFSIZE];
+ static char buffer[CF_BUFSIZE]; /* GLOBAL_R */
char *sp;
strncpy(buffer, str, CF_BUFSIZE - 1);
6 libpromises/generic_agent.c
View
@@ -63,9 +63,9 @@
#include <cf-windows-functions.h>
-static pthread_once_t pid_cleanup_once = PTHREAD_ONCE_INIT;
+static pthread_once_t pid_cleanup_once = PTHREAD_ONCE_INIT; /* GLOBAL_T */
-static char PIDFILE[CF_BUFSIZE];
+static char PIDFILE[CF_BUFSIZE]; /* GLOBAL_C */
static void VerifyPromises(EvalContext *ctx, const Policy *policy, GenericAgentConfig *config);
static void CheckWorkingDirectories(EvalContext *ctx);
@@ -1357,7 +1357,7 @@ static void CheckWorkingDirectories(EvalContext *ctx)
const char *GenericAgentResolveInputPath(const GenericAgentConfig *config, const char *input_file)
{
- static char input_path[CF_BUFSIZE];
+ static char input_path[CF_BUFSIZE]; /* GLOBAL_R */
switch (FilePathGetType(input_file))
{
2  libpromises/granules.c
View
@@ -29,7 +29,7 @@
char *GenTimeKey(time_t now)
{
struct tm tm;
- static char buf[18];
+ static char buf[18]; /* GLOBAL_R */
gmtime_r(&now, &tm);
6 libpromises/known_dirs.c
View
@@ -89,19 +89,19 @@ static const char *GetDefaultDir_helper(char dir[MAX_WORKDIR_LENGTH], const char
static const char *GetDefaultWorkDir(void)
{
- static char workdir[MAX_WORKDIR_LENGTH];
+ static char workdir[MAX_WORKDIR_LENGTH]; /* GLOBAL_C */
return GetDefaultDir_helper(workdir, WORKDIR);
}
static const char *GetDefaultLogDir(void)
{
- static char logdir[MAX_WORKDIR_LENGTH];
+ static char logdir[MAX_WORKDIR_LENGTH]; /* GLOBAL_C */
return GetDefaultDir_helper(logdir, LOGDIR);
}
static const char *GetDefaultPidDir(void)
{
- static char piddir[MAX_WORKDIR_LENGTH];
+ static char piddir[MAX_WORKDIR_LENGTH]; /* GLOBAL_C */
return GetDefaultDir_helper(piddir, PIDDIR);
}
10 libpromises/locks.c
View
@@ -42,11 +42,11 @@
#define CFLOGSIZE 1048576 /* Size of lock-log before rotation */
#define CF_LOCKHORIZON ((time_t)(SECONDS_PER_WEEK * 4))
-static char CFLOCK[CF_BUFSIZE] = { 0 };
-static char CFLAST[CF_BUFSIZE] = { 0 };
-static char CFLOG[CF_BUFSIZE] = { 0 };
+static char CFLOCK[CF_BUFSIZE] = { 0 }; /* GLOBAL_X */
+static char CFLAST[CF_BUFSIZE] = { 0 }; /* GLOBAL_X */
+static char CFLOG[CF_BUFSIZE] = { 0 }; /* GLOBAL_X */
-static pthread_once_t lock_cleanup_once = PTHREAD_ONCE_INIT;
+static pthread_once_t lock_cleanup_once = PTHREAD_ONCE_INIT; /* GLOBAL_X */
#ifdef LMDB
@@ -651,7 +651,7 @@ CfLock AcquireLock(EvalContext *ctx, const char *operand, const char *host, time
char cflock[CF_BUFSIZE], cflast[CF_BUFSIZE], cflog[CF_BUFSIZE];
char str_digest[CF_BUFSIZE];
char *rbt_key = NULL;
- static RBTree *rbt = NULL;
+ static RBTree *rbt = NULL; /* GLOBAL_X */
CfLock this;
unsigned char digest[EVP_MAX_MD_SIZE + 1];
2  libpromises/matching.c
View
@@ -113,7 +113,7 @@ static int RegExMatchFullString(EvalContext *ctx, pcre *rx, const char *teststri
/* Pure, non-thread-safe */
static char *FirstBackReference(pcre *rx, const char *teststring)
{
- static char backreference[CF_BUFSIZE];
+ static char backreference[CF_BUFSIZE]; /* GLOBAL_R */
int ovector[OVECCOUNT], i, rc;
12 libpromises/mutex.c
View
@@ -24,7 +24,7 @@
#include <mutex.h>
-static pthread_mutex_t MUTEXES[] =
+static pthread_mutex_t MUTEXES[] = /* GLOBAL_T */
{
PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP,
PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP,
@@ -33,11 +33,11 @@ static pthread_mutex_t MUTEXES[] =
PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP,
};
-pthread_mutex_t *cft_lock = &MUTEXES[0];
-pthread_mutex_t *cft_count = &MUTEXES[1];
-pthread_mutex_t *cft_getaddr = &MUTEXES[2];
-pthread_mutex_t *cft_server_children = &MUTEXES[3];
-pthread_mutex_t *cft_server_filter = &MUTEXES[4];
+pthread_mutex_t *cft_lock = &MUTEXES[0]; /* GLOBAL_T */
+pthread_mutex_t *cft_count = &MUTEXES[1]; /* GLOBAL_T */
+pthread_mutex_t *cft_getaddr = &MUTEXES[2]; /* GLOBAL_T */
+pthread_mutex_t *cft_server_children = &MUTEXES[3]; /* GLOBAL_T */
+pthread_mutex_t *cft_server_filter = &MUTEXES[4]; /* GLOBAL_T */
#define MUTEX_NAME_SIZE 32
2  libpromises/parser.c
View
@@ -32,7 +32,7 @@
int yyparse(void);
-ParserState P = { 0 };
+ParserState P = { 0 }; /* GLOBAL_X */
extern FILE *yyin;
4 libpromises/pipes_unix.c
View
@@ -35,8 +35,8 @@ static int CfSetuid(uid_t uid, gid_t gid);
static int cf_pwait(pid_t pid);
-static pid_t *CHILDREN;
-static int MAX_FD = 128; /* Max number of simultaneous pipes */
+static pid_t *CHILDREN; /* GLOBAL_X */
+static int MAX_FD = 128; /* GLOBAL_X */ /* Max number of simultaneous pipes */
static int InitChildrenFD()
{
2  libpromises/policy.c
View
@@ -2709,7 +2709,7 @@ void *PromiseGetConstraintAsRval(const Promise *pp, const char *lval, RvalType r
void PromiseRecheckAllConstraints(const EvalContext *ctx, const Promise *pp)
{
- static Item *EDIT_ANCHORS = NULL;
+ static Item *EDIT_ANCHORS = NULL; /* GLOBAL_X */
if (!IsDefinedClass(ctx, pp->classes, PromiseGetNamespace(pp)))
{
2  libpromises/processes_select.c
View
@@ -684,7 +684,7 @@ static void GetProcessColumnNames(char *proc, char **names, int *start, int *end
#ifndef __MINGW32__
static const char *GetProcessOptions(void)
{
- static char psopts[CF_BUFSIZE];
+ static char psopts[CF_BUFSIZE]; /* GLOBAL_R */
if (IsGlobalZone())
{
4 libpromises/signals.c
View
@@ -24,7 +24,7 @@
#include <signals.h>
-static bool PENDING_TERMINATION = false;
+static bool PENDING_TERMINATION = false; /* GLOBAL_X */
/********************************************************************/
@@ -35,7 +35,7 @@ bool IsPendingTermination(void)
/********************************************************************/
-static int SIGNAL_PIPE[2] = { -1, -1 };
+static int SIGNAL_PIPE[2] = { -1, -1 }; /* GLOBAL_C */
/**
* Make a pipe that can be used to flag that a signal has arrived.
6 libpromises/syslog_client.c
View
@@ -29,15 +29,15 @@
/*
* Set by cf-agent/cf-serverd from body agent/server control.
*/
-static char SYSLOG_HOST[MAXHOSTNAMELEN] = "localhost";
+static char SYSLOG_HOST[MAXHOSTNAMELEN] = "localhost"; /* GLOBAL_P */
/*
* Set by cf-agent/cf-serverd from body agent/server control.
*/
-static uint16_t SYSLOG_PORT = 514;
+static uint16_t SYSLOG_PORT = 514; /* GLOBAL_P */
/*
* Set by cf-agent/cf-serverd/cf-execd from body agent/exec/server control.
*/
-static int SYSLOG_FACILITY = LOG_USER;
+static int SYSLOG_FACILITY = LOG_USER; /* GLOBAL_P */
void SetSyslogFacility(int facility)
{
2  libutils/buffer.c
View
@@ -26,7 +26,7 @@
#include <buffer.h>
#include <refcount.h>
-static unsigned int general_memory_cap = DEFAULT_MEMORY_CAP;
+static unsigned int general_memory_cap = DEFAULT_MEMORY_CAP; /* GLOBAL_X */
unsigned int BufferGeneralMemoryCap()
{
return general_memory_cap;
10 libutils/logging.c
View
@@ -29,8 +29,8 @@
#include <string_lib.h>
#include <misc_lib.h>
-char VPREFIX[1024];
-bool LEGACY_OUTPUT = false;
+char VPREFIX[1024]; /* GLOBAL_C */
+bool LEGACY_OUTPUT = false; /* GLOBAL_A */
typedef struct
{
@@ -41,12 +41,12 @@ typedef struct
LoggingPrivContext *pctx;
} LoggingContext;
-static LogLevel global_level = LOG_LEVEL_NOTICE;
+static LogLevel global_level = LOG_LEVEL_NOTICE; /* GLOBAL_X */
static void LogToSystemLog(const char *msg, LogLevel level);
-static pthread_once_t log_context_init_once = PTHREAD_ONCE_INIT;
-static pthread_key_t log_context_key;
+static pthread_once_t log_context_init_once = PTHREAD_ONCE_INIT; /* GLOBAL_T */
+static pthread_key_t log_context_key; /* GLOBAL_T */
static void LoggingInitializeOnce(void)
{
Please sign in to comment.
Something went wrong with that request. Please try again.