Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bline #759

Merged
merged 119 commits into from
Mar 21, 2017
Merged

Bline #759

Show file tree
Hide file tree
Changes from 116 commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
0e56b93
minor friendliness changes
ldegio Mar 26, 2016
f41cd64
merge dev
ldegio Mar 27, 2016
fffae03
minor refactories
ldegio Mar 28, 2016
0c7e5ed
few more event listeners
ldegio Mar 30, 2016
21188ea
Merge branch 'dev' into bline
ldegio Mar 29, 2016
facfb5e
listener callback for clone()
ldegio Mar 30, 2016
67fbe6a
Merge branch 'dev' into bline
ldegio Mar 30, 2016
2505b36
merge dev
ldegio Apr 27, 2016
a1e1c45
merge dev
ldegio Apr 27, 2016
0edf066
some inlining
ldegio May 10, 2016
ef0d8f9
Merge branch 'dev' into bline
ldegio May 11, 2016
b113596
Merge branch 'dev' into bline
ldegio May 14, 2016
ebdb7c2
Merge branch 'dev' into bline
ldegio May 23, 2016
1c09754
Merge branch 'dev' into bline
ldegio May 26, 2016
009f43b
Merge branch 'dev' into bline
ldegio Jun 2, 2016
6ea6555
small interface change
ldegio Jun 3, 2016
eab1204
Merge branch 'dev' into bline
ldegio Jun 7, 2016
c74344b
Merge branch 'dev' into bline
ldegio Jun 8, 2016
c2e487d
the set_output_format chisel API call now supports base64 and jsonbase64
ldegio Jun 9, 2016
b93ef3f
calculate a simple hash for each process that falco can use
ldegio Jun 9, 2016
ea81f9e
Merge remote-tracking branch 'origin/master' into bline
gianlucaborello Jun 17, 2016
2ea93f7
Merge branch 'dev' into bline
ldegio Jun 24, 2016
60e8780
Merge branch 'dev' into bline
ldegio Jun 27, 2016
c01a0f4
minor typo
ldegio Jun 28, 2016
8b6cacd
save container IP with the right endianess
ldegio Jun 28, 2016
289de4f
merge dev
ldegio Jun 28, 2016
558c385
improve local address detection by matching against the full list of …
ldegio Jun 28, 2016
2c298ad
falco process hash includes the arguments if the process is a scripti…
ldegio Jun 30, 2016
2658ff0
Merge remote-tracking branch 'origin/dev' into bline
gianlucaborello Jul 1, 2016
43cbef4
Merge remote-tracking branch 'origin/dev' into bline
gianlucaborello Jul 9, 2016
b3b65dd
Merge branch 'dev' into bline
ldegio Jul 13, 2016
b01cdc5
Merge branch 'dev' into bline
ldegio Jul 15, 2016
b7cdaab
extract the image ID from the docker API
ldegio Jul 17, 2016
a823927
save/load the container ID from trace files
ldegio Jul 17, 2016
83d4e6f
Merge branch 'dev' into bline
ldegio Jul 24, 2016
21a98ef
Merge branch 'dev' into bline
ldegio Aug 25, 2016
6e1bc2d
Merge branch 'dev' into bline
ldegio Aug 29, 2016
9ac15e4
merge dev
ldegio Sep 12, 2016
42b8081
fix a merge issue
ldegio Sep 12, 2016
8627ade
Add container image id filtercheck. (#661)
mstemm Sep 22, 2016
30e1862
Merge branch 'dev' into bline
ldegio Sep 23, 2016
59a423b
Merge remote-tracking branch 'origin/dev' into bline
ltagliamonte Sep 26, 2016
7c9f599
Merge remote-tracking branch 'origin/dev' into bline
ltagliamonte Oct 2, 2016
03c14da
Merge remote-tracking branch 'origin/dev' into bline
ltagliamonte Oct 5, 2016
6a123ec
Merge remote-tracking branch 'origin/dev' into bline
ltagliamonte Oct 7, 2016
83f2fbd
Merge remote-tracking branch 'origin/dev' into bline
ltagliamonte Oct 10, 2016
1b10b70
minor changes required by the agent
ldegio Oct 10, 2016
d8f5763
compile error
ldegio Oct 10, 2016
f64d1f9
Merge remote-tracking branch 'origin/dev' into bline
ltagliamonte Oct 13, 2016
542e095
Merge branch 'dev' into bline
ldegio Dec 12, 2016
651de1a
some logging for debugging purposes
ldegio Dec 14, 2016
167e3a7
a bit more debug info
ldegio Dec 17, 2016
64af261
a bit more debug info
ldegio Dec 17, 2016
3967b24
a bit more debug info
ldegio Dec 18, 2016
2326ef0
a bit more debug info
ldegio Dec 18, 2016
bd35539
a bit more debug info
ldegio Dec 19, 2016
59ce2c6
a bit more debug info
ldegio Dec 19, 2016
23741d0
more debug info
ldegio Dec 20, 2016
1eefad3
more debug info
ldegio Dec 21, 2016
be7602e
debug info fix
ldegio Dec 22, 2016
a0bb843
decrease container verbosity
ldegio Dec 22, 2016
c0ee8d7
Merge branch 'dev' into bline
ldegio Dec 23, 2016
6a6a82d
Merge branch 'dev' into bline
ldegio Dec 24, 2016
24c539a
Merge branch 'dev' into bline
ldegio Dec 24, 2016
3301a8f
more debug info
ldegio Dec 24, 2016
9b9f28b
dump to memory functionality implemented
ldegio Dec 26, 2016
40e2dd4
proper support for tracers in memory dumps
ldegio Dec 27, 2016
4b3449f
bugfix: potential buffer underrun
ldegio Dec 27, 2016
340bb07
Merge branch 'dev' into bline
ldegio Dec 27, 2016
4040304
Merge branch 'bline' into memdump
ldegio Dec 27, 2016
593f405
fixed a bug when converting sinsp IPv6 FDs to scap
ldegio Dec 28, 2016
d26590f
compression experiments
ldegio Dec 29, 2016
3cd69ea
cleanups
ldegio Dec 30, 2016
3ca9988
cleanups
ldegio Dec 30, 2016
93ecd62
fix a comment
ldegio Dec 30, 2016
d52a01b
a couple of helper functions for memory dumps
ldegio Dec 31, 2016
9f212b2
don't restart event numbering when reading merged captures + FD initi…
ldegio Jan 1, 2017
aee8efe
Merge branch 'dev' into bline
ldegio Jan 8, 2017
0a79312
remove some logging
ldegio Jan 8, 2017
f79e21c
Merge branch 'bline' into memdump
ldegio Jan 8, 2017
99bcdd2
Merge branch 'dev' into bline
ldegio Jan 8, 2017
0fcc952
Merge branch 'bline' into memdump
ldegio Jan 8, 2017
c8237ea
small changes to support memory dumping
ldegio Jan 10, 2017
ca45bb2
dump a circular capture file when a command is run in the cassandra c…
ldegio Jan 10, 2017
08beb80
Merge branch 'dev' into bline
ldegio Jan 14, 2017
2c6add7
cleanups
ldegio Jan 14, 2017
ba08dd6
a bit on infrastructure for a notification event
ldegio Jan 16, 2017
02dcbf2
Merge branch 'dev' into bline
ldegio Jan 17, 2017
9dd0472
Merge branch 'bline' into memdump
ldegio Jan 17, 2017
cc1ae3c
notification event type
ldegio Jan 18, 2017
6dd58b8
merge dev
ldegio Jan 18, 2017
ea3fe61
merge bline
ldegio Jan 18, 2017
1989ef8
apply the filter in the successive segments of a merged capture only …
ldegio Jan 19, 2017
4aebb77
temporarily enable dump of any execve
ldegio Jan 19, 2017
4f88b0f
Merge branch 'bline' into memdump
ldegio Jan 19, 2017
d441676
some debug info
ldegio Jan 20, 2017
37a86ab
less aggressive logging
ldegio Jan 21, 2017
e18d93a
Merge branch 'dev' into bline
Jan 24, 2017
0050f5f
Merge branch 'dev' into bline
Jan 24, 2017
c4089dc
Restore scap_savefile
Jan 24, 2017
f277e42
heuristic to determine if a thread is part of a shell pipe
ldegio Jan 26, 2017
d65bfe5
fixes to the pipe detection heuristic
ldegio Jan 26, 2017
9246abf
propagate bash pipe flags in the execve parser
ldegio Jan 27, 2017
481732a
a coule of helper functions
ldegio Feb 6, 2017
eda2f6e
make sure the analyzer thread info is accessed only if available
ldegio Feb 9, 2017
4cf79e7
Merge branch 'dev' into bline
ldegio Feb 9, 2017
d4ec568
Merge branch 'bline' into memdump
ldegio Feb 9, 2017
6a926b9
EOLs
ldegio Feb 11, 2017
d80b0d7
Merge branch 'dev' into bline
ldegio Feb 11, 2017
c4e3bdf
Merge branch 'bline' into memdump
ldegio Feb 11, 2017
9e4d3dc
Merge branch 'dev' into bline
Feb 15, 2017
2c3a513
Merge branch 'bline' into memdump
ldegio Feb 19, 2017
cae0591
cleanups
ldegio Feb 19, 2017
6946ff2
cleanups
ldegio Feb 19, 2017
eff9aab
Merge branch 'memdump' into bline
ldegio Feb 19, 2017
a7fa662
merge dev
ldegio Mar 1, 2017
04edff1
removed an unused variable
ldegio Mar 6, 2017
9d5d984
Merge branch 'dev' into bline
ldegio Mar 6, 2017
ed82712
Merge remote-tracking branch 'origin/dev' into bline
gianlucaborello Mar 21, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ endif() # NOT WIN32 AND NOT APPLE
add_subdirectory(userspace/sysdig)
add_subdirectory(userspace/libscap)
add_subdirectory(userspace/libsinsp)
#add_subdirectory(userspace/falcobl)

set(CPACK_PACKAGE_NAME "${PACKAGE_NAME}")
set(CPACK_PACKAGE_VENDOR "Sysdig Inc.")
Expand Down
4 changes: 3 additions & 1 deletion driver/event_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,5 +301,7 @@ const struct ppm_event_info g_event_info[PPM_EVENT_MAX] = {
/* PPME_SYSCALL_MKDIR_2_E */{"mkdir", EC_FILE, EF_NONE, 1, {{"mode", PT_UINT32, PF_HEX} } },
/* PPME_SYSCALL_MKDIR_2_X */{"mkdir", EC_FILE, EF_NONE, 2, {{"res", PT_ERRNO, PF_DEC}, {"path", PT_FSPATH, PF_NA} } },
/* PPME_SYSCALL_RMDIR_2_E */{"rmdir", EC_FILE, EF_NONE, 0},
/* PPME_SYSCALL_RMDIR_2_X */{"rmdir", EC_FILE, EF_NONE, 2, {{"res", PT_ERRNO, PF_DEC}, {"path", PT_FSPATH, PF_NA} } }
/* PPME_SYSCALL_RMDIR_2_X */{"rmdir", EC_FILE, EF_NONE, 2, {{"res", PT_ERRNO, PF_DEC}, {"path", PT_FSPATH, PF_NA} } },
/* PPME_NOTIFICATION_E */{"notification", EC_OTHER, EF_SKIPPARSERESET, 2, {{"id", PT_CHARBUF, PF_DEC}, {"desc", PT_CHARBUF, PF_NA}, } },
/* PPME_NOTIFICATION_X */{"NA4", EC_SYSTEM, EF_UNUSED, 0}
};
8 changes: 7 additions & 1 deletion driver/ppm_events_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ along with sysdig. If not, see <http://www.gnu.org/licenses/>.
#define PPM_CL_ACTIVE (1 << 19) /* libsinsp-specific flag. Set in the first non-clone event for
this thread. */
#define PPM_CL_CLONE_NEWUSER (1 << 20)
#define PPM_CL_PIPE_SRC (1 << 21) /* libsinsp-specific flag. Set if this thread has been
detected to be the source in a shell pipe. */
#define PPM_CL_PIPE_DST (1 << 22) /* libsinsp-specific flag. Set if this thread has been
detected to be the destination in a shell pipe. */

/*
* Futex Operations
Expand Down Expand Up @@ -770,7 +774,9 @@ enum ppm_event_type {
PPME_SYSCALL_MKDIR_2_X = 277,
PPME_SYSCALL_RMDIR_2_E = 278,
PPME_SYSCALL_RMDIR_2_X = 279,
PPM_EVENT_MAX = 280
PPME_NOTIFICATION_E = 280,
PPME_NOTIFICATION_X = 281,
PPM_EVENT_MAX = 282
};
/*@}*/

Expand Down
4 changes: 3 additions & 1 deletion userspace/libscap/event_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,5 +301,7 @@ const struct ppm_event_info g_event_info[PPM_EVENT_MAX] = {
/* PPME_SYSCALL_MKDIR_2_E */{"mkdir", EC_FILE, EF_NONE, 1, {{"mode", PT_UINT32, PF_HEX} } },
/* PPME_SYSCALL_MKDIR_2_X */{"mkdir", EC_FILE, EF_NONE, 2, {{"res", PT_ERRNO, PF_DEC}, {"path", PT_FSPATH, PF_NA} } },
/* PPME_SYSCALL_RMDIR_2_E */{"rmdir", EC_FILE, EF_NONE, 0},
/* PPME_SYSCALL_RMDIR_2_X */{"rmdir", EC_FILE, EF_NONE, 2, {{"res", PT_ERRNO, PF_DEC}, {"path", PT_FSPATH, PF_NA} } }
/* PPME_SYSCALL_RMDIR_2_X */{"rmdir", EC_FILE, EF_NONE, 2, {{"res", PT_ERRNO, PF_DEC}, {"path", PT_FSPATH, PF_NA} } },
/* PPME_NOTIFICATION_E */{"notification", EC_OTHER, EF_SKIPPARSERESET, 2, {{"id", PT_CHARBUF, PF_DEC}, {"desc", PT_CHARBUF, PF_NA}, } },
/* PPME_NOTIFICATION_X */{"NA4", EC_SYSTEM, EF_UNUSED, 0}
};
7 changes: 5 additions & 2 deletions userspace/libscap/scap-int.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,17 @@ struct scap
typedef enum ppm_dumper_type
{
DT_FILE = 0,
DT_MEM = 0,
DT_MEM = 1,
}ppm_dumper_type;

struct scap_dumper
{
gzFile m_f;
ppm_dumper_type m_type;
uint64_t m_off;
uint8_t* m_targetbuf;
uint8_t* m_targetbufcurpos;
uint8_t* m_targetbufend;
uint64_t m_targetbufsize;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not really used apart from being defined in scap_memory_dump_open. Maybe we can remove it if not needed for other things.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 04edff1

};

struct scap_ns_socket_list
Expand Down
3 changes: 3 additions & 0 deletions userspace/libscap/scap.h
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,9 @@ int32_t scap_enable_tracers_capture(scap_t* handle);
uint64_t scap_get_unexpected_block_readsize(scap_t* handle);
int32_t scap_proc_add(scap_t* handle, uint64_t tid, scap_threadinfo* tinfo);
int32_t scap_fd_add(scap_threadinfo* tinfo, uint64_t fd, scap_fdinfo* fdinfo);
scap_dumper_t *scap_memory_dump_open(scap_t *handle, uint8_t* targetbuf, uint64_t targetbufsize);
int32_t compr(uint8_t* dest, uint64_t* destlen, const uint8_t* source, uint64_t sourcelen, int level);
uint8_t* scap_get_memorydumper_curpos(scap_dumper_t *d);

#ifdef __cplusplus
}
Expand Down
75 changes: 72 additions & 3 deletions userspace/libscap/scap_savefile.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,46 @@ int scap_dump_write(scap_dumper_t *d, void* buf, unsigned len)
{
return gzwrite(d->m_f, buf, len);
}
return 0;
else
{
if(d->m_targetbufcurpos + len < d->m_targetbufend)
{
memcpy(d->m_targetbufcurpos, buf, len);

d->m_targetbufcurpos += len;
return len;
}
else
{
return -1;
}
}
}

