This change contains:
* New configuration keys: record_retention_enabled and
record_server_delivery_enabled. These keys are needed to control
remote delivery of records and record retention. These keys are
optional to preserve backward compatibility with existing custom
configurations.
* Record copy implementation. This change allows to save copies of
records locally when feature is enabled in configuration. This
operation is independent of record spooling and record reporting
to remote server.
* New telem_journal argument to allow record payload print from
local copy (if it exists).
Signed-off-by: avjarami <alex.v.jaramillo@intel.com>
Addressing comments from first code review and fixing travis-ci
check_journal error in prune test.
Signed-off-by: avjarami <alex.v.jaramillo@intel.com>
* An event_id header is needed to group records when multiple records
are generated by same event.
* Adding new available parameter to telem_record_gen, making possible
for this utility to tag multiple records with same event_id.
Signed-off-by: avjarami <alex.v.jaramillo@intel.com>
Because log messages from services contain arbitrary data, and sometimes
this data is privacy sensitive, only enable the log level filters when
the privacy filter override is in effect.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
Since strlen(opt_class) is already called before this for loop, there is
no need to call it again. It also avoids repeatedly calling strlen() as
part of the for-loop conditional check.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
Since the code repeats the same logic in several places, it is
convenient to split the routine into a helper function, startswith().
This also fixes a bug with the earlier port to libnica: in the
in_clr_build() function, strstr() was chosen as the replacement function
instead of strncmp(), which means a match will be found in any part of
the string. However, a match should only be found when it is a prefix.
To fix, switch the strstr() in that function to use startswith() as
well.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
During the processing of a core file or sending telemetry, any numbers
of errors may occur. Make sure the core file is not unlinked under these
conditions.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
When the path filters for privacy are in effect, backtraces are scrubbed
from records, and this results in the core files being unlinked.
However, this is not friendly behavior for the developer. A common
situation that triggers the path filters is installing custom binaries
on the system (say, under /usr/local/bin or /opt/bin) for testing
purposes. To better enable developers to debug their programs, having
the core files available to process with gdb is very valuable.
Eventually, I would like to add an opt-in to keep all core files, but
I'll wait until the configuration code is refactored.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
In case the value returned by SYSLOG_ACTION_SIZE_BUFFER exceeds MAX_BUF,
the buffer later allocated has size MAX_BUF, but SYSLOG_ACTION_READ may
read more than MAX_BUF bytes to store in the buffer, leading to a buffer
overrun.
Fix the issue by ensuring SYSLOG_ACTION_READ reads at most "buflen"
bytes, the size of the allocated buffer.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
Since loopsize is initialized to 0, the conditional statement where
loopsize increments led to the buffer size check not being executed the
first time through the loop.
Simply remove the counter variable to fix the issue.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
This completes the glib dependency removal work. The next commit will
clean up the makefiles and documentation.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
The checks in is_banned_path() for a path prefix not under /usr needed
to be connected with a logical AND, not OR, as implied by the recent
changes.
Also, use an explicit logical OR for the other two groups of
conditionals so that they are grouped similarly to the checks that
required an AND.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
As far as I can tell, the standard library doesn't have a function to
check for an ASCII string. Equivalently, we can iterate over each
character in the string, byte by byte, and verify that only 7-bit
characters are present.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
One more binary was using GOptionContext: telem-record-gen. Convert it
to use getopt_long() as well.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
Continuing the removal of dependency on glib, switch to use
getopt_long() instead of the GOptionContext API for the crash probe.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
Linux 4.10 introduced some format changes for oopses; one of the changes
was removing memory addresses from each stack frame.
This commit adds support for the new format and retains compatibility
for the previous format (4.9 and earlier).
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
The former skip_spaces() function only skipped a single space, so rename
it to skip_space(), and make skip_spaces() greedily consume spaces.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
The previous logic concatenates log messages on initial startup, when
the entire journal is read to process existing messages. But doing so
might run into the payload size limit (8KB), and thus fail to create a
record.
Sending one record per log message will ensure that the payload size
remains relatively small, almost always below the 8KB size limit.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>