int32_t compr(uint8_t* dest, uint64_t* destlen, const uint8_t* source, uint64_t sourcelen, int level)
{
uLongf dl = compressBound(sourcelen);

if(dl >= *destlen)
{
return SCAP_FAILURE;
}

int res = compress2(dest, &dl, source, sourcelen, level);
if(res == Z_OK)
{
*destlen = (uint64_t)dl;
return SCAP_SUCCESS;
}
else
{
return SCAP_FAILURE;
}
}

uint8_t* scap_get_memorydumper_curpos(scap_dumper_t *d)
{
return d->m_targetbufcurpos;
}

#ifndef _WIN32
Expand Down Expand Up @@ -715,7 +754,9 @@ scap_dumper_t *scap_dump_open(scap_t *handle, const char *fname, compression_mod
scap_dumper_t* res = (scap_dumper_t*)malloc(sizeof(scap_dumper_t));
res->m_f = f;
res->m_type = DT_FILE;
res->m_off = 0;
res->m_targetbuf = NULL;
res->m_targetbufcurpos = NULL;
res->m_targetbufend = NULL;

if(scap_setup_dump(handle, res, fname) != SCAP_SUCCESS)
{
Expand All @@ -725,6 +766,34 @@ scap_dumper_t *scap_dump_open(scap_t *handle, const char *fname, compression_mod
return res;
}

//
// Open a memory "savefile"
//
scap_dumper_t *scap_memory_dump_open(scap_t *handle, uint8_t* targetbuf, uint64_t targetbufsize)
{
scap_dumper_t* res = (scap_dumper_t*)malloc(sizeof(scap_dumper_t));
if(res == NULL)
{
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "scap_dump_memory_open memory allocation failure (1)");
return NULL;
}

res->m_f = NULL;
res->m_type = DT_MEM;
res->m_targetbuf = targetbuf;
res->m_targetbufcurpos = targetbuf;
res->m_targetbufsize = targetbufsize;
res->m_targetbufend = targetbuf + targetbufsize;

if(scap_setup_dump(handle, res, "") != SCAP_SUCCESS)
{
free(res);
res = NULL;
}

return res;
}

//
// Close a "savefile" opened with scap_dump_open
//
Expand All @@ -749,7 +818,7 @@ int64_t scap_dump_get_offset(scap_dumper_t *d)
}
else
{
return d->m_off;
return (int64_t)d->m_targetbufcurpos - (int64_t)d->m_targetbuf;
}
}

Expand Down
34 changes: 30 additions & 4 deletions userspace/libsinsp/dumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ sinsp_dumper::sinsp_dumper(sinsp* inspector)
{
m_inspector = inspector;
m_dumper = NULL;
m_target_memory_buffer = NULL;
m_target_memory_buffer_size = 0;
}

sinsp_dumper::sinsp_dumper(sinsp* inspector, uint8_t* target_memory_buffer, uint64_t target_memory_buffer_size)
{
m_inspector = inspector;
m_dumper = NULL;
m_target_memory_buffer = target_memory_buffer;
m_target_memory_buffer_size = target_memory_buffer_size;
}

sinsp_dumper::~sinsp_dumper()
Expand All @@ -47,13 +57,20 @@ void sinsp_dumper::open(const string& filename, bool compress, bool threads_from
m_inspector->m_thread_manager->to_scap();
}

if(compress)
if(m_target_memory_buffer)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you're using m_target_memory_buffer non null == memory dump. Do you want to have an explicit type perhaps reusing ppm_dumper_type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I certainly could, but in such a simple scenario I don't see a big advantage in duplicating state and I would privilege simplicity over expressiveness.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine, it's easy enough to figure out which method is which.

{
m_dumper = scap_dump_open(m_inspector->m_h, filename.c_str(), SCAP_COMPRESSION_GZIP);
m_dumper = scap_memory_dump_open(m_inspector->m_h, m_target_memory_buffer, m_target_memory_buffer_size);
}
else
{
m_dumper = scap_dump_open(m_inspector->m_h, filename.c_str(), SCAP_COMPRESSION_NONE);
if(compress)
{
m_dumper = scap_dump_open(m_inspector->m_h, filename.c_str(), SCAP_COMPRESSION_GZIP);
}
else
{
m_dumper = scap_dump_open(m_inspector->m_h, filename.c_str(), SCAP_COMPRESSION_NONE);
}
}

if(m_dumper == NULL)
Expand All @@ -64,6 +81,15 @@ void sinsp_dumper::open(const string& filename, bool compress, bool threads_from
m_inspector->m_container_manager.dump_containers(m_dumper);
}

void sinsp_dumper::close()
{
if(m_dumper != NULL)
{
scap_dump_close(m_dumper);
m_dumper = NULL;
}
}

void sinsp_dumper::dump(sinsp_evt* evt)
{
if(m_dumper == NULL)
Expand All @@ -86,7 +112,7 @@ uint64_t sinsp_dumper::written_bytes()
{
if(m_dumper == NULL)
{
throw sinsp_exception("dumper not opened yet");
return 0;
}

int64_t written_bytes = scap_dump_get_offset(m_dumper);
Expand Down
25 changes: 24 additions & 1 deletion userspace/libsinsp/dumper.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ class SINSP_PUBLIC sinsp_dumper
*/
sinsp_dumper(sinsp* inspector);

/*!
\brief Constructs a dumper that saves to memory instead of disk.
Takes the address and the size of a preallocated memory buffer
where the data will go.
*/
sinsp_dumper(sinsp* inspector,
uint8_t* target_memory_buffer,
uint64_t target_memory_buffer_size);

~sinsp_dumper();

/*!
Expand All @@ -56,7 +65,14 @@ class SINSP_PUBLIC sinsp_dumper
\note There's no close() because the file is closed when the dumper is
destroyed.
*/
void open(const string& filename, bool compress, bool threads_from_sinsp=false);
void open(const string& filename,
bool compress,
bool threads_from_sinsp=false);

/*!
\brief Closes the dump file.
*/
void close();

/*!
\brief Return the current size of a tracefile.
Expand All @@ -77,9 +93,16 @@ class SINSP_PUBLIC sinsp_dumper
*/
void dump(sinsp_evt* evt);

inline uint8_t* get_memory_dump_cur_buf()
{
return scap_get_memorydumper_curpos(m_dumper);
}

private:
sinsp* m_inspector;
scap_dumper_t* m_dumper;
uint8_t* m_target_memory_buffer;
uint64_t m_target_memory_buffer_size;
};

/*@}*/
2 changes: 2 additions & 0 deletions userspace/libsinsp/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ VISIBILITY_PRIVATE
friend class sinsp_table;
friend class sinsp_cursesui;
friend class sisnp_baseliner;
friend class sinsp_memory_dumper;
friend class sinsp_memory_dumper_job;
};

/*@}*/
31 changes: 26 additions & 5 deletions userspace/libsinsp/parsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ void sinsp_parser::process_event(sinsp_evt *evt)
store_event(evt);
break;
case PPME_SYSCALL_WRITE_E:
if(!m_inspector->m_dumper)
if(!m_inspector->m_is_dumping)
{
evt->m_fdinfo = evt->m_tinfo->get_fd(evt->m_tinfo->m_lastevent_fd);
if(evt->m_fdinfo)
Expand Down Expand Up @@ -1344,7 +1344,7 @@ void sinsp_parser::parse_clone_exit(sinsp_evt *evt)
ASSERT(parinfo->m_len == sizeof(int32_t));
tinfo.m_uid = *(int32_t *)parinfo->m_val;

// Copy the uid
// Copy the gid
switch(etype)
{
case PPME_SYSCALL_CLONE_11_X:
Expand Down Expand Up @@ -1596,10 +1596,16 @@ void sinsp_parser::parse_execve_exit(sinsp_evt *evt)
// scap_fd_free_table(handle, tinfo);

//
// Clear the flags for this thread, making sure to propagate the inverted flag
// Clear the flags for this thread, making sure to propagate the inverted
// and shell pipe flags
//

auto spf = evt->m_tinfo->m_flags & (PPM_CL_PIPE_SRC | PPM_CL_PIPE_DST);
bool inverted = ((evt->m_tinfo->m_flags & PPM_CL_CLONE_INVERTED) != 0);

evt->m_tinfo->m_flags = PPM_CL_ACTIVE;

evt->m_tinfo->m_flags |= spf;
if(inverted)
{
evt->m_tinfo->m_flags |= PPM_CL_CLONE_INVERTED;
Expand All @@ -1616,7 +1622,10 @@ void sinsp_parser::parse_execve_exit(sinsp_evt *evt)
evt->m_tinfo->compute_program_hash();

#ifdef HAS_ANALYZER
evt->m_tinfo->m_ainfo->clear_role_flags();
if(evt->m_tinfo->m_ainfo != NULL)
{
evt->m_tinfo->m_ainfo->clear_role_flags();
}
#endif

//
Expand Down Expand Up @@ -2846,7 +2855,7 @@ uint32_t sinsp_parser::parse_tracer(sinsp_evt *evt, int64_t retval)

if(p->m_res == sinsp_tracerparser::RES_TRUNCATED)
{
if(!m_inspector->m_dumper)
if(!m_inspector->m_is_dumping)
{
evt->m_filtered_out = true;
}
Expand Down Expand Up @@ -3481,6 +3490,18 @@ void sinsp_parser::parse_dup_exit(sinsp_evt *evt)
//
if(retval >= 0)
{
//
// Heuristic to determine if a thread is part of a shell pipe
//
if(retval == 0)
{
evt->m_tinfo->m_flags |= PPM_CL_PIPE_DST;
}
if(retval == 1)
{
evt->m_tinfo->m_flags |= PPM_CL_PIPE_SRC;
}

if(evt->m_fdinfo == NULL)
{
return;
Expand Down
Loading